# start Steepest descent
IterMax = 30
tolerance = 1.0e-14
# start simple gradient descent with random guess again
x = np.random.randn(2,1)
# The residual
r = A @ x-b.T
i = 0
# a more intelligent iterative process
while (i <= IterMax):
z = A @ r
c = r.T @ r
deno = r.T @ z
alpha = c/deno
x -= alpha*r
r = (A @ x)-b.T;
if(np.sqrt(r.T @ r) < tolerance):
break
i += 1
print("Absolute error for Steepest descent solution",np.abs(x-exact))