Finding x in Ax = B in matlab

207 Views Asked by At

I am trying to solve for $x$ in $Ax = B$ in matlab as well as attempting to understand the actual process behind solving a linear equation of said form. My vectors are A and B and they look like this

$ A = \left[\begin{matrix} 0 & -1 & 1 \\ 3 & 17 & -11 \\ 3 & 17 & -11 \\ 1 & 7 & -5 \end{matrix} \right] $

$ B = \left[\begin{matrix} -1 \\ 16 \\ 17 \\ 7 \end{matrix} \right] $

Now my reasoning is that $A$ is a matrix of size $4x3$ and $B$ is of form $4x1$, then $x$ must be of form $3x1$ because $A$ can only be multiplied with a vector with four rows and $B$ has only one column. The equation turns plays out like this $$ Ax = \left[\begin{matrix} 0 & -1 & 1 \\ 3 & 17 & -11 \\ 3 & 17 & -11 \\ 1 & 7 & -5 \end{matrix} \right] \times \left[\begin{matrix}x \\ y \\ z\end{matrix} \right] = \left[\begin{matrix}-y + z \\ 3x +17y -11z \\ 3x + 17y -11z \\ x + 7y -5z \end{matrix} \right] = \left[\begin{matrix} -1 \\ 16 \\ 17 \\ 7 \end{matrix} \right] $$

that means that we have four equations and three unknowns. Equation two and three contradict each other (resulting in 0 = 1 from equation 3 when -1*equation 2 + equation 3). Therefore the equation is unsolvable.

$$ -y + z = -1 \\ 3x +17y -11z = 16\\ 3x +17y -11z = 17\\ x + 7y -5z = 7\\ $$

Matlab, however says that B\A = x, and $$x = 0.1782, 1.026, -0.6706$$ I got this way of solving the equation from mathworks. Where am I going wrong? Is the equation $Ax = B$ in my case solvable?