Solution (source code)

= Solution

Apply the same permutation to the right-hand side and solve two <triangular systems>. <Forward substitution> in $Ly=Pb$ gives
$$
y_1=3,\qquad 2y_1+y_2=0,\qquad3y_1+y_3=-2,
$$
so $y=(3,-6,-11)^T$. <Back substitution> in $Ux=y$ gives $-11x_3=-11$, $4x_2-2x_3=-6$, and $3x_1+x_2+4x_3=3$. Therefore \b[$x=(0,-1,1)^T$]. Substitution in the original system returns $(3,-2,0)^T$, as required.