diff --git a/doc/pub/week39/html/week39-reveal.html b/doc/pub/week39/html/week39-reveal.html index a802dee73..6a4b2f801 100644 --- a/doc/pub/week39/html/week39-reveal.html +++ b/doc/pub/week39/html/week39-reveal.html @@ -1028,15 +1028,15 @@ $$ 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) @@ -1080,6 +1080,8 @@ pt.contour(xmesh, ymesh, fmesh, 50) it_array = np.array(guesses) pt.plot(it_array.T[0], it_array.T[1], "x-") +
+Note that we did only one iteration here. We can easily add more using our previous guesses. @@ -1502,7 +1504,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) diff --git a/doc/pub/week39/html/week39-solarized.html b/doc/pub/week39/html/week39-solarized.html index 7d4f92047..2b2180abc 100644 --- a/doc/pub/week39/html/week39-solarized.html +++ b/doc/pub/week39/html/week39-solarized.html @@ -1057,15 +1057,15 @@ $$ 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) @@ -1109,6 +1109,9 @@ pt.contour(xmesh, ymesh, fmesh, 50) it_array = np.array(guesses) pt.plot(it_array.T[0], it_array.T[1], "x-") +
+Note that we did only one iteration here. We can easily add more using our previous guesses. +
@@ -1489,7 +1492,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)
diff --git a/doc/pub/week39/html/week39.html b/doc/pub/week39/html/week39.html
index 7040e016f..faaccd860 100644
--- a/doc/pub/week39/html/week39.html
+++ b/doc/pub/week39/html/week39.html
@@ -1062,15 +1062,15 @@ $$
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)
@@ -1114,6 +1114,9 @@ pt.contour(xmesh, ymesh, fmesh, = np.array(guesses)
pt.plot(it_array.T[0], it_array.T[1], "x-")
+
+Note that we did only one iteration here. We can easily add more using our previous guesses. +
@@ -1494,7 +1497,7 @@ X = np.c
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)
diff --git a/doc/pub/week39/ipynb/ipynb-week39-src.tar.gz b/doc/pub/week39/ipynb/ipynb-week39-src.tar.gz
index 428b7dd95..a241d058b 100644
Binary files a/doc/pub/week39/ipynb/ipynb-week39-src.tar.gz and b/doc/pub/week39/ipynb/ipynb-week39-src.tar.gz differ
diff --git a/doc/pub/week39/ipynb/week39.ipynb b/doc/pub/week39/ipynb/week39.ipynb
index 0da13db9a..f65ca3d3c 100644
--- a/doc/pub/week39/ipynb/week39.ipynb
+++ b/doc/pub/week39/ipynb/week39.ipynb
@@ -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",
diff --git a/doc/src/week39/week39.do.txt b/doc/src/week39/week39.do.txt
index 4cf3be9fa..44b43ce15 100644
--- a/doc/src/week39/week39.do.txt
+++ b/doc/src/week39/week39.do.txt
@@ -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)