##
**Matrix Chain
Multiplication**

- Matrix chain multiplication (or Matrix Chain Ordering Problem, MCOP) is an optimization problem that can be solved using dynamic programming.
- Given a sequence of matrices, the goal is to find the most efficient way to multiply these matrices.
- The problem is not actually to perform the multiplications, but merely to decide the sequence of the matrix multiplications involved.
- Here are many options because matrix multiplication is associative. In other words, no matter how the product is parenthesized, the result obtained will remain the same. For example, for four matrices A, B, C, and D, we would have:

((AB)C)D
= ((A(BC))D) = (AB)(CD) = A((BC)D) = A(B(CD))

###
**Example of Matrix Chain
Multiplication**

**Example:**

Sequence
{4, 10, 3, 12, 20, and 7}. The matrices have size 4 x 10, 10 x 3, 3 x 12, 12 x
20, 20 x 7. We need to compute M [i,j], 0 ≤ i, j≤ 5.

We know M [i, i] = 0 for
all i.

Here P0 to P5 are Position
and M1 to M5 are matrix of size (pi to pi-1)

On the basis of sequence, we make
a formula

In Dynamic Programming,
initialization of every method done by '0'.So we initialize it by '0'.It will
sort out diagonally.

We have to sort out all
the combination but the minimum output combination is taken into consideration.

####
**Pseudo code**