Sequences and Series – Why Wolfram Alpha Gives Different Answers for Sum of a Matrix

matricessequences-and-serieswolfram alpha

I would like to find out what $\sum_{r=1}^{n} \pmatrix{1 & -1 \\ 0 & 2}^r$ is equal to.

I have typed this expression into WolramAlpha twice and got a different answer each time, both inconsistent.

Attempt 1

Attempt 1

Attempt 2

Attempt 2

We can see the entry in the top right is not the same in both answers and those expressions are definitely not equal.

My question is: why is WolframAlpha giving different answers?

Best Answer

WolframAlpha is just some natural language input parsing on top of a limited form of Wolfram Language: the programming language used in Mathematica.

If Mathematica were given {{1,-1},{0,2}}^r, it would not take the $r^{\text{th}}$ power of the $2 \times 2$ matrix in the usual linear algebra sense; it would instead take the $r^{\text{th}}$ power of each entry. You would have to write MatrixPower[{{1,-1},{0,2}},r] for the desired result.

WolframAlpha is a little bit better at guesing what you want: if you write {{1,-1},{0,2}}^r, it seems to guess that you mean a matrix power. If you write ({{1,-1},{0,2}})^(r), that's too confusing for WolframAlpha, and it falls back to the default (and probably wrong) interpretation.

So that's the difference between the two expressions. In the first case, WolframAlpha is taking matrix powers and adding them up. In the second case, WolframAlpha is dealing with each entry of the matrix separately.

If you do not want to rely on WolframAlpha guessing what you want, you can use syntax closer to Mathematica syntax to disambiguate. For example, you can ask WolframAlpha to compute

sum of MatrixPower[{{1,-1},{0,2}},r] from r=1 to n

and when you get the output (which is the same as your first result), you can be certain that WolframAlpha is taking the correct kind of matrix power.