diff --git a/HW3/README.md b/HW3/README.md
index 494e0d5..45214a4 100644
--- a/HW3/README.md
+++ b/HW3/README.md
@@ -11,8 +11,8 @@
c. Copy your `projectile.m` function into the 'roots_and_optimization' folder.
*Disable the plotting routine for the solvers*
- d. Use the four solvers `falsepos.m`, `incsearch.m`, `newtraph.m` and `mod_secant.m`
- to solve for the angle needed to reach h=1.72 m, with an initial speed of 1.5 m/s.
+ d. Use the four solvers `falsepos.m`, `bisect.m`, `newtraph.m` and `mod_secant.m`
+ to solve for the angle needed to reach h=1.72 m, with an initial speed of 15 m/s.
e. The `newtraph.m` function needs a derivative, calculate the derivative of your
function with respect to theta, `dprojectile_dtheta.m`. This function should
@@ -29,7 +29,7 @@
| solver | initial guess(es) | ea | number of iterations|
| --- | --- | --- | --- |
|falsepos | | | |
- |incsearch | | | |
+ |bisect | | | |
|newtraph | | | |
|mod_secant | | | |
```
@@ -49,7 +49,7 @@ using the numerical solvers, `newtraph.m` and `mod_secant.m`, there are certain
guesses that do not converge.
a. Calculate the first 5 iterations for the Newton-Raphson method with an initial
- guess of x_i=2.
+ guess of x_i=2 for f(x)=x*exp(-x^2).
b. Add the results to a table in the `README.md` with:
@@ -70,5 +70,4 @@ guesses that do not converge.
'divergence' to 'convergence')
3. Commit your changes to your repository. Sync your local repository with github. Then
-copy and paste the "clone URL" into the following Google Form [Homework
-#3](https://goo.gl/forms/UJBGwp0fQcSxImkq2)
+copy and paste the "clone URL" into the following Google Form [Homework 3](https://goo.gl/forms/UJBGwp0fQcSxImkq2)
diff --git a/lecture_07/.lecture_07.md.swo b/lecture_07/.lecture_07.md.swo
new file mode 100644
index 0000000..244c92b
Binary files /dev/null and b/lecture_07/.lecture_07.md.swo differ
diff --git a/lecture_07/.lecture_07.md.swp b/lecture_07/.lecture_07.md.swp
new file mode 100644
index 0000000..0998c86
Binary files /dev/null and b/lecture_07/.lecture_07.md.swp differ
diff --git a/lecture_08/.ipynb_checkpoints/lecture_08-checkpoint.ipynb b/lecture_08/.ipynb_checkpoints/lecture_08-checkpoint.ipynb
new file mode 100644
index 0000000..2fd6442
--- /dev/null
+++ b/lecture_08/.ipynb_checkpoints/lecture_08-checkpoint.ipynb
@@ -0,0 +1,6 @@
+{
+ "cells": [],
+ "metadata": {},
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/lecture_08/Auchain_model.gif b/lecture_08/Auchain_model.gif
new file mode 100644
index 0000000..2f8c78c
Binary files /dev/null and b/lecture_08/Auchain_model.gif differ
diff --git a/lecture_08/au_chain.jpg b/lecture_08/au_chain.jpg
new file mode 100644
index 0000000..492fee8
Binary files /dev/null and b/lecture_08/au_chain.jpg differ
diff --git a/lecture_08/goldenratio.png b/lecture_08/goldenratio.png
new file mode 100644
index 0000000..9493c8c
Binary files /dev/null and b/lecture_08/goldenratio.png differ
diff --git a/lecture_08/lecture_08.ipynb b/lecture_08/lecture_08.ipynb
new file mode 100644
index 0000000..134ed8a
--- /dev/null
+++ b/lecture_08/lecture_08.ipynb
@@ -0,0 +1,1941 @@
+{
+ "cells": [
+ {
+ "cell_type": "code",
+ "execution_count": 2,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [],
+ "source": [
+ "%plot --format svg"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "# Optimization\n",
+ "\n",
+ "Many problems involve finding a minimum or maximum based on given constraints. Engineers and scientists typically use energy balance equations to find the conditions of minimum energy, but this value may never go to 0 and the actual value of energy may not be of interest. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "The Lennard-Jones potential is commonly used to model interatomic bonding. \n",
+ "\n",
+ "$E_{LJ}(x)=4\\epsilon \\left(\\left(\\frac{\\sigma}{x}\\right)^{12}-\\left(\\frac{\\sigma}{x}\\right)^{6}\\right)$\n",
+ "\n",
+ "Considering a 1-D gold chain, we can calculate the bond length, $x_{b}$, with no force applied to the chain and even for tension, F. This will allow us to calculate the nonlinear spring constant of a 1-D gold chain. \n",
+ "\n",
+ "![TEM image of Gold chain](au_chain.jpg)\n",
+ "\n",
+ "Computational Tools to Study and Predict the Long-Term Stability of Nanowires.\n",
+ "By Martin E. Zoloff Michoff, Patricio VĂ©lez, Sergio A. Dassie and Ezequiel P. M. Leiva \n",
+ "\n",
+ "![Model of Gold chain, from molecular dynamics simulation](Auchain_model.gif)\n",
+ "\n",
+ "[Single atom gold chain mechanics](http://www.uam.es/personal_pdi/ciencias/agrait/)\n",
+ "\n",
+ "### First, let's find the minimum energy $\\min(E_{LJ}(x))$\n",
+ "\n",
+ "## Brute force"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 3,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "data": {
+ "image/svg+xml": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "setdefaults\n",
+ "epsilon = 0.039; % kcal/mol\n",
+ "sigma = 2.934; % Angstrom\n",
+ "x=linspace(2.8,6,200); % bond length in Angstrom\n",
+ "\n",
+ "Ex = lennard_jones(x,sigma,epsilon);\n",
+ "\n",
+ "[Emin,imin]=min(Ex);\n",
+ "\n",
+ "plot(x,Ex,x(imin),Emin,'o')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 4,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "ans = 3.2824\n",
+ "ans = 3.2985\n",
+ "ans = 3.3146\n"
+ ]
+ }
+ ],
+ "source": [
+ "x(imin-1)\n",
+ "x(imin)\n",
+ "x(imin+1)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Golden Search Algorithm\n",
+ "\n",
+ "We can't just look for a sign change for the problem (unless we can take a derivative) so we need a new approach to determine whether we have a maximum between the two bounds.\n",
+ "\n",
+ "Rather than using the midpoint of initial bounds, here the problem is more difficult. We need to compare the values of 4 function evaluations. The golden search uses the golden ratio to determine two interior points. \n",
+ "\n",
+ "![golden ratio](goldenratio.png)\n",
+ "\n",
+ "Start with bounds of 2.5 and 6 Angstrom. "
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 5,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "current_min = -0.019959\r\n"
+ ]
+ },
+ {
+ "data": {
+ "image/svg+xml": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "% define Au atomic potential\n",
+ "epsilon = 0.039; % kcal/mol\n",
+ "sigma = 2.934; % Angstrom\n",
+ "Au_x= @(x) lennard_jones(x,sigma,epsilon);\n",
+ "\n",
+ "% calculate golden ratio\n",
+ "phi = 1/2+sqrt(5)/2;\n",
+ "% set initial limits\n",
+ "x_l=2.8; \n",
+ "x_u=6; \n",
+ "\n",
+ "% Iteration #1\n",
+ "d=(phi-1)*(x_u-x_l);\n",
+ "\n",
+ "x1=x_l+d; % define point 1\n",
+ "x2=x_u-d; % define point 2\n",
+ "\n",
+ "\n",
+ "% evaluate Au_x(x1) and Au_x(x2)\n",
+ "\n",
+ "f1=Au_x(x1);\n",
+ "f2=Au_x(x2);\n",
+ "plot(x,Au_x(x),x_l,Au_x(x_l),'ro',x2,f2,'rs',x1,f1,'gs',x_u,Au_x(x_u),'go')\n",
+ "hold on;\n",
+ "\n",
+ "if f2\n",
+ "\n",
+ "Gnuplot\n",
+ "Produced by GNUPLOT 5.0 patchlevel 3 \n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\t\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t-0.04\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t-0.02\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.02\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.04\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.06\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.08\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t2.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t3\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t3.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t4\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t4.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t5.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t6\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\tgnuplot_plot_1a\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_2a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_3a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_4a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_5a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_6a\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "% Iteration #2\n",
+ "d=(phi-1)*(x_u-x_l);\n",
+ "\n",
+ "x1=x_l+d; % define point 1\n",
+ "x2=x_u-d; % define point 2\n",
+ "\n",
+ "% evaluate Au_x(x1) and Au_x(x2)\n",
+ "\n",
+ "f1=Au_x(x1);\n",
+ "f2=Au_x(x2);\n",
+ "plot(x,Au_x(x),x_l,Au_x(x_l),'ro',x2,f2,'rs',x1,f1,'gs',x_u,Au_x(x_u),'go')\n",
+ "hold on;\n",
+ "\n",
+ "if f2\n",
+ "\n",
+ "Gnuplot\n",
+ "Produced by GNUPLOT 5.0 patchlevel 3 \n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t \n",
+ "\t \n",
+ "\t\n",
+ "\t\n",
+ "\t \n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\t\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t-0.04\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t-0.02\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.02\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.04\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.06\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.08\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t2.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t3\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t3.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t4\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t4.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t5.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t6\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\tgnuplot_plot_1a\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_2a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_3a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_4a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_5a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_6a\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "% Iteration #3\n",
+ "d=(phi-1)*(x_u-x_l);\n",
+ "\n",
+ "x1=x_l+d; % define point 1\n",
+ "x2=x_u-d; % define point 2\n",
+ "\n",
+ "% evaluate Au_x(x1) and Au_x(x2)\n",
+ "\n",
+ "f1=Au_x(x1);\n",
+ "f2=Au_x(x2);\n",
+ "plot(x,Au_x(x),x_l,Au_x(x_l),'ro',x2,f2,'rs',x1,f1,'gs',x_u,Au_x(x_u),'go')\n",
+ "hold on;\n",
+ "\n",
+ "if f2\n",
+ "\n",
+ "Gnuplot\n",
+ "Produced by GNUPLOT 5.0 patchlevel 3 \n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t \n",
+ "\t \n",
+ "\t\n",
+ "\t\n",
+ "\t \n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\t\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t-0.04\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t-0.02\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.02\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.04\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.06\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.08\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t2.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t3\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t3.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t4\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t4.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t5.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t6\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\tgnuplot_plot_1a\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_2a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_3a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_4a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_5a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_6a\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "% Iteration #3\n",
+ "d=(phi-1)*(x_u-x_l);\n",
+ "\n",
+ "x1=x_l+d; % define point 1\n",
+ "x2=x_u-d; % define point 2\n",
+ "\n",
+ "% evaluate Au_x(x1) and Au_x(x2)\n",
+ "\n",
+ "f1=Au_x(x1);\n",
+ "f2=Au_x(x2);\n",
+ "plot(x,Au_x(x),x_l,Au_x(x_l),'ro',x2,f2,'rs',x1,f1,'gs',x_u,Au_x(x_u),'go')\n",
+ "hold on;\n",
+ "\n",
+ "if f2\n",
+ "\n",
+ "Gnuplot\n",
+ "Produced by GNUPLOT 5.0 patchlevel 3 \n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\t \n",
+ "\t \n",
+ "\t\n",
+ "\t\n",
+ "\t \n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\t\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t-0.06\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t-0.04\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t-0.02\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.02\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.04\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.06\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t0.08\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t2.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t3\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t3.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t4\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t4.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t5.5\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\t\t\n",
+ "\t\t6\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\tgnuplot_plot_1a\n",
+ "\n",
+ "\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_2a\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\tgnuplot_plot_3a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\t\n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_4a\n",
+ "\n",
+ "\t \n",
+ "\t\n",
+ "\n",
+ "\t\n",
+ "\tgnuplot_plot_5a\n",
+ "\n",
+ "\t\n",
+ "\t\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ "\n",
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "% define Au atomic potential\n",
+ "epsilon = 0.039; % kcal/mol\n",
+ "sigma = 2.934; % Angstrom\n",
+ "Au_x= @(x) lennard_jones(x,sigma,epsilon);\n",
+ "\n",
+ "% set initial limits\n",
+ "x_l=2.8; \n",
+ "x_u=3.5; \n",
+ "\n",
+ "% Iteration #1\n",
+ "x1=x_l;\n",
+ "x2=mean([x_l,x_u]);\n",
+ "x3=x_u;\n",
+ "\n",
+ "% evaluate Au_x(x1), Au_x(x2) and Au_x(x3)\n",
+ " \n",
+ "f1=Au_x(x1);\n",
+ "f2=Au_x(x2);\n",
+ "f3=Au_x(x3);\n",
+ "p = polyfit([x1,x2,x3],[f1,f2,f3],2);\n",
+ "x_fit = linspace(x1,x3,20);\n",
+ "y_fit = polyval(p,x_fit);\n",
+ "\n",
+ "plot(x,Au_x(x),x_fit,y_fit,[x1,x2,x3],[f1,f2,f3],'o')\n",
+ "hold on\n",
+ "if f2x2\n",
+ " plot(x4,f4,'*',[x1,x2],[f1,f2])\n",
+ " x1=x2;\n",
+ " f1=f2;\n",
+ " else\n",
+ " plot(x4,f4,'*',[x3,x2],[f3,f2])\n",
+ " x3=x2;\n",
+ " f3=f2;\n",
+ " end\n",
+ " x2=x4; f2=f4;\n",
+ "else\n",
+ " error('no minimum in bracket')\n",
+ "end\n",
+ "hold off"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 32,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "f3 = -0.038878\r\n"
+ ]
+ },
+ {
+ "data": {
+ "image/svg+xml": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "p = polyfit([x1,x2,x3],[f1,f2,f3],2);\n",
+ "x_fit = linspace(x1,x3,20);\n",
+ "y_fit = polyval(p,x_fit);\n",
+ "\n",
+ "plot(x,Au_x(x),x_fit,y_fit,[x1,x2,x3],[f1,f2,f3],'o')\n",
+ "hold on\n",
+ "if f2x2\n",
+ " plot(x4,f4,'*',[x1,x2],[f1,f2])\n",
+ " x1=x2;\n",
+ " f1=f2;\n",
+ " else\n",
+ " plot(x4,f4,'*',[x3,x2],[f3,f2])\n",
+ " x3=x2;\n",
+ " f3=f2;\n",
+ " end\n",
+ " x2=x4; f2=f4;\n",
+ "else\n",
+ " error('no minimum in bracket')\n",
+ "end\n",
+ "hold off\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 33,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "f3 = -0.038878\r\n"
+ ]
+ },
+ {
+ "data": {
+ "image/svg+xml": [
+ ""
+ ],
+ "text/plain": [
+ ""
+ ]
+ },
+ "metadata": {},
+ "output_type": "display_data"
+ }
+ ],
+ "source": [
+ "p = polyfit([x1,x2,x3],[f1,f2,f3],2);\n",
+ "x_fit = linspace(x1,x3,20);\n",
+ "y_fit = polyval(p,x_fit);\n",
+ "\n",
+ "plot(x,Au_x(x),x_fit,y_fit,[x1,x2,x3],[f1,f2,f3],'o')\n",
+ "hold on\n",
+ "if f2x2\n",
+ " plot(x4,f4,'*',[x1,x2],[f1,f2])\n",
+ " x1=x2;\n",
+ " f1=f2;\n",
+ " else\n",
+ " plot(x4,f4,'*',[x3,x2],[f3,f2])\n",
+ " x3=x2;\n",
+ " f3=f2;\n",
+ " end\n",
+ " x2=x4; f2=f4;\n",
+ "else\n",
+ " error('no minimum in bracket')\n",
+ "end\n",
+ "hold off\n"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "Parabolic interpolation does not converge in many scenarios even though it it a bracketing method. Instead, functions like `fminbnd` in Matlab and Octave use a combination of the two (Golden Ratio and Parabolic)"
+ ]
+ },
+ {
+ "cell_type": "markdown",
+ "metadata": {},
+ "source": [
+ "## Using the solutions to minimization for the nonlinear spring constant\n",
+ "\n",
+ "Now, we have two routines to find minimums of a univariate function (Golden Ratio and Parabolic). Let's use these to solve for the minimum energy given a range of applied forces to the single atom gold chain\n",
+ "\n",
+ "$E_{total}(\\Delta x) = E_{LJ}(x_{min}+\\Delta x) - F \\cdot \\Delta x$"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 37,
+ "metadata": {
+ "collapsed": false
+ },
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "xmin = 3.2933\r\n"
+ ]
+ }
+ ],
+ "source": [
+ "xmin = fminbnd(Au_x,2.8,6)\n",
+ "\n",
+ "Etotal = @(dx,F) Au_x(xmin+dx)-F.*dx;\n"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": null,
+ "metadata": {
+ "collapsed": true
+ },
+ "outputs": [],
+ "source": []
+ }
+ ],
+ "metadata": {
+ "kernelspec": {
+ "display_name": "Octave",
+ "language": "octave",
+ "name": "octave"
+ },
+ "language_info": {
+ "file_extension": ".m",
+ "help_links": [
+ {
+ "text": "MetaKernel Magics",
+ "url": "https://github.com/calysto/metakernel/blob/master/metakernel/magics/README.md"
+ }
+ ],
+ "mimetype": "text/x-octave",
+ "name": "octave",
+ "version": "0.19.14"
+ }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/lecture_08/lennard_jones.m b/lecture_08/lennard_jones.m
new file mode 100644
index 0000000..d18a6ad
--- /dev/null
+++ b/lecture_08/lennard_jones.m
@@ -0,0 +1,4 @@
+function E_LJ =lennard_jones(x,sigma,epsilon)
+ E_LJ = 4*epsilon*((sigma./x).^12-(sigma./x).^6);
+end
+
diff --git a/lecture_08/octave-workspace b/lecture_08/octave-workspace
new file mode 100644
index 0000000..f505b0a
Binary files /dev/null and b/lecture_08/octave-workspace differ