mpower

Matrix power, the ^ operator.

Category: Mathematics > Linear Algebra

Syntax

C = A^p

Raises the square matrix A to the scalar power p.

C = mpower(A, p)

Function form of A^p.

Description

A^2 is A*A, which differs from A.^2 that squares each entry. A^0 is the identity and A^-1 is inv(A). Integer powers are computed by repeated squaring.

In full generality A^p with non-integer p, or s^A with scalar s, is defined through eigenvalues: A^p = V*D.^p/V and s^A = expm(log(s)*A).

Input arguments

A
Square matrix (or a scalar).
p
Scalar exponent. Integers are exact products; a negative integer uses the inverse.

Output arguments

C
The matrix power, of the same size as A.

Example

Integer powers

A = [1 1; 0 1];
A^3
[2 0; 0 4]^-1
[1 2; 3 4]^0
mpower(2, 3)
Output
ans = 2×2

     1     3
     0     1
ans = 2×2

    0.5000         0
         0    0.2500
ans = 2×2

     1     0
     0     1
ans = 8

See also

power mtimes expm sqrtm inv