^

Matrix power operator.

Category: Language Fundamentals > Operators and Elementary Operations

Syntax

C = A ^ p

Raises the square matrix A to the power p. Same as mpower(A, p).

Description

A^2 is A*A, and A^-1 is inv(A). Use sqrtm for a matrix square root.

When both operands are scalars the result is the ordinary power. For element-wise powers of an array use .^.

Input arguments

A
Square matrix, or a scalar.
p
Scalar exponent. An integer gives repeated multiplication; a negative integer uses the inverse.

Output arguments

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

Example

A = [1 1; 1 0];
A ^ 5
A ^ -1
Output
ans = 2×2

     8     5
     5     3
ans = 2×2

     0     1
     1    -1

See also

mpower .^ expm inv sqrtm