Accelerating the pace of engineering and science

# pinv

Moore-Penrose inverse (pseudoinverse) of symbolic matrix

X = pinv(A)

## Description

X = pinv(A) returns the pseudoinverse of A. Pseudoinverse is also called the Moore-Penrose inverse.

## Input Arguments

 A Symbolic m-by-n matrix.

## Output Arguments

 X Symbolic n-by-m matrix, such that A*X*A = A and X*A*X = X.

## Examples

Compute the pseudoinverse of this matrix. Because these numbers are not symbolic objects, you get floating-point results.

```A = [1 1i 3; 1 3 2];
X = pinv(A)```
```X =
0.0729 + 0.0312i   0.0417 - 0.0312i
-0.2187 - 0.0521i   0.3125 + 0.0729i
0.2917 + 0.0625i   0.0104 - 0.0937i```

Now, convert this matrix to a symbolic object, and compute the pseudoinverse:

```A = sym([1 1i 3; 1 3 2]);
X = pinv(A)```
```X =
[       7/96 + i/32,     1/24 - i/32]
[ - 7/32 - (5*i)/96, 5/16 + (7*i)/96]
[       7/24 + i/16, 1/96 - (3*i)/32]```

Check that A*X*A = A and X*A*X = X:

`logical(A*X*A == A)`
```ans =
1     1     1
1     1     1```
`logical(X*A*X == X)`
```ans =
1     1
1     1
1     1```

Now, verify that A*X and X*A are Hermitian matrices:

`logical(A*X == (A*X)')`
```ans =
1     1
1     1```
`logical(X*A == (X*A)')`
```ans =
1     1     1
1     1     1
1     1     1```

Compute the pseudoinverse of this matrix:

```syms a
A = [1 a; -a 1];
X = pinv(A)```
```X =
[ (a*conj(a) + 1)/(a^2*conj(a)^2 + a^2 + conj(a)^2 + 1) -...
(conj(a)*(a - conj(a)))/(a^2*conj(a)^2 + a^2 + conj(a)^2 + 1),
- (a - conj(a))/(a^2*conj(a)^2 + a^2 + conj(a)^2 + 1) -...
(conj(a)*(a*conj(a) + 1))/(a^2*conj(a)^2 + a^2 + conj(a)^2 + 1)]
[ (a - conj(a))/(a^2*conj(a)^2 + a^2 + conj(a)^2 + 1) +...
(conj(a)*(a*conj(a) + 1))/(a^2*conj(a)^2 + a^2 + conj(a)^2 + 1),
(a*conj(a) + 1)/(a^2*conj(a)^2 + a^2 + conj(a)^2 + 1) -...
(conj(a)*(a - conj(a)))/(a^2*conj(a)^2 + a^2 + conj(a)^2 + 1)]```

Now, compute the pseudoinverse of A assuming that a is real:

```assume(a,'real')
A = [1 a; -a 1];
X = pinv(A)```
```X =
[ 1/(a^2 + 1), -a/(a^2 + 1)]
[ a/(a^2 + 1),  1/(a^2 + 1)]```

For further computations, remove the assumption:

`syms a clear`

expand all

### Moore-Penrose Pseudoinverse

The pseudoinverse of an m-by-n matrix A is an n-by-m matrix X, such that A*X*A = A and X*A*X = X. The matrices A*X and X*A must be Hermitian.

### Tips

• Calling pinv for numeric arguments that are not symbolic objects invokes the MATLAB® pinv function.

• For an invertible matrix A, the Moore-Penrose inverse X of A coincides with the inverse of A.