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
Binary file not shown.
+6 -4
View File
@@ -1031,15 +1031,15 @@
"from mpl_toolkits.mplot3d import axes3d\n",
"\n",
"def f(x):\n",
" return 0.5*x[0]**2 + 2.5*x[1]**2\n",
" return x[0]**2 + 3.0*x[1]**2\n",
"\n",
"def df(x):\n",
" return np.array([x[0], 5*x[1]])\n",
" return np.array([2*x[0], 6*x[1]])\n",
"\n",
"fig = pt.figure()\n",
"ax = fig.gca(projection=\"3d\")\n",
"\n",
"xmesh, ymesh = np.mgrid[-2:2:50j,-2:2:50j]\n",
"xmesh, ymesh = np.mgrid[-3:3:50j,-3:3:50j]\n",
"fmesh = f(np.array([xmesh, ymesh]))\n",
"ax.plot_surface(xmesh, ymesh, fmesh)"
]
@@ -1136,6 +1136,8 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"Note that we did only one iteration here. We can easily add more using our previous guesses.\n",
"\n",
"## Conjugate gradient method\n",
"In the CG method we define so-called conjugate directions and two vectors \n",
"$\\boldsymbol{s}$ and $\\boldsymbol{t}$\n",
@@ -1695,7 +1697,7 @@
"H = (2.0/n)* X.T @ X\n",
"# Get the eigenvalues\n",
"EigValues, EigVectors = np.linalg.eig(H)\n",
"print(EigValues)\n",
"print(f\"Eigenvalues of Hessian Matrix:{EigValues}\")\n",
"\n",
"beta_linreg = np.linalg.inv(X.T @ X) @ X.T @ y\n",
"print(beta_linreg)\n",