# Linear solver

A is a square matrix n-by-n and `\vecu` a vector of dimension n.

**square matrix**, `\vecu`, a given vector and `\vecx`, the unknowns vector.

Any linear system with n

**linear**equations and n unknowns can be transformed into a linear solver that can be solved with this tool.

## What is the linear solver ?

This solver is used to solve a system of n linear equations and n unknowns which can be represented by in a matrix form.

Example of a system of 3 equations and 3 unknowns :

`x_1 + 2x_2 + 6x_3 = 5`

`-x_1 + 5x_2 + x_3 = 0`

`6x_1 -9x_2 + 4x_3 = -2`

This system can be rewritten in the following matrix form:

`[[1,2,6],[-1,5,1],[6,-9,4]] . [[x_1],[x_2],[x_3]] = [[5],[0],[-2]]`

We can write the correspondant linear solver as follows,

`A.\vec(x) = \vec(u)`

where,

`A= [[1,2,6],[-1,5,1],[6,-9,4]]`

`\vec(x)= [[x_1],[x_2],[x_3]]`

`\vec(u) = [[5],[0],[-2]]`

**How to solve a system of n equations and n unknowns **

One method is to write the system in a matrix form as described above i.e.,
`A.\vec(x) = \vec(u)`

A is a square matrix of order n.

`\vec(u)` is a vector of dimension n.

`\vec(x)` is a vector of dimension n considered of the unknown n of the system.

A single solution exists if and only if the A matrix is invertible and the solution can be written,

`\vec(x) = A^(-1) . \vec(u)`

With this method, solving a system of n equations and n unknowns implies to inverse a square matrix of size n.