Wolframalpha yields different results of matrix multiplication based on parentheses placement

180 Views Asked by At

I was trying to multiply some matrices using wolframalpha when I found that the results didn't match up. Specifically, matrix expression like $CX^2C^{-1}$ produced different result than $CXC^{-1}CXC^{-1}$, although these should be the same. I found that this happens because wolframalpha calculates the product differently based on how the parentheses are placed. Here are two examples:

First expression

({{1,1},{-1,0}}*{{2,1},{1,2}}*{{1,1},{-1,0}}^-1)*{{1,1},{-1,0}}*{{2,1},{1,2}}*{{1,1},{-1,0}}^-1

enter image description here

Second expression:

{{1,1},{-1,0}}*{{2,1},{1,2}}*{{1,1},{-1,0}}^-1*{{1,1},{-1,0}}*{{2,1},{1,2}}*{{1,1},{-1,0}}^-1

enter image description here

Is there an adequate reason for this or is it a bug?

1

There are 1 best solutions below

5
On BEST ANSWER

As it was mentioned in a comment, you are missing a dot in the first expression. When you don't use the dot (or use *) Wolfram will compute the product as $$ (A*B)_{ij} = a_{ij} b_{ij}$$ when you really wanted it to compute $$(A.B)_{ij} = \sum_{k=1}^n a_{ik} b_{kj}$$

In the second expression, you always use "*", so you are not computing what you expect.

Computers don't do what we want, they do what we ask.

Also consider that, even though this does not seem to be a problem for wolframalpha, in Wolfram Mathematica $\texttt{A^(-1)}$ does not represent the inverse... you must use $\texttt{Inverse[A]}$.

This post was probably a better fit for http://mathematica.stackexchenge.com