I need to write a program, which shows the different combinations in which matrices can be multiplied.

The output should look like below :
When there are two matrices multiplied there is one combination
(XX)

When there are three matrices multiplied there are two combinations
(X(XX)) ((XX)X)

When there are four matrices multiplied there are five combinations
(X(X(XX))) ((X(XX))X) (X((XX)X)) (((XX)X)X) ((XX)(XX))

Thank you,

3
Contributors
3
Replies
4
Views
8 Years
Discussion Span
Last Post by jwenting

think recursion.

I need to write a program, which shows the different combinations in which matrices can be multiplied.

The output should look like below :
When there are two matrices multiplied there is one combination
(XX)

When there are three matrices multiplied there are two combinations
(X(XX)) ((XX)X)

When there are four matrices multiplied there are five combinations
(X(X(XX))) ((X(XX))X) (X((XX)X)) (((XX)X)X) ((XX)(XX))

Thank you,

Matrix multiplication is non-commutative operation, so X*Y!=Y*X.
XY -> 2 combinations XY and YX
XYZ -> respectively 8 combinations.
But maybe it can be that your assignment ignores this fact for the sake of simplicity of assignment.

Matrix multiplication is non-commutative operation, so X*Y!=Y*X.