# Linear Algebra

## Systems of Linear Equations

 A linear equation in n variables $$x_1, \ldots , x_n$$ is an equation that can be written in the form  $a_1 x_1 + a_2 x_2 + a_3 x_3 + \ldots a_n x_n = b$ The numbers $$a_1, \ldots , a_n$$  are called the coefficients of the equations, and b is usually referred to as "the right-hand side" or the "constant term". The $$x_i$$ are the variables to be solved for.
 A set of m linear equations in the same variables $$x_1, \ldots , x_n$$  is called a system of m linear equations in n variables.

A general system of m linear equations in variables written in the form

\begin{align} a_{11} x_1 + a_{12} x_2 + \ldots a_{1n} x_n &= b_1 \\ a_{21} x_1 + a_{22} x_2 + \ldots a_{2n} x_n &= b_2 \\ &\vdots \\ a_{m1} x_1 + a_{m2} x_2 + \ldots a_{mn} x_n &= b_m \end{align}

 A vector $$\vec{s} = \begin{bmatrix} s_1 \\ \vdots \\ s_n \end{bmatrix} \in \mathbb{R}^n$$ is called a solution of a system of m linear equations in n variables if all m equations are satisfied when we set $$x_i = s_i$$ for $$1 \leq i \leq n$$. The set of all solutions of a system of linear equations is called the solution set of the system.
 If a system of linear equations has at least one solution, then it is said to be consistent. Otherwise, it is said to be inconsistent.

\begin{align} x_1 + 3x_2 - 4x_3 &= 1 \\ 2x_1 + 6x_2 - 8x_3 &= 2 \end{align}

does not have any solutions since the corresponding planes are parallel. Hence, the system is inconsistent.

## Solving Systems of Linear Equations

Let's find all solutions of the following system of linear equations

\begin{align} x_1 + x_2 - 2x_3 &= 4 \\ x_1 + 3x_2 - x_3 &= 7 \\ 2x_1 + x_2 - 5x_3 &= 7 \end{align}

Solution:

Add (-1) times the first equation to the second equation. The first and third equations are unchanged

\begin{align} x_1 + x_2 - 2x_3 &= 4 \\ 2x_2 + x_3 &= 3 \\ 2x_1 + x_2 - 5x_3 &= 7 \end{align}

Add (-2) times the first equation to the third equation.

\begin{align} x_1 + x_2 - 2x_3 &= 4 \\ 2x_2 + x_3 &= 3 \\ - x_2 - x_3 &= -1 \end{align}

Interchange the second and third equations.

\begin{align} x_1 + x_2 - 2x_3 &= 4 \\ - x_2 - x_3 &= -1 \\ 2x_2 + x_3 &= 3 \end{align}

Multiply the second equation by (-1).

\begin{align} x_1 + x_2 - 2x_3 &= 4 \\ x_2 + x_3 &= 1 \\ 2x_2 + x_3 &= 3 \end{align}

Add (-2) times the second equation to the third equation.

\begin{align} x_1 + x_2 - 2x_3 &= 4 \\ x_2 + x_3 &= 1 \\ - x_3 &= 1 \end{align}

We could continue but it is simpler to complete the solutions through back-substitution, since we know that $$x_3 = -1$$.

\begin{align} x_2 &= 1 - x_3 = 1 - (-1) = 2 \\ x_1 &= 4 - x_2 + 2x_3 = 4 - 2 + 2(-1) = 0 \end{align}

Thus, the only solution of this system is

$\begin{bmatrix} x_1 \\ x_2 \\ x_3 \end{bmatrix} = \begin{bmatrix} 0 \\ 2 \\ -1 \end{bmatrix}$

This solution checks out with the original equations.

\begin{align} 0 + 2 - 2(-1) = 4 \\ 0 + 3(2) - (-1) = 7 \\ 2(0) + 2 -5(-1) = 7 \end{align}

The solution process we just performed is what we call Gaussian Elimination with back-subsitution. It involved the elimination steps:

• Multiply one equation by a non-zero constant.
• Interchange two equations.
• Add a multiple of one equation to another equation.