typo corrections

This commit is contained in:
Morten Hjorth-Jensen
2021-09-30 10:47:41 +02:00
parent 43877d18ff
commit 03084febf3
6 changed files with 32 additions and 20 deletions
+6 -4
View File
@@ -723,15 +723,15 @@ import matplotlib.pyplot as pt
from mpl_toolkits.mplot3d import axes3d
def f(x):
return 0.5*x[0]**2 + 2.5*x[1]**2
return x[0]**2 + 3.0*x[1]**2
def df(x):
return np.array([x[0], 5*x[1]])
return np.array([2*x[0], 6*x[1]])
fig = pt.figure()
ax = fig.gca(projection="3d")
xmesh, ymesh = np.mgrid[-2:2:50j,-2:2:50j]
xmesh, ymesh = np.mgrid[-3:3:50j,-3:3:50j]
fmesh = f(np.array([xmesh, ymesh]))
ax.plot_surface(xmesh, ymesh, fmesh)
!ec
@@ -764,6 +764,8 @@ it_array = np.array(guesses)
pt.plot(it_array.T[0], it_array.T[1], "x-")
!ec
Note that we did only one iteration here. We can easily add more using our previous guesses.
!split
===== Conjugate gradient method =====
!bblock
@@ -1081,7 +1083,7 @@ X = np.c_[np.ones((n,1)), x]
H = (2.0/n)* X.T @ X
# Get the eigenvalues
EigValues, EigVectors = np.linalg.eig(H)
print(EigValues)
print(f"Eigenvalues of Hessian Matrix:{EigValues}")
beta_linreg = np.linalg.inv(X.T @ X) @ X.T @ y
print(beta_linreg)