Problems with Q2 on Machine Learning Exam No 2


I am having issues with this question. I think I am able to solve it but cannot get the question to agree with me.

Here is my code:

import numpy as np



3x + z = 8

y - z - 2x = 3

z + 4x - y = 5


#Define A

A = np.array([[3, -2, 4], [0, 1, -1], [1, -1, 1]])

#Define b

b = np.array([8, 3, 5])

Calculate x,y,z

X = np.linalg.solve(A, b)

x = round(X[0])

y = round(X[1])

z = round(X[2])

Print x,y,z

print(x, y, z)

Can you tell me please what the question is expecting please?

Look at the example in the documentation: numpy.linalg.solve — NumPy v1.24 Manual

The example solves the system of equations:

Look at how the a and b arrays have been set up in the example (see linked page).

Compare this with how you have set up your A array.

Yes got it now. Thanks for the steer.


1 Like