Most programming languages have a built-in implementation of exponentiation for integers and reals only.



Task

Demonstrate how to implement matrix exponentiation as an operator.




M = [ 3, 2; 2, 1 ];
M^0
M^1
M^2
M^(-1)
M^0.5