CABAIS_FINALS_LAB_ACT#2
CABAIS_FINALS_LAB_ACT#2
04/08/2025
Finals_Lab_Act#1
Sub:CSE_2
BSCS-2B
I. Introduction
Matrices are basic mathematical and computer science concepts. As arrays of numbers displayed in
rows and columns, matrices are useful aids for representing sophisticated systems and carrying out
matrices are often employed to describe and solve systems of equations, they are used in many fields
One of the most frequent and computationally important operations on matrices is matrix
multiplication. If several matrices are multiplied, the number of scalar multiplications needed
depends greatly on the way the matrices are parenthesized for multiplication. While matrix
This optimization problem leads to the Matrix Chain Multiplication (MCM) problem, a traditional
dynamic programming problem in algorithm design. It finds the optimal method of multiplying a
chain of matrices by finding the best sequence of operations. The aim of this paper is to discuss the
conceptual basis of MCM and examine its wide variety of applications in various fields, illustrating
Matrix Chain Multiplication is concerned with finding the minimum number of scalar multiplications
required to compute the product of a chain of matrices. Let there be nnn matrices A1,A2,...,AnA_1,
A_2,..., A_nA1,A2,...,An, where the dimensions of matrix AiA_iAi are pi−1×pip_{i-1} \times
pipi−1×pi. What is not aimed for is doing the multiplications but determining the optimal way of
parenthesizing the product in order to have the minimum number of scalar multiplications.
resulting in different computational costs. For example, to multiply a 10×10010 \\times 10010×100
matrix by a 100×5100 \\times 5100×5 matrix takes 5,000 multiplications, while to multiply a
100×5100 \\times 5100×5 matrix by a 5×505 \\times 505×50 matrix takes only 25,000 operations. If
the chain consists of more than three matrices, the number of possible parenthesizations increases
exponentially.
Dynamic programming provides a more efficient solution to this problem. Dynamic programming
breaks down the core problem into overlapping subproblems, solves every subproblem once, and
remembers the outcomes so that the outcomes can be reused. The standard algorithm builds a table to
track the minimum number of operations involved in calculating each sub-chain of matrices. This
approach ensures that the computation is performed in polynomial time, namely O(n3)O(n^3)O(n3),
Though founded on theoretical grounds at the start, Matrix Chain Multiplication is now used far and
wide across different fields requiring matrix operations as components of more elaborate, advanced
systems.
represented in the form of matrices and applied to objects by multiplying them with the coordinate
Instead of applying each transformation individually to the object, graphics engines combine all the
transformation matrices into one composite matrix. In situations where many transformation matrices
are necessary, determining the best order to multiply matrices to minimize computation and enhance
rendering efficiency is crucial. The MCM algorithm allows for rendering engines to optimize latency
real-time scenarios like video games, virtual reality (VR), and augmented reality (AR), where frame
Scientific computing typically consists of the simulation of physical systems with mathematical
models expressed in the matrix format. Some examples are simulating electrical circuits, fluid
dynamics, mechanical stress patterns, and chemical reactions. The simulations need to solve very
large systems of linear equations or evaluate matrix expressions involving scores or hundreds of
matrices.
For example, in finite element techniques (FEM) applied in engineering analysis, different element
matrices are assembled and multiplied to create global system matrices. Fast multiplication of the
matrices can greatly affect the performance of the simulation, particularly when working with large-
scale systems that have millions of degrees of freedom. MCM offers a way of optimizing such
matrix expressions and thus decreasing overall computation time without changing the physical
optimization in relational databases. For query processing, join operations of tables may also be
viewed on similar lines to matrix multiplication. Each operation by join processes the rows from two
Database management systems (DBMS) employ query optimizers to decide how to best execute a
query, and frequently this is done by rearranging join operations to reduce computational expense.
Through algorithms like MCM, optimizers try different orders of joins and choose the one that
minimizes the query's cost overall. This is particularly helpful in data warehousing and big data
analytics involving large databases, where queries may be joining many large tables and performance
optimization is critical.
citizens.
operations can be translated into series of lower-level commands. MCM-like algorithms are used by
the compiler to determine the most efficient sequence of evaluation. This optimizes memory access
Matrix operations form the core of machine learning and deep learning, and in both, forward and
backward propagation steps consist of a series of matrix multiplications. For example, in deep neural
networks (DNNs), every layer consists of matrix multiplications between the input features and the
optimized back-end linear algebra libraries (e.g., BLAS, cuBLAS), the computation underlying can
still be improved using MCM principles, especially when there are a series of linear transformations
composed together. Reordering these operations can save computational overhead, especially in
In addition, in training big models like transformer architectures or CNNs, the training time is
usually several days or even weeks. Any increase in efficiency of matrix computations directly
Matrix operations are also common in bioinformatics for problems involving sequence alignment,
building phylogenetic trees, and the analysis of gene expression, among others. Such problems
typically involve the computation and comparison of large similarity or distance matrices.
Matrix Chain Multiplication can be used to make dynamic programming algorithm computations
more efficient, like in the Needleman–Wunsch and Smith–Waterman algorithms for sequence
alignment. These algorithms build scoring matrices whose computation can be made more efficient
by using MCM techniques. Moreover, in systems biology, biochemical reaction networks are
represented with matrix algebra, and efficient matrix multiplication is then needed for simulation and
analysis.
In robotics, coordinate frame transformations play an important role in calculating the position and
orientation of robot parts. They are modeled by homogeneous transformation matrices that are
chained up and multiplied together to calculate the end effector's final pose relative to the base
frame.
When robotic arms possess numerous joints, the number of transformations is high, and minimizing
the multiplication order using MCM becomes useful in lowering the computation time of motion
planning algorithms. This is vital in real-time systems where reaction time is paramount for safety
and accuracy.
Example:
A1=10×30 =10×30
A2=30×5 = 30×5
A3=5×60 = 5×60
A4=60×10 =60×10
We want to find the optimal way to multiply them. Naively computing all combinations would
involve trying different parenthesizations:
((A1A2)A3)A4
(A1(A2A3))A4
(A1A2)(A3A4)
By using the dynamic programming approach to matrix chain multiplication, we find that the
minimal cost is achieved using the parenthesization:
((A1A2)(A3A4))
This reduces the total scalar multiplications required from potentially over 30,000 to around 4,500.
As extensive as its usage is, though, Matrix Chain Multiplication also has its draw backs. Primarily,
while the dynamic programming method of breaking the MCM problem down exists in
O(n3)O(n^3)O(n3) and is therefore less than ideal in cases of matrices that form a very long chain,
more complicated methods like using sparse matrix forms or heuristic codes could provide increases
Second, the MCM problem has the implicit assumption that all the matrices used are dense and does
not in itself account for sparsity. In most practical applications, matrices can have large quantities of
zero entries. Sparse matrix algorithms implemented especially for this purpose are usually superior to
Furthermore, the MCM algorithm requires complete knowledge of the dimensions of all matrices
involved. In dynamic or real-time systems where matrix sizes may vary based on input data, this
information may not always be available beforehand, limiting the algorithm's applicability.
Lastly, whereas MCM targets the optimization of scalar multiplications, it fails to consider other key
factors like memory access patterns, cache usage, or parallelizability of operations. In contemporary
high-performance computing settings, these are usually equally significant as the reduction of
arithmetic operations.
V. Conclusion
Matrix Chain Multiplication, though originally presented as a textbook problem in algorithm design,
Ranging from enhanced performance in graphics and scientific simulation to database query
The importance of MCM is its capacity to lower computational overhead while not sacrificing the
integrity of the end result. By identifying the most effective chain of matrix multiplications, it allows
systems to compute faster and more economically, especially in conditions where computational
theoretical underpinnings established by MCM still affect optimization methods in research studies
as well as in commercial endeavors. With growing sizes of data and complexities in systems,
requirements for matrix operations with optimal efficiency will continue to rise, guaranteeing Matrix
Chain Multiplication a place as an aid for computational efficiency well into the future.
In an era driven by data, computation, and optimization, MCM reaffirms the strength of traditional
References
Aho, A. V., Lam, M. S., Sethi, R., & Ullman, J. D. (2006). Compilers: Principles,
techniques, and tools (2nd ed.). Addison-Wesley.
https://www.pearson.com/en-us/subject-catalog/p/compilers-principles-techniques-
and-tools/P200000003702
Cormen, T. H., Leiserson, C. E., Rivest, R. L., & Stein, C. (2009). Introduction to
algorithms (3rd ed.). MIT Press.
https://mitpress.mit.edu/9780262033848/introduction-to-algorithms/
Golub, G. H., & Van Loan, C. F. (2013). Matrix computations (4th ed.). Johns
Hopkins University Press. https://jhupbooks.press.jhu.edu/title/matrix-computations
Kumar, V., Grama, A., Gupta, A., & Karypis, G. (1994). Introduction to parallel
computing: Design and analysis of algorithms. Benjamin/Cummings. https://www-
users.cs.umn.edu/~karypis/parbook/
Nocedal, J., & Wright, S. J. (2006). Numerical optimization (2nd ed.). Springer.
https://link.springer.com/book/10.1007/978-0-387-40065-5
Press, W. H., Teukolsky, S. A., Vetterling, W. T., & Flannery, B. P. (2007).
Numerical recipes: The art of scientific computing (3rd ed.). Cambridge University
Press. https://numerical.recipes/
Rosen, K. H. (2012). Discrete mathematics and its applications (7th ed.). McGraw-
Hill Education. https://www.mheducation.com/highered/product/discrete-
mathematics-its-applications-rosen/M9780073383095.html