# inv() Function & Examples

Use the inv() matrix function in Calcul.io. Review its syntax, edit working examples, understand the result, and explore related math functions.

## inv

#### inv(x)

Try it yourself:

```calculio
inv([1, 2; 3, 4])
inv(4)
1 / 4
```

[concat](https://calcul.io/function/concat/index.md)

[det](https://calcul.io/function/det/index.md)

[diag](https://calcul.io/function/diag/index.md)

[identity](https://calcul.io/function/identity/index.md)

[ones](https://calcul.io/function/ones/index.md)

[range](https://calcul.io/function/range/index.md)

[size](https://calcul.io/function/size/index.md)

[squeeze](https://calcul.io/function/squeeze/index.md)

[subset](https://calcul.io/function/subset/index.md)

[trace](https://calcul.io/function/trace/index.md)

[transpose](https://calcul.io/function/transpose/index.md)

[zeros](https://calcul.io/function/zeros/index.md)

---

## inv(): invert a square matrix

**inv(A)** returns the inverse of a square matrix A when it exists. Multiplying A by its inverse yields the identity matrix, making inversion a way to solve matrix equations.

## Example and meaning

If `A × x = b`, then `x = inv(A) × b` when A is invertible. In practice, a linear solver is often more stable and efficient than explicitly forming an inverse.

## Related linear algebra

Check whether inversion is possible using [det()](https://calcul.io/function/det/index.md): a zero determinant means no inverse. Use [lsolve()](https://calcul.io/function/lsolve/index.md) for systems, [multiply()](https://calcul.io/function/multiply/index.md) to verify a result, and [transpose()](https://calcul.io/function/transpose/index.md) in related transformations. [identity()](https://calcul.io/function/identity/index.md) creates the target product.

## Important caveat

A must be square and non-singular. Nearly singular floating-point matrices can produce unreliable results; scale data and prefer a solver for numerical applications.

[All functions](https://calcul.io/functions/index.md)
