In addition to the other answers, it is possible to rise any square matrix to the power of any other square matrix (even of different order).
I use the following Mathematica code for this:
Clear["Global`*"]
$PrePrint =.; FormatValues@Matrix = {};
Hold[MakeBoxes[Matrix[a_], StandardForm] ^:=
Block[{Internal`$ConvertForms = {}},
TemplateBox[{MakeBoxes[MatrixForm@a][[1, 1, 3]]}, "Matrix",
DisplayFunction -> (RowBox@{style@"(", "\[NoBreak]", #,
"\[NoBreak]", style@")"} &)]]] /.
style[string_] -> StyleBox[string, FontColor -> Red] // ReleaseHold
Unprotect[Dot];
Dot[x_?NumberQ, y_] := x y;
Dot[A_?SquareMatrixQ, B_?SquareMatrixQ] :=
Matrix[KroneckerProduct[A,
IdentityMatrix[LCM[Length[A], Length[B]]/Length[A]]] .
KroneckerProduct[B,
IdentityMatrix[LCM[Length[A], Length[B]]/Length[B]]]] /;
Length[A] != Length[B];
Protect[Dot];
Unprotect[Power];
Power[0, 0] = 1;
Protect[Power];
Matrix /: Matrix[x_?MatrixQ] :=
First[First[x]] /; x == First[First[x]] IdentityMatrix[Length[x]];
Matrix /: NonCommutativeMultiply[Matrix[x_?MatrixQ], y_] :=
Dot[Matrix[x], y];
Matrix /: NonCommutativeMultiply[y_, Matrix[x_?MatrixQ]] :=
Dot[y, Matrix[x]];
Matrix /: Dot[Matrix[x_], Matrix[y_]] := Matrix[x . y];
Matrix /: Matrix[x_] + Matrix[y_] := Matrix[x + y];
Matrix /: x_?NumericQ + Matrix[y_] :=
Matrix[x IdentityMatrix[Length[y]] + y];
Matrix /: x_?NumericQ Matrix[y_] := Matrix[x y];
Matrix /: Matrix[x_]*Matrix[y_] := Matrix[x . y] /; x . y == y . x;
Matrix /: Power[Matrix[x_?MatrixQ], y_?NumericQ] :=
Matrix[MatrixPower[x, y]];
Matrix /: Power[Matrix[x_?MatrixQ], Matrix[y_?MatrixQ]] :=
Exp[Log[Matrix[x]] . Matrix[y]];
Matrix /: Log[Matrix[x_?MatrixQ], Matrix[y_?MatrixQ]] :=
Log[Matrix[x]]^-1 . Log[Matrix[y]]
Matrix /: Dot[Matrix[A_?SquareMatrixQ], Matrix[B_?SquareMatrixQ]] :=
Matrix[KroneckerProduct[A,
IdentityMatrix[LCM[Length[A], Length[B]]/Length[A]]] .
KroneckerProduct[B,
IdentityMatrix[LCM[Length[A], Length[B]]/Length[B]]]]
$Post2 =
FullSimplify[# /.
f_[args1___?NumericQ, Matrix[mat_], args2___?NumericQ] :>
Matrix[MatrixFunction[f[args1, #, args2] &, mat]]] &;
$Post = Nest[$Post2, #, 3] /. Dot -> NonCommutativeMultiply &;
Now one can use something like this:
Matrix[ {
{0, 1},
{1, 0}
} ] ^ Matrix[ {
{0, 0, 1},
{1, 0, 0},
{0, 1, 0}
} ]
And get the result. Note though, the computation takes long time and the result may be huge in volume and include Root
objects.