For example, this input...
{{1, 2}, {3, 4}}*{{1, 2}, {3, 4}}
produces this output...
{{1, 4}, {9, 16}}
and this input...
{{1, 2}, {3, 4}}^2
produces the same...
{{1, 4}, {9, 16}}
What I want in both cases is...
{{7, 10}, {15, 22}}
I think I know what's going on here. Mathematica doesn't seem to be discriminating between lists of lists, and matrices, and the *
and ^
operators are just threading over the lists.
I've found .
and MatrixPower
which do what I think *
and ^
should.
But the question still remains, is this confusing (to at least me) behavior of *
and ^
by design, and what benefit does it confer?
.
is (almost) the usual mathematical center-dot notation for matrix product. And that a superscript such as^2
would be ambiguous when applied to matrices; only context or convention would dictate that it means matrix power, which is made explicit byMatrixPower
. $\endgroup$