You are on page 1of 2

MA111 Lab Sheet 1 Examples

Question 1 a
Plot[{- 2 x + 4, x - 2}, {x, - 2, 6}, AxesStyle → Arrowheads[0.05], PlotStyle → {Blue, Red},
PlotPoints → 100, AxesLabel → {x, y}, PlotLegends → {"2x+y=4", "x-y=2"}]
y

2x+y=4

-2 2 4
x x-y=2

-5

Solve[{2 x - y ⩵ 4, x - y ⩵ 2}, {x, y}]


{{x → 2, y → 0}}

Question 2 c
ClearAll[x, y, z]

Solve[{x + y + z ⩵ 0, x + 2 y + 3 z ⩵ 1, x - y + z ⩵ 2}, {x, y, z}]


{{x → 0, y → - 1, z → 1}}

Question 3 c)
ClearAll[A, B]

GaussianElimination[m_List ? MatrixQ, v_List ? VectorQ] :=


Last /@ RowReduce[Flatten /@ Transpose[{m, v}]]

A = {{0, 2, 1}, {1, - 2, - 3}, {- 1, 1, 2}};


B = {- 8, 0, 3};
MatrixForm[A]
MatrixForm[B]
GaussianElimination[A, B]
0 2 1
1 -2 -3
-1 1 2
-8
0
3
{- 4, - 5, 2}
2 MA111 week 2 lab.nb

RowReduce[{{0, 2, 1, - 8}, {1, - 2, - 3, 0}, {- 1, 1, 2, 3}}]


MatrixForm[%]
{{1, 0, 0, - 4}, {0, 1, 0, - 5}, {0, 0, 1, 2}}

1 0 0 -4
0 1 0 -5
0 0 1 2

You might also like