Task 04

Task 04ΒΆ

deadline: 21/03/2021 23:59 CET

[0.25 points]: Edit the conjugate gradient method so that it returns a list of all iterations \( x^{(k)} \) (including the initial guess).

[0.25 points]: Solve the following system of linear equations

\[ 4 x_1 + x_2 = 1, \]
\[ x_1 + 3x_2 = 2 \]

using the edited conjugate gradient method withe the error tolerance of \( 10^{-15} \). Print the list of all iterations \( x^{(k)} \).

[0.5 points]: Plot the iterations \( x^{(k)} \) and the contours of the function

\[ f(x) = 1 \, / \, 2 \, x^T \mathbb{A} x - x^T b, \ x \in [-1, 1] \times [-1, 1], \]

where \( \mathbb{A} \) is the coefficient matrix and \( b \) is the right-hand side vector, using the matplotlib.pyplot.scatter and the matplotlib.pyplot.contour functions, respectively.

# add your code here