Main Content

mpower, ^

Symbolic matrix power

Description

example

A^B computes A to the B power.

mpower(A,B) is equivalent to A^B.

Examples

Matrix Base and Scalar Exponent

Create a 2-by-2 matrix.

A = sym('a%d%d', [2 2])
A =
[ a11, a12]
[ a21, a22]

Find A^2.

A^2
ans =
[   a11^2 + a12*a21, a11*a12 + a12*a22]
[ a11*a21 + a21*a22,   a22^2 + a12*a21]

Scalar Base and Matrix Exponent

Create a 2-by-2 symbolic magic square.

A = sym(magic(2))
A =
[ 1, 3]
[ 4, 2]

Find πA.

sym(pi)^A
ans =
[   (3*pi^7 + 4)/(7*pi^2), (3*(pi^7 - 1))/(7*pi^2)]
[ (4*(pi^7 - 1))/(7*pi^2),   (4*pi^7 + 3)/(7*pi^2)]

Input Arguments

collapse all

Base, specified as a number or a symbolic number, variable, expression, function, or square matrix. A and B must be one of the following:

  • Both are scalars.

  • A is a square matrix, and B is a scalar.

  • B is a square matrix, and A is a scalar.

Exponent, specified as a number or a symbolic number, variable, expression, function, or square matrix. A and B must be one of the following:

  • Both are scalars.

  • A is a square matrix, and B is a scalar.

  • B is a square matrix, and A is a scalar.

Introduced before R2006a