\n",
@@ -2130,11 +2070,8 @@
"sigma = 2.934; % Angstrom\n",
"sigma = sigma*0.10; % nm/Angstrom\n",
"x=linspace(2.8,6,200)*0.10; % bond length in um\n",
- "\n",
"Ex = lennard_jones(x,sigma,epsilon);\n",
"\n",
- "%[Emin,imin]=min(Ex);\n",
- "\n",
"[xmin,Emin] = goldmin(@(x) lennard_jones(x,sigma,epsilon),0.28,0.6)\n",
"\n",
"plot(x,Ex,xmin,Emin,'o')\n",
diff --git a/08_optimization/octave-workspace b/08_optimization/octave-workspace
index 8c437bb..4df051d 100644
Binary files a/08_optimization/octave-workspace and b/08_optimization/octave-workspace differ
diff --git a/HW2/README.html b/HW2/README.html
new file mode 100644
index 0000000..078c879
--- /dev/null
+++ b/HW2/README.html
@@ -0,0 +1,77 @@
+
+
+
+
+
+
+
+
+
+
+
+Homework #2
+due 10/6/17 by 11:59pm
+1. Create a new github repository called ‘02_roots_and_optimization’.
+
+Add rcc02007 and zhs15101 as collaborators.
+submit the clone repository URL to: https://goo.gl/forms/svFKpfiCfLO9Zvfz1
+
+2. You’re installing a powerline in a residential neighborhood. The lowest point on the cable is 30 m above the ground, but 30 m away is a tree that is 35 m tall. Another engineer informs you that this is a catenary cable problem with the following solution
+
+\(y(x)=\frac{T}{w}\cosh\left(\frac{w}{T}x\right)+y_{0}-\frac{T}{w}\).
+where y(x) is the height of the cable at a distance, x, from the lowest point, \(y_{0}\), T is the tension in the cable, and w is the weight per unit length of the cable. Your supervisor wants to know which numerical solver to use when they have to install these powerlines in similar places.
+
+Use the three solvers falsepos.m
, bisect.m
, and mod_secant.m
to solve for the tension neededi, T, to reach y(30 m)=35 m, with w=10 N/m, and \(y_{0}\)=30 m.
+Compare the number of iterations that each function needed to reach an accuracy of 0.00001%. Include a table in your README.md with:
+| solver | initial guess(es) | ea | number of iterations|
+| --- | --- | --- | --- |
+|falsepos | | | |
+|mod_secant | | | |
+|bisect | | | |
+Add a figure to your README that plots the final shape of the powerline () from x=-10 to 50 m.
+
+3. The Newton-Raphson method and the modified secant method do not always converge to a solution. One simple example is the function f(x) = (x-1)*exp(-(x-1)^2). The root is at 1, but using the numerical solvers, newtraph.m
and mod_secant.m
, there are certain initial guesses that do not converge.
+
+Calculate the first 5 iterations for the Newton-Raphson method with an initial guess of x_i=3 for f(x)=(x-1)*exp(-(x-1)^2).
+Add the results to a table in the README.md
with:
+### divergence of Newton-Raphson method
+
+| iteration | x_i | approx error |
+| --- | --- | --- |
+| 0 | 3 | n/a |
+| 1 | | |
+| 2 | | |
+| 3 | | |
+| 4 | | |
+| 5 | | |
+Repeat steps a-b for an initial guess of 1.2. (But change the heading from ‘divergence’ to ‘convergence’)
+
+
+4. Determine the nonlinear spring constants of a single-atom gold chain. You can assume the gold atoms are aligned in a one dimensional network and the potential energy is described by the Lennard-Jones potential as such
+
+\(E_{LJ}(x)=4\epsilon \left(\left(\frac{\sigma}{x}\right)^{12}-\left(\frac{\sigma}{x}\right)^{6}\right)\).
+Where x is the distance between atoms in nm, \(\epsilon\)=2.71E-4 aJ, and \(\sigma\)=0.2934 nm. The energy term that must be minimized is
+
+\(E_{total}(\Delta x)=E_{LJ}(x_{0}+\Delta x)-F\Delta x\).
+Where \(x_{0}\) is the distance between atoms with no force applied and is the amount each gold atom has moved under a given force, F.
+
+Determine when F=0 nN using the golden ratio and parabolic methods. Show your script and output in your README and include your functions
+Solve for is the amount each gold atom has mov for F=0 to 0.0022 nN with 30 steps. *Use the golden ratio solver or the matlab/octave fminsearch
+create a sum of squares error function sse_of_parabola.m
that calculates the sum of squares error between a function \(F(x)=K_{1}\Delta x+1/2K_{2}\Delta x^{2}\) and the Forces used in part B for each .
+Use the fminsearch
matlab/octave function to determine .
+Plot the force vs calculated and the best-fit parabola using in part d.
+
+
+
diff --git a/HW2/README.md b/HW2/README.md
index a3b064d..0b5d703 100644
--- a/HW2/README.md
+++ b/HW2/README.md
@@ -14,6 +14,8 @@
cable is 30 m above the ground, but 30 m away is a tree that is 35 m tall. Another
engineer informs you that this is a catenary cable problem with the following solution
+ ![eq. 1](./equations/eq1.png)
+
$y(x)=\frac{T}{w}\cosh\left(\frac{w}{T}x\right)+y_{0}-\frac{T}{w}$.
where y(x) is the height of the cable at a distance, x, from the lowest point, $y_{0}$,
@@ -37,7 +39,7 @@ engineer informs you that this is a catenary cable problem with the following so
c. Add a figure to your README that plots the final shape of the powerline
- ($y(x)~vs.~x$) from x=-10 to 50 m.
+ (![eq2](./equations/eq2.png)) from x=-10 to 50 m.
**3\.** The Newton-Raphson method and the modified secant method do not always converge to a
solution. One simple example is the function f(x) = (x-1)*exp(-(x-1)^2). The root is at 1, but
@@ -71,29 +73,35 @@ guesses that do not converge.
the gold atoms are aligned in a one dimensional network and the potential energy is
described by the Lennard-Jones potential as such
+ ![eq3](./equations/eq3.png)
+
$E_{LJ}(x)=4\epsilon
\left(\left(\frac{\sigma}{x}\right)^{12}-\left(\frac{\sigma}{x}\right)^{6}\right)$.
Where x is the distance between atoms in nm, $\epsilon$=2.71E-4 aJ, and $\sigma$=0.2934
nm. The energy term that must be minimized is
+ ![eq4](./equations/eq4.png)
+
$E_{total}(\Delta x)=E_{LJ}(x_{0}+\Delta x)-F\Delta x$.
- Where $x_{0}$ is the distance between atoms with no force applied and $\Delta x$ is the
+ Where ![x0](./equations/x0.png) is the distance between atoms with no force applied and
+ ![dx](./equations/deltax.png) is the
amount each gold atom has moved under a given force, F.
- a. Determine $x_{0}$ when F=0 nN using the golden ratio and parabolic methods. *Show
+ a. Determine ![x0](./equations/x0.png) when F=0 nN using the golden ratio and parabolic methods. *Show
your script and output in your README and include your functions*
- b. Solve for $\Delta x$ for F=0 to 0.0022 nN with 30 steps. *Use the golden ratio
+ b. Solve for ![dx](./equations/deltax.png) is the
+ amount each gold atom has mov for F=0 to 0.0022 nN with 30 steps. *Use the golden ratio
solver or the matlab/octave `fminsearch`
c. create a sum of squares error function `sse_of_parabola.m` that calculates the sum of
squares error between a function $F(x)=K_{1}\Delta x+1/2K_{2}\Delta x^{2}$ and the
- Forces used in part B for each $\Delta x$.
+ Forces used in part B for each ![dx](./equations/deltax.png).
- d. Use the `fminsearch` matlab/octave function to determine $K_{1}$ and $K_{2}$.
+ d. Use the `fminsearch` matlab/octave function to determine
+ ![k1k2](./equations/k1k2.png).
- e. Plot the force vs calculated $\Delta x$ and the best-fit parabola using $K_{1}$ and
- $K_{2}$ in part d.
+ e. Plot the force vs calculated ![dx](./equations/deltax.png) and the best-fit parabola using ![k1k2](./equations/k1k2.png) in part d.
diff --git a/HW2/equations/README.md b/HW2/equations/README.md
new file mode 100644
index 0000000..e69de29
diff --git a/HW2/equations/deltax.png b/HW2/equations/deltax.png
new file mode 100644
index 0000000..a27cd7a
Binary files /dev/null and b/HW2/equations/deltax.png differ
diff --git a/HW2/equations/deltax.tex b/HW2/equations/deltax.tex
new file mode 100644
index 0000000..dfba7b4
--- /dev/null
+++ b/HW2/equations/deltax.tex
@@ -0,0 +1 @@
+$\Delta x$
diff --git a/HW2/equations/eq1.png b/HW2/equations/eq1.png
new file mode 100644
index 0000000..fe78ec6
Binary files /dev/null and b/HW2/equations/eq1.png differ
diff --git a/HW2/equations/eq1.tex b/HW2/equations/eq1.tex
new file mode 100644
index 0000000..3dadcac
--- /dev/null
+++ b/HW2/equations/eq1.tex
@@ -0,0 +1,2 @@
+$y(x)=T/w \cosh\left(\frac{w}{T}x\right)+y_{0}-\frac{T}{w}$.
+
diff --git a/HW2/equations/eq2.png b/HW2/equations/eq2.png
new file mode 100644
index 0000000..2bd0218
Binary files /dev/null and b/HW2/equations/eq2.png differ
diff --git a/HW2/equations/eq2.tex b/HW2/equations/eq2.tex
new file mode 100644
index 0000000..d6debd4
--- /dev/null
+++ b/HW2/equations/eq2.tex
@@ -0,0 +1,2 @@
+ ($y(x)~vs.~x$)
+
diff --git a/HW2/equations/eq3.png b/HW2/equations/eq3.png
new file mode 100644
index 0000000..121bdf0
Binary files /dev/null and b/HW2/equations/eq3.png differ
diff --git a/HW2/equations/eq3.tex b/HW2/equations/eq3.tex
new file mode 100644
index 0000000..b807515
--- /dev/null
+++ b/HW2/equations/eq3.tex
@@ -0,0 +1,3 @@
+$E_{LJ}(x)=4\epsilon
+\left(\left(\frac{\sigma}{x}\right)^{12}-\left(\frac{\sigma}{x}\right)^{6}\right)$.
+
diff --git a/HW2/equations/eq4.png b/HW2/equations/eq4.png
new file mode 100644
index 0000000..2077360
Binary files /dev/null and b/HW2/equations/eq4.png differ
diff --git a/HW2/equations/eq4.tex b/HW2/equations/eq4.tex
new file mode 100644
index 0000000..26fe469
--- /dev/null
+++ b/HW2/equations/eq4.tex
@@ -0,0 +1,2 @@
+$E_{total}(\Delta x)=E_{LJ}(x_{0}+\Delta x)-F\Delta x$.
+
diff --git a/HW2/equations/fx.png b/HW2/equations/fx.png
new file mode 100644
index 0000000..bd17982
Binary files /dev/null and b/HW2/equations/fx.png differ
diff --git a/HW2/equations/fx.tex b/HW2/equations/fx.tex
new file mode 100644
index 0000000..07d410c
--- /dev/null
+++ b/HW2/equations/fx.tex
@@ -0,0 +1,2 @@
+$F(x)=K_{1}\Delta x+1/2K_{2}\Delta x^{2}$
+
diff --git a/HW2/equations/k1k2.png b/HW2/equations/k1k2.png
new file mode 100644
index 0000000..d7048f7
Binary files /dev/null and b/HW2/equations/k1k2.png differ
diff --git a/HW2/equations/k1k2.tex b/HW2/equations/k1k2.tex
new file mode 100644
index 0000000..c0d4c95
--- /dev/null
+++ b/HW2/equations/k1k2.tex
@@ -0,0 +1 @@
+$K_{1}$ and $K_{2}$
diff --git a/HW2/equations/x0.png b/HW2/equations/x0.png
new file mode 100644
index 0000000..468b8ff
Binary files /dev/null and b/HW2/equations/x0.png differ
diff --git a/HW2/equations/x0.tex b/HW2/equations/x0.tex
new file mode 100644
index 0000000..037c2d3
--- /dev/null
+++ b/HW2/equations/x0.tex
@@ -0,0 +1 @@
+$x_{0}$