Given the A **linear equation** is an equation with variables $ x_1,\ldots,x_n $ (commonly $ x,y $ with two variables and $ x,y,z $ with three) that can be written in the form

- $ a_1x_1+\cdots+a_nx_n=b $

where $ b $ and $ a_1,\ldots,a_n $ are real or complex numbers which are usually known beforehand.

A **system of linear equations** is a collection of linear equations using the same variables. For example, the equations

- $ \begin{align}&3x_1+5x_2=9\\&2x_3-9x_4=10\end{align} $

are not a system of linear equations because the two equations do not share any variables, whereas adding the equation

- $ 8x_2+2x_3=0 $

makes the collection a system of equation because variables are shared between equations.

A **solution** to a system of linear equations is a list of values $ s_1,\ldots,s_n $ that can be exchanged with the variables $ x_1,\ldots,x_n $ such that every equation becomes true. A system of linear equations may have no solution, exactly one solution, or infinitely many solutions.

## Solving systems of equations

When solving a system of equations, there are several ways to go about solving it.

### Matrix Notation

For a given system of equations, each equation can be written as a row in a matrix. For a *coefficient matrix*, each of the coefficients is written in aligned columns. For example, the system

- $ \begin{align}&2x_2-8x_3=8\\&x_1-2x_2+x_3=0\\&-4x_1+5x_2+9x_3=-9\end{align} $

would be written as the coefficient matrix

- $ \begin{bmatrix}0&2&-8\\1&-2&3\\-4&5&9\end{bmatrix} $

An *augmented matrix* shows the coefficient matrix with an additional column for the values of $ b $ . The augmented matrix for the above system is

- $ \begin{bmatrix}0&2&-8&8\\1&-2&1&0\\-4&5&9&-9\end{bmatrix} $

The goal of solving by a matrix is to produce a matrix of the form

- $ \begin{bmatrix} 1&0&\cdots&0&s_1\\0&1&\cdots&0&s_2\\ \vdots&\vdots&\ddots&\vdots&\vdots\\ 0&0&\cdots&1&s_n\end{bmatrix} $

so that each variable is paired with a solution value. This is known as reduced row-echelon form. The matrix can be put into this form by the use of *elementary row operations*. Matrices are said to be *row-equivalent* if one matrix may be transformed into the other using only elementary row operations. The three elementary row operations are:

- Replacement - replacing one row by a sum of itself and a multiple of another row.
- Interchange - exchange two rows
- Scaling - multiply a row by a non-zero constant.

The standard way, also known as the Gauss-Jordon Elimination Method, of solving using row operations is to work from left to right and attempt to make the value in the appropriate row (for example, the first row in the first column) equal to 1, then bring all the other values to 0. This has the advantage of never undoing work previously done. To solve the augmented matrix:

- $ \begin{bmatrix}0&2&-8&8\\1&-2&1&0\\-4&5&9&-9\end{bmatrix} $

Interchange the first and second rows to get 1 in $ A_{1,1} $

- $ \begin{bmatrix}1&-2&1&0\\0&2&-8&8\\-4&5&9&-9\end{bmatrix} $

Replace $ R_3 $ with $ R_3+4R_1 $

- $ \begin{bmatrix}1&-2&1&0\\0&2&-8&8\\0&-3&13&-9\end{bmatrix} $

Scale $ R_2 $ by $ \frac12 $

- $ \begin{bmatrix}1&-2&1&0\\0&1&-4&4\\0&-3&13&-9\end{bmatrix} $

Replace $ R_1 $ with $ R_1+2R_2 $

- $ \begin{bmatrix}1&0&-7&8\\0&1&-4&4\\0&-3&13&-9\end{bmatrix} $

Replace $ R_3 $ with $ R_3+3R_2 $

- $ \begin{bmatrix}1&0&-7&8\\0&1&-4&4\\0&0&1&3\end{bmatrix} $

Replace $ R_1 $ with $ R_1+7R_3 $

- $ \begin{bmatrix}1&0&0&29\\0&1&-4&4\\0&0&1&3\end{bmatrix} $

Replace $ R_2 $ with $ R_2+4R_3 $

- $ \begin{bmatrix}1&0&0&29\\0&1&0&16\\0&0&1&3\end{bmatrix} $

Thus, the solution to the system is (29, 16, 3).

Another way is Cramer's rule, which states that in a system of linear equations, x_{n} = D_{xn}/D, Where D is the determinant of the coefficient matrix and D_{xn} is the coefficient determinant with the coefficients of x_{n} replaced with the constants on the right of the equations. However, this only works in a square matrix, and each equation must be in the form ax_{1}+ax_{2}+...=C.