# solve a system of equations by matrices

Is there any way to solve the system of linear equations by matrices ??

for example:

\left\{\begin{aligned} 2x+3y-z&=p \\ px+(p+1)y-pz&=1 \\ x+y+pz&=2 \end{aligned} \right.

Thank you :)

You can write this system as a matrix (assuming $p$ is known - if not, it will not be a system of linear equations):
$$\underbrace{\begin{bmatrix}2 & 3 & -1 \\ p & p+1 & -p \\ 1 & 1 & p \end{bmatrix}}_A \underbrace{\begin{bmatrix}x \\ y \\ z \end{bmatrix}}_v = \underbrace{\begin{bmatrix}p \\ 1 \\ 2\end{bmatrix}}_b$$
So the solution is $$v = A^{-1} b,$$ so all you have to do is invert $A$ and multipy it (the inverse of $A$) with $b$ in order to get $v$. This can be done easiest via Gauss algorithm if you have to do it by hand with no other means.
• Here is a warning if you follow flawr's answer (it's a good answer by the way, except for one small problem). It is possible that the matrix $A$ is singular. Note that $$\det(A)=-p^2+p+1\,,$$ so $\det(A)=0$ for $p=\frac{1\pm\sqrt{5}}{2}$. – Batominovski Jul 10 '18 at 17:46