# General solution for system of linear equations

Regarding the first general solution (λ1), there is no problem, but what were the steps to obtain the second general solution (λ2) in the following problem:

$$\begin{eqnarray} x_1 - 2x_2 + x_3 - x_4 + x_5 = 0 \\ x_3 -x_4 + 3x_5 = -2 \\ x_4 - 2x_5 = 1 \\ 0 = a + 1 \end{eqnarray}$$

Only for a = −1 this system can be solved. A particular solution is

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

The general solution, which captures the set of all possible solutions, is

$$\left\{ x \in \mathbb{R}^5: \begin{bmatrix} 2 \\ 0 \\ -1 \\ 1\\ 0 \end{bmatrix} + \lambda_1 \begin{bmatrix} 2 \\ 1 \\ 0 \\ 0 \\0 \end{bmatrix} + \lambda_2 \begin{bmatrix} 2 \\ 0 \\ -1 \\ 2 \\ 0 \end{bmatrix} , \lambda_1, \lambda_2 \in \mathbb{R} \right\}$$

Reference: 'Mathematics for Machine Learning' Marc Peter Deisenroth, A. Aldo Faisal, Cheng Soon Ong

There are 5 unknowns in your system of equations. But you have got only 3 useful equations to solve it. Therefore, you have to let 2 of the unknowns have some arbitrary values, such as $$\lambda_1$$ and $$\lambda_2 \in \mathbb{R}$$.
According to the solution you have posted, someone has assigned that $$x_2=\lambda_1$$ and $$x_5=\lambda_2$$. Now, your system of equations, which is already in echelon form, looks like, $$\begin{eqnarray} x_1 + x_3 - x_4 = 2\lambda_1 - \lambda_2 \\ x_3 -x_4 = -2 - 3\lambda_2 \\ x_4 = 1 + 2\lambda_2 \\ 0 = a + 1 \end{eqnarray}$$
The solution of this system is, $$\begin{bmatrix} x_1 \\ x_2 \\ x_3 \\ x_4 \\ x_5 \end{bmatrix} = \begin{bmatrix} 2 + 2\lambda_1 + 2\lambda_2 \\ \lambda_1 \\ -1 - \lambda_2 \\ 1 + 2\lambda_2 \\ \lambda_2 \end{bmatrix}.$$
Therefore, the general solution of the original system of equations should be, $$\left\{ x \in \mathbb{R}^5: \begin{bmatrix} 2 \\ 0 \\ -1 \\ 1\\ 0 \end{bmatrix} + \lambda_1 \begin{bmatrix} 2 \\ 1 \\ 0 \\ 0 \\0 \end{bmatrix} + \lambda_2 \begin{bmatrix} 2 \\ 0 \\ -1 \\ 2 \\ \mathbf{\color{red}{1}} \end{bmatrix} , \lambda_1, \lambda_2 \in \mathbb{R} \right\}$$