# inverse

Inverse of a matrix

### Use only in the MuPAD Notebook Interface.

This functionality does not run in MATLAB.

## Syntax

```inverse(`A`, <Normal>)
```

## Description

`inverse(A)` returns the inverse of the matrix A.

If the input is a matrix A of category `Cat::Matrix`, then `A^(-1)` is called to compute the result. In contrast to the overloaded arithmetics, the function `inverse` also operates on `array`s and `hfarray`s.

If the input matrix is an `array` of domain type `DOM_ARRAY`, then `numeric::inverse(A, Symbolic)` is called to compute the result.

The inverse of `hfarray`s of domain type `DOM_HFARRAY` is internally computed via `numeric::inverse(A)`.

If the argument does not evaluate to a matrix of one of the types mentioned above, a symbolic call `inverse(A)` is returned.

By default, `inverse` calls `normal` before returning results. This additional internal call ensures that the final result is normalized. This call can be computationally expensive. It also affects the result returned by `inverse` only if a matrix contains variables or exact expressions, such as `sqrt(5)` or `sin(PI/7)`.

To avoid this additional call, specify `Normal = FALSE`. In this case, `inverse` also can return normalized results, but does not guarantee such normalization. See Example 4.

## Examples

### Example 1

Compute the inverse of a matrix given by various data types:

```A := array(1..2, 1..2, [[1, 2], [3, PI]]); inverse(A)```

```B := hfarray(1..2, 1..2, [[1, 2], [3, PI]]); inverse(B)```

```C := matrix(2, 2, [[1, 2], [3, PI]]); inverse(C)```

`delete A, B, C:`

### Example 2

The following matrix is not invertible:

`inverse(matrix([[1, 2], [3, 6]]))`

### Example 3

If the input does not evaluate to a matrix, then symbolic calls are returned:

```delete A, B: inverse(A + 2*B)```

### Example 4

Using `Normal` can significantly decrease the performance of `inverse`. For example, computing the inverse of this matrix takes a long time:

```n := 5: inv5 := inverse(matrix(n, n, [[1/(x[i] + x[j]) \$ j = 1..n] \$ i = 1..n])):```

For better performance, specify `Normal = FALSE`:

```n := 5: inv5 := inverse(matrix(n, n, [[1/(x[i] + x[j]) \$ j = 1..n] \$ i = 1..n]), Normal = FALSE):```

## Parameters

 `A` Square matrix: either a two-dimensional `array`, a two-dimensional `hfarray`, or an object of the category `Cat::Matrix`

## Options

 `Normal` Option, specified as `Normal = b` Return normalized results. The value `b` must be `TRUE` or `FALSE`. By default, `Normal = TRUE`, meaning that `inverse` guarantees normalization of the returned results. Normalizing results can be computationally expensive.

## Return Values

The inverse is returned as a matrix of the same type as the input matrix. If the matrix is not invertible, then `FAIL` is returned. If the input does not evaluate to a matrix, then a symbolic call of `inverse` is returned.

`A`