Skip to content
Permalink
master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
{
"cells": [
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"function h = parabola(x)\n",
" y=1;\n",
" h=sum(x.^2+y.^2-1);\n",
"end\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"ans = 0\r\n"
]
}
],
"source": [
"fzero(@(x) parabola(x),1)"
]
},
{
"cell_type": "code",
"execution_count": 10,
"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": "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.png)\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": 11,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"62.2,384.0 534.9,384.0 534.9,16.8 62.2,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L74.7,384.0 M535.0,384.0 L522.5,384.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,390.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,322.8 L74.7,322.8 M535.0,322.8 L522.5,322.8 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,328.8)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,261.6 L74.7,261.6 M535.0,261.6 L522.5,261.6 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,267.6)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,200.3 L74.7,200.3 M535.0,200.3 L522.5,200.3 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,206.3)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,139.1 L74.7,139.1 M535.0,139.1 L522.5,139.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,145.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,77.9 L74.7,77.9 M535.0,77.9 L522.5,77.9 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,83.9)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.06</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L74.7,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.08</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L62.2,371.5 M62.2,16.7 L62.2,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(62.2,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">2.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M129.7,384.0 L129.7,371.5 M129.7,16.7 L129.7,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(129.7,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M197.3,384.0 L197.3,371.5 M197.3,16.7 L197.3,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(197.3,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M264.8,384.0 L264.8,371.5 M264.8,16.7 L264.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(264.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M332.4,384.0 L332.4,371.5 M332.4,16.7 L332.4,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(332.4,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M399.9,384.0 L399.9,371.5 M399.9,16.7 L399.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(399.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M467.5,384.0 L467.5,371.5 M467.5,16.7 L467.5,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(467.5,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,384.0 L535.0,371.5 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">6</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L62.2,384.0 L535.0,384.0 L535.0,16.7 L62.2,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M102.7,56.9 L104.9,91.1 L107.1,122.2 L109.2,150.4 L111.4,176.0 L113.6,199.2 L115.8,220.2 L117.9,239.1 L120.1,256.2 L122.3,271.7 L124.4,285.6 L126.6,298.1 L128.8,309.3 L131.0,319.3 L133.1,328.2 L135.3,336.1 L137.5,343.2 L139.7,349.4 L141.8,354.9 L144.0,359.7 L146.2,363.8 L148.3,367.4 L150.5,370.4 L152.7,373.0 L154.9,375.2 L157.0,376.9 L159.2,378.3 L161.4,379.4 L163.5,380.1 L165.7,380.6 L167.9,380.9 L170.1,380.9 L172.2,380.8 L174.4,380.4 L176.6,379.9 L178.8,379.3 L180.9,378.5 L183.1,377.6 L185.3,376.6 L187.4,375.5 L189.6,374.4 L191.8,373.1 L194.0,371.9 L196.1,370.5 L198.3,369.1 L200.5,367.7 L202.6,366.2 L204.8,364.7 L207.0,363.2 L209.2,361.7 L211.3,360.1 L213.5,358.5 L215.7,357.0 L217.9,355.4 L220.0,353.8 L222.2,352.3 L224.4,350.7 L226.5,349.2 L228.7,347.6 L230.9,346.1 L233.1,344.6 L235.2,343.1 L237.4,341.6 L239.6,340.1 L241.7,338.6 L243.9,337.2 L246.1,335.8 L248.3,334.4 L250.4,333.0 L252.6,331.6 L254.8,330.3 L257.0,329.0 L259.1,327.7 L261.3,326.4 L263.5,325.1 L265.6,323.9 L267.8,322.7 L270.0,321.5 L272.2,320.3 L274.3,319.1 L276.5,318.0 L278.7,316.9 L280.8,315.8 L283.0,314.7 L285.2,313.7 L287.4,312.7 L289.5,311.7 L291.7,310.7 L293.9,309.7 L296.1,308.7 L298.2,307.8 L300.4,306.9 L302.6,306.0 L304.7,305.1 L306.9,304.3 L309.1,303.4 L311.3,302.6 L313.4,301.8 L315.6,301.0 L317.8,300.2 L319.9,299.5 L322.1,298.7 L324.3,298.0 L326.5,297.3 L328.6,296.6 L330.8,295.9 L333.0,295.2 L335.2,294.6 L337.3,293.9 L339.5,293.3 L341.7,292.7 L343.8,292.1 L346.0,291.5 L348.2,290.9 L350.4,290.4 L352.5,289.8 L354.7,289.3 L356.9,288.8 L359.0,288.2 L361.2,287.7 L363.4,287.2 L365.6,286.7 L367.7,286.3 L369.9,285.8 L372.1,285.3 L374.3,284.9 L376.4,284.5 L378.6,284.0 L380.8,283.6 L382.9,283.2 L385.1,282.8 L387.3,282.4 L389.5,282.0 L391.6,281.6 L393.8,281.3 L396.0,280.9 L398.1,280.5 L400.3,280.2 L402.5,279.9 L404.7,279.5 L406.8,279.2 L409.0,278.9 L411.2,278.6 L413.4,278.3 L415.5,278.0 L417.7,277.7 L419.9,277.4 L422.0,277.1 L424.2,276.8 L426.4,276.5 L428.6,276.3 L430.7,276.0 L432.9,275.8 L435.1,275.5 L437.2,275.3 L439.4,275.0 L441.6,274.8 L443.8,274.6 L445.9,274.3 L448.1,274.1 L450.3,273.9 L452.5,273.7 L454.6,273.5 L456.8,273.3 L459.0,273.1 L461.1,272.9 L463.3,272.7 L465.5,272.5 L467.7,272.3 L469.8,272.1 L472.0,271.9 L474.2,271.8 L476.3,271.6 L478.5,271.4 L480.7,271.3 L482.9,271.1 L485.0,270.9 L487.2,270.8 L489.4,270.6 L491.6,270.5 L493.7,270.3 L495.9,270.2 L498.1,270.0 L500.2,269.9 L502.4,269.8 L504.6,269.6 L506.8,269.5 L508.9,269.4 L511.1,269.3 L513.3,269.1 L515.4,269.0 L517.6,268.9 L519.8,268.8 L522.0,268.7 L524.1,268.5 L526.3,268.4 L528.5,268.3 L530.7,268.2 L532.8,268.1 L535.0,268.0 \" stroke=\"rgb( 0, 0, 255)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_2a\"><title>gnuplot_plot_2a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 128, 0)\" transform=\"translate(170.1,380.9) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"</g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb( 0, 128, 0)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"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": 12,
"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": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"current_min = -0.019959\r\n"
]
},
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"62.2,384.0 534.9,384.0 534.9,16.8 62.2,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L74.7,384.0 M535.0,384.0 L522.5,384.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,390.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,322.8 L74.7,322.8 M535.0,322.8 L522.5,322.8 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,328.8)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,261.6 L74.7,261.6 M535.0,261.6 L522.5,261.6 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,267.6)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,200.3 L74.7,200.3 M535.0,200.3 L522.5,200.3 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,206.3)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,139.1 L74.7,139.1 M535.0,139.1 L522.5,139.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,145.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,77.9 L74.7,77.9 M535.0,77.9 L522.5,77.9 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,83.9)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.06</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L74.7,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.08</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L62.2,371.5 M62.2,16.7 L62.2,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(62.2,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">2.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M129.7,384.0 L129.7,371.5 M129.7,16.7 L129.7,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(129.7,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M197.3,384.0 L197.3,371.5 M197.3,16.7 L197.3,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(197.3,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M264.8,384.0 L264.8,371.5 M264.8,16.7 L264.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(264.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M332.4,384.0 L332.4,371.5 M332.4,16.7 L332.4,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(332.4,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M399.9,384.0 L399.9,371.5 M399.9,16.7 L399.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(399.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M467.5,384.0 L467.5,371.5 M467.5,16.7 L467.5,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(467.5,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,384.0 L535.0,371.5 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">6</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L62.2,384.0 L535.0,384.0 L535.0,16.7 L62.2,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M102.7,56.9 L104.9,91.1 L107.1,122.2 L109.2,150.4 L111.4,176.0 L113.6,199.2 L115.8,220.2 L117.9,239.1 L120.1,256.2 L122.3,271.7 L124.4,285.6 L126.6,298.1 L128.8,309.3 L131.0,319.3 L133.1,328.2 L135.3,336.1 L137.5,343.2 L139.7,349.4 L141.8,354.9 L144.0,359.7 L146.2,363.8 L148.3,367.4 L150.5,370.4 L152.7,373.0 L154.9,375.2 L157.0,376.9 L159.2,378.3 L161.4,379.4 L163.5,380.1 L165.7,380.6 L167.9,380.9 L170.1,380.9 L172.2,380.8 L174.4,380.4 L176.6,379.9 L178.8,379.3 L180.9,378.5 L183.1,377.6 L185.3,376.6 L187.4,375.5 L189.6,374.4 L191.8,373.1 L194.0,371.9 L196.1,370.5 L198.3,369.1 L200.5,367.7 L202.6,366.2 L204.8,364.7 L207.0,363.2 L209.2,361.7 L211.3,360.1 L213.5,358.5 L215.7,357.0 L217.9,355.4 L220.0,353.8 L222.2,352.3 L224.4,350.7 L226.5,349.2 L228.7,347.6 L230.9,346.1 L233.1,344.6 L235.2,343.1 L237.4,341.6 L239.6,340.1 L241.7,338.6 L243.9,337.2 L246.1,335.8 L248.3,334.4 L250.4,333.0 L252.6,331.6 L254.8,330.3 L257.0,329.0 L259.1,327.7 L261.3,326.4 L263.5,325.1 L265.6,323.9 L267.8,322.7 L270.0,321.5 L272.2,320.3 L274.3,319.1 L276.5,318.0 L278.7,316.9 L280.8,315.8 L283.0,314.7 L285.2,313.7 L287.4,312.7 L289.5,311.7 L291.7,310.7 L293.9,309.7 L296.1,308.7 L298.2,307.8 L300.4,306.9 L302.6,306.0 L304.7,305.1 L306.9,304.3 L309.1,303.4 L311.3,302.6 L313.4,301.8 L315.6,301.0 L317.8,300.2 L319.9,299.5 L322.1,298.7 L324.3,298.0 L326.5,297.3 L328.6,296.6 L330.8,295.9 L333.0,295.2 L335.2,294.6 L337.3,293.9 L339.5,293.3 L341.7,292.7 L343.8,292.1 L346.0,291.5 L348.2,290.9 L350.4,290.4 L352.5,289.8 L354.7,289.3 L356.9,288.8 L359.0,288.2 L361.2,287.7 L363.4,287.2 L365.6,286.7 L367.7,286.3 L369.9,285.8 L372.1,285.3 L374.3,284.9 L376.4,284.5 L378.6,284.0 L380.8,283.6 L382.9,283.2 L385.1,282.8 L387.3,282.4 L389.5,282.0 L391.6,281.6 L393.8,281.3 L396.0,280.9 L398.1,280.5 L400.3,280.2 L402.5,279.9 L404.7,279.5 L406.8,279.2 L409.0,278.9 L411.2,278.6 L413.4,278.3 L415.5,278.0 L417.7,277.7 L419.9,277.4 L422.0,277.1 L424.2,276.8 L426.4,276.5 L428.6,276.3 L430.7,276.0 L432.9,275.8 L435.1,275.5 L437.2,275.3 L439.4,275.0 L441.6,274.8 L443.8,274.6 L445.9,274.3 L448.1,274.1 L450.3,273.9 L452.5,273.7 L454.6,273.5 L456.8,273.3 L459.0,273.1 L461.1,272.9 L463.3,272.7 L465.5,272.5 L467.7,272.3 L469.8,272.1 L472.0,271.9 L474.2,271.8 L476.3,271.6 L478.5,271.4 L480.7,271.3 L482.9,271.1 L485.0,270.9 L487.2,270.8 L489.4,270.6 L491.6,270.5 L493.7,270.3 L495.9,270.2 L498.1,270.0 L500.2,269.9 L502.4,269.8 L504.6,269.6 L506.8,269.5 L508.9,269.4 L511.1,269.3 L513.3,269.1 L515.4,269.0 L517.6,268.9 L519.8,268.8 L522.0,268.7 L524.1,268.5 L526.3,268.4 L528.5,268.3 L530.7,268.2 L532.8,268.1 L535.0,268.0 \" stroke=\"rgb( 0, 0, 255)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_2a\"><title>gnuplot_plot_2a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(102.7,56.9) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_3a\"><title>gnuplot_plot_3a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(267.8,322.7) scale(9.00)\" xlink:href=\"#gpPt3\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_4a\"><title>gnuplot_plot_4a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 255, 0)\" transform=\"translate(369.9,285.8) scale(9.00)\" xlink:href=\"#gpPt3\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_5a\"><title>gnuplot_plot_5a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 255, 0)\" transform=\"translate(535.0,268.0) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_6a\"><title>gnuplot_plot_6a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M535.0,268.0 L369.9,285.8 \" stroke=\"rgb( 0, 0, 0)\"/></g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb( 0, 0, 0)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"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<f1\n",
" plot([x_u,x1],[Au_x(x_u),f1],'k-')\n",
" x_u=x1;\n",
"else \n",
" plot([x_l,x2],[Au_x(x_l),f2],'k-')\n",
" x_l=x1;\n",
"end\n",
"hold off\n",
"%old_min = current_min;\n",
"current_min=min([f1,f2,Au_x(x_l),Au_x(x_u)])\n",
"%error_app=abs((current_min-old_min)/current_min)"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"current_min = -0.033707\n",
"error_app = 0.40787\n"
]
},
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"62.2,384.0 534.9,384.0 534.9,16.8 62.2,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L74.7,384.0 M535.0,384.0 L522.5,384.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,390.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,322.8 L74.7,322.8 M535.0,322.8 L522.5,322.8 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,328.8)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,261.6 L74.7,261.6 M535.0,261.6 L522.5,261.6 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,267.6)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,200.3 L74.7,200.3 M535.0,200.3 L522.5,200.3 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,206.3)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,139.1 L74.7,139.1 M535.0,139.1 L522.5,139.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,145.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,77.9 L74.7,77.9 M535.0,77.9 L522.5,77.9 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,83.9)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.06</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L74.7,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.08</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L62.2,371.5 M62.2,16.7 L62.2,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(62.2,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">2.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M129.7,384.0 L129.7,371.5 M129.7,16.7 L129.7,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(129.7,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M197.3,384.0 L197.3,371.5 M197.3,16.7 L197.3,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(197.3,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M264.8,384.0 L264.8,371.5 M264.8,16.7 L264.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(264.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M332.4,384.0 L332.4,371.5 M332.4,16.7 L332.4,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(332.4,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M399.9,384.0 L399.9,371.5 M399.9,16.7 L399.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(399.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M467.5,384.0 L467.5,371.5 M467.5,16.7 L467.5,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(467.5,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,384.0 L535.0,371.5 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">6</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L62.2,384.0 L535.0,384.0 L535.0,16.7 L62.2,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M102.7,56.9 L104.9,91.1 L107.1,122.2 L109.2,150.4 L111.4,176.0 L113.6,199.2 L115.8,220.2 L117.9,239.1 L120.1,256.2 L122.3,271.7 L124.4,285.6 L126.6,298.1 L128.8,309.3 L131.0,319.3 L133.1,328.2 L135.3,336.1 L137.5,343.2 L139.7,349.4 L141.8,354.9 L144.0,359.7 L146.2,363.8 L148.3,367.4 L150.5,370.4 L152.7,373.0 L154.9,375.2 L157.0,376.9 L159.2,378.3 L161.4,379.4 L163.5,380.1 L165.7,380.6 L167.9,380.9 L170.1,380.9 L172.2,380.8 L174.4,380.4 L176.6,379.9 L178.8,379.3 L180.9,378.5 L183.1,377.6 L185.3,376.6 L187.4,375.5 L189.6,374.4 L191.8,373.1 L194.0,371.9 L196.1,370.5 L198.3,369.1 L200.5,367.7 L202.6,366.2 L204.8,364.7 L207.0,363.2 L209.2,361.7 L211.3,360.1 L213.5,358.5 L215.7,357.0 L217.9,355.4 L220.0,353.8 L222.2,352.3 L224.4,350.7 L226.5,349.2 L228.7,347.6 L230.9,346.1 L233.1,344.6 L235.2,343.1 L237.4,341.6 L239.6,340.1 L241.7,338.6 L243.9,337.2 L246.1,335.8 L248.3,334.4 L250.4,333.0 L252.6,331.6 L254.8,330.3 L257.0,329.0 L259.1,327.7 L261.3,326.4 L263.5,325.1 L265.6,323.9 L267.8,322.7 L270.0,321.5 L272.2,320.3 L274.3,319.1 L276.5,318.0 L278.7,316.9 L280.8,315.8 L283.0,314.7 L285.2,313.7 L287.4,312.7 L289.5,311.7 L291.7,310.7 L293.9,309.7 L296.1,308.7 L298.2,307.8 L300.4,306.9 L302.6,306.0 L304.7,305.1 L306.9,304.3 L309.1,303.4 L311.3,302.6 L313.4,301.8 L315.6,301.0 L317.8,300.2 L319.9,299.5 L322.1,298.7 L324.3,298.0 L326.5,297.3 L328.6,296.6 L330.8,295.9 L333.0,295.2 L335.2,294.6 L337.3,293.9 L339.5,293.3 L341.7,292.7 L343.8,292.1 L346.0,291.5 L348.2,290.9 L350.4,290.4 L352.5,289.8 L354.7,289.3 L356.9,288.8 L359.0,288.2 L361.2,287.7 L363.4,287.2 L365.6,286.7 L367.7,286.3 L369.9,285.8 L372.1,285.3 L374.3,284.9 L376.4,284.5 L378.6,284.0 L380.8,283.6 L382.9,283.2 L385.1,282.8 L387.3,282.4 L389.5,282.0 L391.6,281.6 L393.8,281.3 L396.0,280.9 L398.1,280.5 L400.3,280.2 L402.5,279.9 L404.7,279.5 L406.8,279.2 L409.0,278.9 L411.2,278.6 L413.4,278.3 L415.5,278.0 L417.7,277.7 L419.9,277.4 L422.0,277.1 L424.2,276.8 L426.4,276.5 L428.6,276.3 L430.7,276.0 L432.9,275.8 L435.1,275.5 L437.2,275.3 L439.4,275.0 L441.6,274.8 L443.8,274.6 L445.9,274.3 L448.1,274.1 L450.3,273.9 L452.5,273.7 L454.6,273.5 L456.8,273.3 L459.0,273.1 L461.1,272.9 L463.3,272.7 L465.5,272.5 L467.7,272.3 L469.8,272.1 L472.0,271.9 L474.2,271.8 L476.3,271.6 L478.5,271.4 L480.7,271.3 L482.9,271.1 L485.0,270.9 L487.2,270.8 L489.4,270.6 L491.6,270.5 L493.7,270.3 L495.9,270.2 L498.1,270.0 L500.2,269.9 L502.4,269.8 L504.6,269.6 L506.8,269.5 L508.9,269.4 L511.1,269.3 L513.3,269.1 L515.4,269.0 L517.6,268.9 L519.8,268.8 L522.0,268.7 L524.1,268.5 L526.3,268.4 L528.5,268.3 L530.7,268.2 L532.8,268.1 L535.0,268.0 \" stroke=\"rgb( 0, 0, 255)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_2a\"><title>gnuplot_plot_2a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(102.7,56.9) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_3a\"><title>gnuplot_plot_3a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(204.8,364.7) scale(9.00)\" xlink:href=\"#gpPt3\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_4a\"><title>gnuplot_plot_4a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 255, 0)\" transform=\"translate(267.8,322.7) scale(9.00)\" xlink:href=\"#gpPt3\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_5a\"><title>gnuplot_plot_5a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 255, 0)\" transform=\"translate(369.9,285.8) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_6a\"><title>gnuplot_plot_6a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M369.9,285.8 L267.8,322.7 \" stroke=\"rgb( 0, 0, 0)\"/></g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb( 0, 0, 0)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"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<f1\n",
" plot([x_u,x1],[Au_x(x_u),f1],'k-')\n",
" x_u=x1;\n",
"else \n",
" plot([x_l,x2],[Au_x(x_l),f2],'k-')\n",
" x_l=x1;\n",
"end\n",
"hold off\n",
"old_min = current_min;\n",
"current_min=min([f1,f2,Au_x(x_l),Au_x(x_u)])\n",
"error_app=abs((current_min-old_min)/current_min)"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"current_min = -0.038904\n",
"error_app = 0.13359\n"
]
},
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"62.2,384.0 534.9,384.0 534.9,16.8 62.2,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L74.7,384.0 M535.0,384.0 L522.5,384.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,390.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,322.8 L74.7,322.8 M535.0,322.8 L522.5,322.8 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,328.8)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,261.6 L74.7,261.6 M535.0,261.6 L522.5,261.6 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,267.6)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,200.3 L74.7,200.3 M535.0,200.3 L522.5,200.3 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,206.3)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,139.1 L74.7,139.1 M535.0,139.1 L522.5,139.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,145.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,77.9 L74.7,77.9 M535.0,77.9 L522.5,77.9 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,83.9)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.06</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L74.7,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.08</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L62.2,371.5 M62.2,16.7 L62.2,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(62.2,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">2.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M129.7,384.0 L129.7,371.5 M129.7,16.7 L129.7,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(129.7,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M197.3,384.0 L197.3,371.5 M197.3,16.7 L197.3,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(197.3,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M264.8,384.0 L264.8,371.5 M264.8,16.7 L264.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(264.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M332.4,384.0 L332.4,371.5 M332.4,16.7 L332.4,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(332.4,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M399.9,384.0 L399.9,371.5 M399.9,16.7 L399.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(399.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M467.5,384.0 L467.5,371.5 M467.5,16.7 L467.5,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(467.5,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,384.0 L535.0,371.5 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">6</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L62.2,384.0 L535.0,384.0 L535.0,16.7 L62.2,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M102.7,56.9 L104.9,91.1 L107.1,122.2 L109.2,150.4 L111.4,176.0 L113.6,199.2 L115.8,220.2 L117.9,239.1 L120.1,256.2 L122.3,271.7 L124.4,285.6 L126.6,298.1 L128.8,309.3 L131.0,319.3 L133.1,328.2 L135.3,336.1 L137.5,343.2 L139.7,349.4 L141.8,354.9 L144.0,359.7 L146.2,363.8 L148.3,367.4 L150.5,370.4 L152.7,373.0 L154.9,375.2 L157.0,376.9 L159.2,378.3 L161.4,379.4 L163.5,380.1 L165.7,380.6 L167.9,380.9 L170.1,380.9 L172.2,380.8 L174.4,380.4 L176.6,379.9 L178.8,379.3 L180.9,378.5 L183.1,377.6 L185.3,376.6 L187.4,375.5 L189.6,374.4 L191.8,373.1 L194.0,371.9 L196.1,370.5 L198.3,369.1 L200.5,367.7 L202.6,366.2 L204.8,364.7 L207.0,363.2 L209.2,361.7 L211.3,360.1 L213.5,358.5 L215.7,357.0 L217.9,355.4 L220.0,353.8 L222.2,352.3 L224.4,350.7 L226.5,349.2 L228.7,347.6 L230.9,346.1 L233.1,344.6 L235.2,343.1 L237.4,341.6 L239.6,340.1 L241.7,338.6 L243.9,337.2 L246.1,335.8 L248.3,334.4 L250.4,333.0 L252.6,331.6 L254.8,330.3 L257.0,329.0 L259.1,327.7 L261.3,326.4 L263.5,325.1 L265.6,323.9 L267.8,322.7 L270.0,321.5 L272.2,320.3 L274.3,319.1 L276.5,318.0 L278.7,316.9 L280.8,315.8 L283.0,314.7 L285.2,313.7 L287.4,312.7 L289.5,311.7 L291.7,310.7 L293.9,309.7 L296.1,308.7 L298.2,307.8 L300.4,306.9 L302.6,306.0 L304.7,305.1 L306.9,304.3 L309.1,303.4 L311.3,302.6 L313.4,301.8 L315.6,301.0 L317.8,300.2 L319.9,299.5 L322.1,298.7 L324.3,298.0 L326.5,297.3 L328.6,296.6 L330.8,295.9 L333.0,295.2 L335.2,294.6 L337.3,293.9 L339.5,293.3 L341.7,292.7 L343.8,292.1 L346.0,291.5 L348.2,290.9 L350.4,290.4 L352.5,289.8 L354.7,289.3 L356.9,288.8 L359.0,288.2 L361.2,287.7 L363.4,287.2 L365.6,286.7 L367.7,286.3 L369.9,285.8 L372.1,285.3 L374.3,284.9 L376.4,284.5 L378.6,284.0 L380.8,283.6 L382.9,283.2 L385.1,282.8 L387.3,282.4 L389.5,282.0 L391.6,281.6 L393.8,281.3 L396.0,280.9 L398.1,280.5 L400.3,280.2 L402.5,279.9 L404.7,279.5 L406.8,279.2 L409.0,278.9 L411.2,278.6 L413.4,278.3 L415.5,278.0 L417.7,277.7 L419.9,277.4 L422.0,277.1 L424.2,276.8 L426.4,276.5 L428.6,276.3 L430.7,276.0 L432.9,275.8 L435.1,275.5 L437.2,275.3 L439.4,275.0 L441.6,274.8 L443.8,274.6 L445.9,274.3 L448.1,274.1 L450.3,273.9 L452.5,273.7 L454.6,273.5 L456.8,273.3 L459.0,273.1 L461.1,272.9 L463.3,272.7 L465.5,272.5 L467.7,272.3 L469.8,272.1 L472.0,271.9 L474.2,271.8 L476.3,271.6 L478.5,271.4 L480.7,271.3 L482.9,271.1 L485.0,270.9 L487.2,270.8 L489.4,270.6 L491.6,270.5 L493.7,270.3 L495.9,270.2 L498.1,270.0 L500.2,269.9 L502.4,269.8 L504.6,269.6 L506.8,269.5 L508.9,269.4 L511.1,269.3 L513.3,269.1 L515.4,269.0 L517.6,268.9 L519.8,268.8 L522.0,268.7 L524.1,268.5 L526.3,268.4 L528.5,268.3 L530.7,268.2 L532.8,268.1 L535.0,268.0 \" stroke=\"rgb( 0, 0, 255)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_2a\"><title>gnuplot_plot_2a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(102.7,56.9) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_3a\"><title>gnuplot_plot_3a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(165.8,380.6) scale(9.00)\" xlink:href=\"#gpPt3\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_4a\"><title>gnuplot_plot_4a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 255, 0)\" transform=\"translate(204.8,364.7) scale(9.00)\" xlink:href=\"#gpPt3\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_5a\"><title>gnuplot_plot_5a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 255, 0)\" transform=\"translate(267.8,322.7) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_6a\"><title>gnuplot_plot_6a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M267.8,322.7 L204.8,364.7 \" stroke=\"rgb( 0, 0, 0)\"/></g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb( 0, 0, 0)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"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<f1\n",
" plot([x_u,x1],[Au_x(x_u),f1],'k-')\n",
" x_u=x1;\n",
"else \n",
" plot([x_l,x2],[Au_x(x_l),f2],'k-')\n",
" x_l=x1;\n",
"end\n",
"hold off\n",
"old_min = current_min;\n",
"current_min=min([f1,f2,Au_x(x_l),Au_x(x_u)])\n",
"error_app=abs((current_min-old_min)/current_min)"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"current_min = -0.038904\n",
"error_app = 0\n"
]
},
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"62.2,384.0 534.9,384.0 534.9,16.8 62.2,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L74.7,384.0 M535.0,384.0 L522.5,384.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,390.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,322.8 L74.7,322.8 M535.0,322.8 L522.5,322.8 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,328.8)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,261.6 L74.7,261.6 M535.0,261.6 L522.5,261.6 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,267.6)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,200.3 L74.7,200.3 M535.0,200.3 L522.5,200.3 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,206.3)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,139.1 L74.7,139.1 M535.0,139.1 L522.5,139.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,145.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,77.9 L74.7,77.9 M535.0,77.9 L522.5,77.9 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,83.9)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.06</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L74.7,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.08</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L62.2,371.5 M62.2,16.7 L62.2,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(62.2,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">2.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M129.7,384.0 L129.7,371.5 M129.7,16.7 L129.7,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(129.7,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M197.3,384.0 L197.3,371.5 M197.3,16.7 L197.3,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(197.3,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M264.8,384.0 L264.8,371.5 M264.8,16.7 L264.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(264.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M332.4,384.0 L332.4,371.5 M332.4,16.7 L332.4,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(332.4,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M399.9,384.0 L399.9,371.5 M399.9,16.7 L399.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(399.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M467.5,384.0 L467.5,371.5 M467.5,16.7 L467.5,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(467.5,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,384.0 L535.0,371.5 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">6</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L62.2,384.0 L535.0,384.0 L535.0,16.7 L62.2,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M102.7,56.9 L104.9,91.1 L107.1,122.2 L109.2,150.4 L111.4,176.0 L113.6,199.2 L115.8,220.2 L117.9,239.1 L120.1,256.2 L122.3,271.7 L124.4,285.6 L126.6,298.1 L128.8,309.3 L131.0,319.3 L133.1,328.2 L135.3,336.1 L137.5,343.2 L139.7,349.4 L141.8,354.9 L144.0,359.7 L146.2,363.8 L148.3,367.4 L150.5,370.4 L152.7,373.0 L154.9,375.2 L157.0,376.9 L159.2,378.3 L161.4,379.4 L163.5,380.1 L165.7,380.6 L167.9,380.9 L170.1,380.9 L172.2,380.8 L174.4,380.4 L176.6,379.9 L178.8,379.3 L180.9,378.5 L183.1,377.6 L185.3,376.6 L187.4,375.5 L189.6,374.4 L191.8,373.1 L194.0,371.9 L196.1,370.5 L198.3,369.1 L200.5,367.7 L202.6,366.2 L204.8,364.7 L207.0,363.2 L209.2,361.7 L211.3,360.1 L213.5,358.5 L215.7,357.0 L217.9,355.4 L220.0,353.8 L222.2,352.3 L224.4,350.7 L226.5,349.2 L228.7,347.6 L230.9,346.1 L233.1,344.6 L235.2,343.1 L237.4,341.6 L239.6,340.1 L241.7,338.6 L243.9,337.2 L246.1,335.8 L248.3,334.4 L250.4,333.0 L252.6,331.6 L254.8,330.3 L257.0,329.0 L259.1,327.7 L261.3,326.4 L263.5,325.1 L265.6,323.9 L267.8,322.7 L270.0,321.5 L272.2,320.3 L274.3,319.1 L276.5,318.0 L278.7,316.9 L280.8,315.8 L283.0,314.7 L285.2,313.7 L287.4,312.7 L289.5,311.7 L291.7,310.7 L293.9,309.7 L296.1,308.7 L298.2,307.8 L300.4,306.9 L302.6,306.0 L304.7,305.1 L306.9,304.3 L309.1,303.4 L311.3,302.6 L313.4,301.8 L315.6,301.0 L317.8,300.2 L319.9,299.5 L322.1,298.7 L324.3,298.0 L326.5,297.3 L328.6,296.6 L330.8,295.9 L333.0,295.2 L335.2,294.6 L337.3,293.9 L339.5,293.3 L341.7,292.7 L343.8,292.1 L346.0,291.5 L348.2,290.9 L350.4,290.4 L352.5,289.8 L354.7,289.3 L356.9,288.8 L359.0,288.2 L361.2,287.7 L363.4,287.2 L365.6,286.7 L367.7,286.3 L369.9,285.8 L372.1,285.3 L374.3,284.9 L376.4,284.5 L378.6,284.0 L380.8,283.6 L382.9,283.2 L385.1,282.8 L387.3,282.4 L389.5,282.0 L391.6,281.6 L393.8,281.3 L396.0,280.9 L398.1,280.5 L400.3,280.2 L402.5,279.9 L404.7,279.5 L406.8,279.2 L409.0,278.9 L411.2,278.6 L413.4,278.3 L415.5,278.0 L417.7,277.7 L419.9,277.4 L422.0,277.1 L424.2,276.8 L426.4,276.5 L428.6,276.3 L430.7,276.0 L432.9,275.8 L435.1,275.5 L437.2,275.3 L439.4,275.0 L441.6,274.8 L443.8,274.6 L445.9,274.3 L448.1,274.1 L450.3,273.9 L452.5,273.7 L454.6,273.5 L456.8,273.3 L459.0,273.1 L461.1,272.9 L463.3,272.7 L465.5,272.5 L467.7,272.3 L469.8,272.1 L472.0,271.9 L474.2,271.8 L476.3,271.6 L478.5,271.4 L480.7,271.3 L482.9,271.1 L485.0,270.9 L487.2,270.8 L489.4,270.6 L491.6,270.5 L493.7,270.3 L495.9,270.2 L498.1,270.0 L500.2,269.9 L502.4,269.8 L504.6,269.6 L506.8,269.5 L508.9,269.4 L511.1,269.3 L513.3,269.1 L515.4,269.0 L517.6,268.9 L519.8,268.8 L522.0,268.7 L524.1,268.5 L526.3,268.4 L528.5,268.3 L530.7,268.2 L532.8,268.1 L535.0,268.0 \" stroke=\"rgb( 0, 0, 255)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_2a\"><title>gnuplot_plot_2a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(102.7,56.9) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_3a\"><title>gnuplot_plot_3a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(141.7,354.6) scale(9.00)\" xlink:href=\"#gpPt3\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_4a\"><title>gnuplot_plot_4a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 255, 0)\" transform=\"translate(165.8,380.6) scale(9.00)\" xlink:href=\"#gpPt3\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_5a\"><title>gnuplot_plot_5a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 255, 0)\" transform=\"translate(204.8,364.7) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_6a\"><title>gnuplot_plot_6a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M102.7,56.9 L141.7,354.6 \" stroke=\"rgb( 0, 0, 0)\"/></g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb( 0, 0, 0)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"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<f1\n",
" plot([x_u,x1],[Au_x(x_u),f1],'k-')\n",
" x_u=x1;\n",
"else \n",
" plot([x_l,x2],[Au_x(x_l),f2],'k-')\n",
" x_l=x1;\n",
"end\n",
"hold off\n",
"old_min = current_min;\n",
"current_min=min([f1,f2,Au_x(x_l),Au_x(x_u)])\n",
"error_app=abs((current_min-old_min)/current_min)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"## Parabolic Interpolation\n",
"\n",
"Near a minimum/maximum, the function resembles a parabola. With three data points, it is possible to fit a parabola to the function. So, given a lower and upper bound, we can choose the midpoint and fit a parabola to the 3 x,f(x) coordinates. \n",
"\n",
"$$ x_{4} =x_{2} - \\frac{1}{2}\\frac{\\left(x_{2} -x_{1}\\right)^{2} \\left(f\\left(x_{2} \\right)-f \\left(x_{3} \\right) \\right)- \\left(x_{2} -x_{3} \\right)^{2}\\left(f \\left(x_{2} \\right)-f \\left(x_{1} \\right) \\right)}{ \\left(x_{2} -x_{1} \\right) \\left(f \\left(x_{2} \\right)-f \\left(x_{3} \\right)\\right)- \\left(x_{2} -x_{3} \\right) \\left(f \\left(x_{2} \\right)-f \\left(x_{1} \\right) \\right)}$$\n",
"\n",
"Where $x_{4}$ location of the maximum or minimum of the parabola. "
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"62.2,384.0 534.9,384.0 534.9,16.8 62.2,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L74.7,384.0 M535.0,384.0 L522.5,384.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,390.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.06</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,331.5 L74.7,331.5 M535.0,331.5 L522.5,331.5 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,337.5)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,279.1 L74.7,279.1 M535.0,279.1 L522.5,279.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,285.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,226.6 L74.7,226.6 M535.0,226.6 L522.5,226.6 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,232.6)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,174.1 L74.7,174.1 M535.0,174.1 L522.5,174.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,180.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,121.6 L74.7,121.6 M535.0,121.6 L522.5,121.6 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,127.6)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,69.2 L74.7,69.2 M535.0,69.2 L522.5,69.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,75.2)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.06</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L74.7,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.08</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L62.2,371.5 M62.2,16.7 L62.2,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(62.2,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">2.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M129.7,384.0 L129.7,371.5 M129.7,16.7 L129.7,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(129.7,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M197.3,384.0 L197.3,371.5 M197.3,16.7 L197.3,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(197.3,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M264.8,384.0 L264.8,371.5 M264.8,16.7 L264.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(264.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M332.4,384.0 L332.4,371.5 M332.4,16.7 L332.4,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(332.4,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M399.9,384.0 L399.9,371.5 M399.9,16.7 L399.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(399.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M467.5,384.0 L467.5,371.5 M467.5,16.7 L467.5,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(467.5,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,384.0 L535.0,371.5 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">6</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L62.2,384.0 L535.0,384.0 L535.0,16.7 L62.2,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M102.7,51.2 L104.9,80.5 L107.1,107.1 L109.2,131.3 L111.4,153.2 L113.6,173.1 L115.8,191.1 L117.9,207.3 L120.1,222.0 L122.3,235.3 L124.4,247.2 L126.6,257.9 L128.8,267.5 L131.0,276.0 L133.1,283.7 L135.3,290.5 L137.5,296.5 L139.7,301.9 L141.8,306.6 L144.0,310.7 L146.2,314.2 L148.3,317.3 L150.5,319.9 L152.7,322.1 L154.9,324.0 L157.0,325.5 L159.2,326.6 L161.4,327.6 L163.5,328.2 L165.7,328.6 L167.9,328.9 L170.1,328.9 L172.2,328.8 L174.4,328.5 L176.6,328.0 L178.8,327.5 L180.9,326.8 L183.1,326.1 L185.3,325.2 L187.4,324.3 L189.6,323.3 L191.8,322.2 L194.0,321.1 L196.1,320.0 L198.3,318.8 L200.5,317.5 L202.6,316.3 L204.8,315.0 L207.0,313.7 L209.2,312.4 L211.3,311.0 L213.5,309.7 L215.7,308.4 L217.9,307.0 L220.0,305.7 L222.2,304.3 L224.4,303.0 L226.5,301.7 L228.7,300.3 L230.9,299.0 L233.1,297.7 L235.2,296.4 L237.4,295.2 L239.6,293.9 L241.7,292.7 L243.9,291.4 L246.1,290.2 L248.3,289.0 L250.4,287.8 L252.6,286.6 L254.8,285.5 L257.0,284.4 L259.1,283.2 L261.3,282.1 L263.5,281.1 L265.6,280.0 L267.8,279.0 L270.0,277.9 L272.2,276.9 L274.3,275.9 L276.5,275.0 L278.7,274.0 L280.8,273.1 L283.0,272.2 L285.2,271.3 L287.4,270.4 L289.5,269.5 L291.7,268.7 L293.9,267.8 L296.1,267.0 L298.2,266.2 L300.4,265.4 L302.6,264.7 L304.7,263.9 L306.9,263.2 L309.1,262.5 L311.3,261.8 L313.4,261.1 L315.6,260.4 L317.8,259.7 L319.9,259.1 L322.1,258.4 L324.3,257.8 L326.5,257.2 L328.6,256.6 L330.8,256.0 L333.0,255.5 L335.2,254.9 L337.3,254.3 L339.5,253.8 L341.7,253.3 L343.8,252.8 L346.0,252.3 L348.2,251.8 L350.4,251.3 L352.5,250.8 L354.7,250.3 L356.9,249.9 L359.0,249.4 L361.2,249.0 L363.4,248.6 L365.6,248.2 L367.7,247.8 L369.9,247.4 L372.1,247.0 L374.3,246.6 L376.4,246.2 L378.6,245.8 L380.8,245.5 L382.9,245.1 L385.1,244.8 L387.3,244.4 L389.5,244.1 L391.6,243.8 L393.8,243.5 L396.0,243.2 L398.1,242.9 L400.3,242.6 L402.5,242.3 L404.7,242.0 L406.8,241.7 L409.0,241.4 L411.2,241.2 L413.4,240.9 L415.5,240.6 L417.7,240.4 L419.9,240.1 L422.0,239.9 L424.2,239.7 L426.4,239.4 L428.6,239.2 L430.7,239.0 L432.9,238.8 L435.1,238.5 L437.2,238.3 L439.4,238.1 L441.6,237.9 L443.8,237.7 L445.9,237.5 L448.1,237.3 L450.3,237.2 L452.5,237.0 L454.6,236.8 L456.8,236.6 L459.0,236.4 L461.1,236.3 L463.3,236.1 L465.5,235.9 L467.7,235.8 L469.8,235.6 L472.0,235.5 L474.2,235.3 L476.3,235.2 L478.5,235.0 L480.7,234.9 L482.9,234.8 L485.0,234.6 L487.2,234.5 L489.4,234.4 L491.6,234.2 L493.7,234.1 L495.9,234.0 L498.1,233.9 L500.2,233.7 L502.4,233.6 L504.6,233.5 L506.8,233.4 L508.9,233.3 L511.1,233.2 L513.3,233.1 L515.4,233.0 L517.6,232.9 L519.8,232.8 L522.0,232.7 L524.1,232.6 L526.3,232.5 L528.5,232.4 L530.7,232.3 L532.8,232.2 L535.0,232.1 \" stroke=\"rgb( 0, 0, 255)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_2a\"><title>gnuplot_plot_2a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M102.7,51.2 L107.7,92.0 L112.7,129.9 L117.7,164.8 L122.6,196.8 L127.6,225.7 L132.6,251.7 L137.6,274.8 L142.5,294.8 L147.5,311.9 L152.5,326.0 L157.5,337.2 L162.4,345.3 L167.4,350.5 L172.4,352.8 L177.4,352.0 L182.4,348.3 L187.3,341.6 L192.3,332.0 L197.3,319.3 \" stroke=\"rgb( 0, 128, 0)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_3a\"><title>gnuplot_plot_3a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(102.7,51.2) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(150.0,319.3) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(197.3,319.3) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_4a\"><title>gnuplot_plot_4a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(173.6,328.6) scale(9.00)\" xlink:href=\"#gpPt2\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_5a\"><title>gnuplot_plot_5a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M102.7,51.2 L150.0,319.3 \" stroke=\"rgb(191, 0, 191)\"/></g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb(191, 0, 191)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"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 f2<f1 && f2<f3\n",
" x4=x2-0.5*((x2-x1)^2*(f2-f3)-(x2-x3)^2*(f2-f1))/((x2-x1)...\n",
" *(f2-f3)-(x2-x3)*(f2-f1));\n",
" f4=Au_x(x4);\n",
"\n",
" if x4>x2\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": 24,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"62.2,384.0 534.9,384.0 534.9,16.8 62.2,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L74.7,384.0 M535.0,384.0 L522.5,384.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,390.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,322.8 L74.7,322.8 M535.0,322.8 L522.5,322.8 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,328.8)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,261.6 L74.7,261.6 M535.0,261.6 L522.5,261.6 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,267.6)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,200.3 L74.7,200.3 M535.0,200.3 L522.5,200.3 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,206.3)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,139.1 L74.7,139.1 M535.0,139.1 L522.5,139.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,145.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,77.9 L74.7,77.9 M535.0,77.9 L522.5,77.9 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,83.9)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.06</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L74.7,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.08</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L62.2,371.5 M62.2,16.7 L62.2,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(62.2,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">2.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M129.7,384.0 L129.7,371.5 M129.7,16.7 L129.7,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(129.7,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M197.3,384.0 L197.3,371.5 M197.3,16.7 L197.3,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(197.3,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M264.8,384.0 L264.8,371.5 M264.8,16.7 L264.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(264.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M332.4,384.0 L332.4,371.5 M332.4,16.7 L332.4,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(332.4,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M399.9,384.0 L399.9,371.5 M399.9,16.7 L399.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(399.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M467.5,384.0 L467.5,371.5 M467.5,16.7 L467.5,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(467.5,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,384.0 L535.0,371.5 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">6</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L62.2,384.0 L535.0,384.0 L535.0,16.7 L62.2,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M102.7,56.9 L104.9,91.1 L107.1,122.2 L109.2,150.4 L111.4,176.0 L113.6,199.2 L115.8,220.2 L117.9,239.1 L120.1,256.2 L122.3,271.7 L124.4,285.6 L126.6,298.1 L128.8,309.3 L131.0,319.3 L133.1,328.2 L135.3,336.1 L137.5,343.2 L139.7,349.4 L141.8,354.9 L144.0,359.7 L146.2,363.8 L148.3,367.4 L150.5,370.4 L152.7,373.0 L154.9,375.2 L157.0,376.9 L159.2,378.3 L161.4,379.4 L163.5,380.1 L165.7,380.6 L167.9,380.9 L170.1,380.9 L172.2,380.8 L174.4,380.4 L176.6,379.9 L178.8,379.3 L180.9,378.5 L183.1,377.6 L185.3,376.6 L187.4,375.5 L189.6,374.4 L191.8,373.1 L194.0,371.9 L196.1,370.5 L198.3,369.1 L200.5,367.7 L202.6,366.2 L204.8,364.7 L207.0,363.2 L209.2,361.7 L211.3,360.1 L213.5,358.5 L215.7,357.0 L217.9,355.4 L220.0,353.8 L222.2,352.3 L224.4,350.7 L226.5,349.2 L228.7,347.6 L230.9,346.1 L233.1,344.6 L235.2,343.1 L237.4,341.6 L239.6,340.1 L241.7,338.6 L243.9,337.2 L246.1,335.8 L248.3,334.4 L250.4,333.0 L252.6,331.6 L254.8,330.3 L257.0,329.0 L259.1,327.7 L261.3,326.4 L263.5,325.1 L265.6,323.9 L267.8,322.7 L270.0,321.5 L272.2,320.3 L274.3,319.1 L276.5,318.0 L278.7,316.9 L280.8,315.8 L283.0,314.7 L285.2,313.7 L287.4,312.7 L289.5,311.7 L291.7,310.7 L293.9,309.7 L296.1,308.7 L298.2,307.8 L300.4,306.9 L302.6,306.0 L304.7,305.1 L306.9,304.3 L309.1,303.4 L311.3,302.6 L313.4,301.8 L315.6,301.0 L317.8,300.2 L319.9,299.5 L322.1,298.7 L324.3,298.0 L326.5,297.3 L328.6,296.6 L330.8,295.9 L333.0,295.2 L335.2,294.6 L337.3,293.9 L339.5,293.3 L341.7,292.7 L343.8,292.1 L346.0,291.5 L348.2,290.9 L350.4,290.4 L352.5,289.8 L354.7,289.3 L356.9,288.8 L359.0,288.2 L361.2,287.7 L363.4,287.2 L365.6,286.7 L367.7,286.3 L369.9,285.8 L372.1,285.3 L374.3,284.9 L376.4,284.5 L378.6,284.0 L380.8,283.6 L382.9,283.2 L385.1,282.8 L387.3,282.4 L389.5,282.0 L391.6,281.6 L393.8,281.3 L396.0,280.9 L398.1,280.5 L400.3,280.2 L402.5,279.9 L404.7,279.5 L406.8,279.2 L409.0,278.9 L411.2,278.6 L413.4,278.3 L415.5,278.0 L417.7,277.7 L419.9,277.4 L422.0,277.1 L424.2,276.8 L426.4,276.5 L428.6,276.3 L430.7,276.0 L432.9,275.8 L435.1,275.5 L437.2,275.3 L439.4,275.0 L441.6,274.8 L443.8,274.6 L445.9,274.3 L448.1,274.1 L450.3,273.9 L452.5,273.7 L454.6,273.5 L456.8,273.3 L459.0,273.1 L461.1,272.9 L463.3,272.7 L465.5,272.5 L467.7,272.3 L469.8,272.1 L472.0,271.9 L474.2,271.8 L476.3,271.6 L478.5,271.4 L480.7,271.3 L482.9,271.1 L485.0,270.9 L487.2,270.8 L489.4,270.6 L491.6,270.5 L493.7,270.3 L495.9,270.2 L498.1,270.0 L500.2,269.9 L502.4,269.8 L504.6,269.6 L506.8,269.5 L508.9,269.4 L511.1,269.3 L513.3,269.1 L515.4,269.0 L517.6,268.9 L519.8,268.8 L522.0,268.7 L524.1,268.5 L526.3,268.4 L528.5,268.3 L530.7,268.2 L532.8,268.1 L535.0,268.0 \" stroke=\"rgb( 0, 0, 255)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_2a\"><title>gnuplot_plot_2a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M150.0,369.8 L152.5,371.9 L155.0,373.8 L157.5,375.5 L160.0,376.9 L162.4,378.1 L164.9,379.1 L167.4,379.8 L169.9,380.3 L172.4,380.5 L174.9,380.5 L177.4,380.3 L179.9,379.8 L182.4,379.1 L184.8,378.1 L187.3,376.9 L189.8,375.5 L192.3,373.8 L194.8,371.9 L197.3,369.8 \" stroke=\"rgb( 0, 128, 0)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_3a\"><title>gnuplot_plot_3a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(150.0,369.8) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(173.6,380.6) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(197.3,369.8) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_4a\"><title>gnuplot_plot_4a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(173.6,380.6) scale(9.00)\" xlink:href=\"#gpPt2\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_5a\"><title>gnuplot_plot_5a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M197.3,369.8 L173.6,380.6 \" stroke=\"rgb(191, 0, 191)\"/></g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb(191, 0, 191)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"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 f2<f1 && f2<f3\n",
" x4=x2-0.5*((x2-x1)^2*(f2-f3)-(x2-x3)^2*(f2-f1))/((x2-x1)...\n",
" *(f2-f3)-(x2-x3)*(f2-f1));\n",
" f4=Au_x(x4);\n",
"\n",
" if x4>x2\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": 25,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"62.2,384.0 534.9,384.0 534.9,16.8 62.2,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L74.7,384.0 M535.0,384.0 L522.5,384.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,390.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,322.8 L74.7,322.8 M535.0,322.8 L522.5,322.8 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,328.8)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,261.6 L74.7,261.6 M535.0,261.6 L522.5,261.6 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,267.6)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,200.3 L74.7,200.3 M535.0,200.3 L522.5,200.3 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,206.3)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,139.1 L74.7,139.1 M535.0,139.1 L522.5,139.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,145.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,77.9 L74.7,77.9 M535.0,77.9 L522.5,77.9 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,83.9)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.06</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L74.7,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(53.9,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.08</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,384.0 L62.2,371.5 M62.2,16.7 L62.2,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(62.2,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">2.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M129.7,384.0 L129.7,371.5 M129.7,16.7 L129.7,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(129.7,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M197.3,384.0 L197.3,371.5 M197.3,16.7 L197.3,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(197.3,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">3.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M264.8,384.0 L264.8,371.5 M264.8,16.7 L264.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(264.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M332.4,384.0 L332.4,371.5 M332.4,16.7 L332.4,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(332.4,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">4.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M399.9,384.0 L399.9,371.5 M399.9,16.7 L399.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(399.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M467.5,384.0 L467.5,371.5 M467.5,16.7 L467.5,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(467.5,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">5.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,384.0 L535.0,371.5 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">6</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M62.2,16.7 L62.2,384.0 L535.0,384.0 L535.0,16.7 L62.2,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M102.7,56.9 L104.9,91.1 L107.1,122.2 L109.2,150.4 L111.4,176.0 L113.6,199.2 L115.8,220.2 L117.9,239.1 L120.1,256.2 L122.3,271.7 L124.4,285.6 L126.6,298.1 L128.8,309.3 L131.0,319.3 L133.1,328.2 L135.3,336.1 L137.5,343.2 L139.7,349.4 L141.8,354.9 L144.0,359.7 L146.2,363.8 L148.3,367.4 L150.5,370.4 L152.7,373.0 L154.9,375.2 L157.0,376.9 L159.2,378.3 L161.4,379.4 L163.5,380.1 L165.7,380.6 L167.9,380.9 L170.1,380.9 L172.2,380.8 L174.4,380.4 L176.6,379.9 L178.8,379.3 L180.9,378.5 L183.1,377.6 L185.3,376.6 L187.4,375.5 L189.6,374.4 L191.8,373.1 L194.0,371.9 L196.1,370.5 L198.3,369.1 L200.5,367.7 L202.6,366.2 L204.8,364.7 L207.0,363.2 L209.2,361.7 L211.3,360.1 L213.5,358.5 L215.7,357.0 L217.9,355.4 L220.0,353.8 L222.2,352.3 L224.4,350.7 L226.5,349.2 L228.7,347.6 L230.9,346.1 L233.1,344.6 L235.2,343.1 L237.4,341.6 L239.6,340.1 L241.7,338.6 L243.9,337.2 L246.1,335.8 L248.3,334.4 L250.4,333.0 L252.6,331.6 L254.8,330.3 L257.0,329.0 L259.1,327.7 L261.3,326.4 L263.5,325.1 L265.6,323.9 L267.8,322.7 L270.0,321.5 L272.2,320.3 L274.3,319.1 L276.5,318.0 L278.7,316.9 L280.8,315.8 L283.0,314.7 L285.2,313.7 L287.4,312.7 L289.5,311.7 L291.7,310.7 L293.9,309.7 L296.1,308.7 L298.2,307.8 L300.4,306.9 L302.6,306.0 L304.7,305.1 L306.9,304.3 L309.1,303.4 L311.3,302.6 L313.4,301.8 L315.6,301.0 L317.8,300.2 L319.9,299.5 L322.1,298.7 L324.3,298.0 L326.5,297.3 L328.6,296.6 L330.8,295.9 L333.0,295.2 L335.2,294.6 L337.3,293.9 L339.5,293.3 L341.7,292.7 L343.8,292.1 L346.0,291.5 L348.2,290.9 L350.4,290.4 L352.5,289.8 L354.7,289.3 L356.9,288.8 L359.0,288.2 L361.2,287.7 L363.4,287.2 L365.6,286.7 L367.7,286.3 L369.9,285.8 L372.1,285.3 L374.3,284.9 L376.4,284.5 L378.6,284.0 L380.8,283.6 L382.9,283.2 L385.1,282.8 L387.3,282.4 L389.5,282.0 L391.6,281.6 L393.8,281.3 L396.0,280.9 L398.1,280.5 L400.3,280.2 L402.5,279.9 L404.7,279.5 L406.8,279.2 L409.0,278.9 L411.2,278.6 L413.4,278.3 L415.5,278.0 L417.7,277.7 L419.9,277.4 L422.0,277.1 L424.2,276.8 L426.4,276.5 L428.6,276.3 L430.7,276.0 L432.9,275.8 L435.1,275.5 L437.2,275.3 L439.4,275.0 L441.6,274.8 L443.8,274.6 L445.9,274.3 L448.1,274.1 L450.3,273.9 L452.5,273.7 L454.6,273.5 L456.8,273.3 L459.0,273.1 L461.1,272.9 L463.3,272.7 L465.5,272.5 L467.7,272.3 L469.8,272.1 L472.0,271.9 L474.2,271.8 L476.3,271.6 L478.5,271.4 L480.7,271.3 L482.9,271.1 L485.0,270.9 L487.2,270.8 L489.4,270.6 L491.6,270.5 L493.7,270.3 L495.9,270.2 L498.1,270.0 L500.2,269.9 L502.4,269.8 L504.6,269.6 L506.8,269.5 L508.9,269.4 L511.1,269.3 L513.3,269.1 L515.4,269.0 L517.6,268.9 L519.8,268.8 L522.0,268.7 L524.1,268.5 L526.3,268.4 L528.5,268.3 L530.7,268.2 L532.8,268.1 L535.0,268.0 \" stroke=\"rgb( 0, 0, 255)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_2a\"><title>gnuplot_plot_2a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M150.0,369.8 L151.2,371.1 L152.5,372.3 L153.7,373.4 L155.0,374.5 L156.2,375.5 L157.5,376.4 L158.7,377.2 L160.0,377.9 L161.2,378.6 L162.4,379.1 L163.7,379.6 L164.9,380.0 L166.2,380.3 L167.4,380.6 L168.7,380.7 L169.9,380.8 L171.2,380.8 L172.4,380.7 L173.6,380.6 \" stroke=\"rgb( 0, 128, 0)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_3a\"><title>gnuplot_plot_3a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(150.0,369.8) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(173.6,380.6) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb(255, 0, 0)\" transform=\"translate(173.6,380.6) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_4a\"><title>gnuplot_plot_4a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(170.5,380.9) scale(9.00)\" xlink:href=\"#gpPt2\"/></g>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_5a\"><title>gnuplot_plot_5a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M173.6,380.6 \" stroke=\"rgb(191, 0, 191)\"/></g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb(191, 0, 191)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"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 f2<f1 && f2<f3\n",
" x4=x2-0.5*((x2-x1)^2*(f2-f3)-(x2-x3)^2*(f2-f1))/((x2-x1)...\n",
" *(f2-f3)-(x2-x3)*(f2-f1));\n",
" f4=Au_x(x4);\n",
"\n",
" if x4>x2\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$\n",
"\n",
"$1 aJ = 10^{-18} J = 1~nN* 1~nm = 10^{-9}N * 10^{-9} m$"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"warning: Matlab-style short-circuit operation performed for operator |\n",
"warning: called from\n",
" goldmin at line 17 column 1\n",
"warning: Matlab-style short-circuit operation performed for operator |\n",
"warning: Matlab-style short-circuit operation performed for operator |\n",
"xmin = 0.32933\n",
"Emin = -2.7096e-04\n"
]
},
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"96.8,362.4 534.9,362.4 534.9,16.8 96.8,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M96.8,362.4 L109.3,362.4 M535.0,362.4 L522.5,362.4 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(88.5,368.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.0004</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M96.8,293.3 L109.3,293.3 M535.0,293.3 L522.5,293.3 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(88.5,299.3)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.0002</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M96.8,224.1 L109.3,224.1 M535.0,224.1 L522.5,224.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(88.5,230.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M96.8,155.0 L109.3,155.0 M535.0,155.0 L522.5,155.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(88.5,161.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0002</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M96.8,85.8 L109.3,85.8 M535.0,85.8 L522.5,85.8 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(88.5,91.8)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0004</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M96.8,16.7 L109.3,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(88.5,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0006</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M96.8,362.4 L96.8,349.9 M96.8,16.7 L96.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(96.8,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.2</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M184.4,362.4 L184.4,349.9 M184.4,16.7 L184.4,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(184.4,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.3</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M272.1,362.4 L272.1,349.9 M272.1,16.7 L272.1,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(272.1,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.4</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M359.7,362.4 L359.7,349.9 M359.7,16.7 L359.7,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(359.7,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.5</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M447.4,362.4 L447.4,349.9 M447.4,16.7 L447.4,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(447.4,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.6</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,362.4 L535.0,349.9 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.7</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M96.8,16.7 L96.8,362.4 L535.0,362.4 L535.0,16.7 L96.8,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(19.1,189.6) rotate(-90)\">\n",
"\t\t<text><tspan font-family=\"{}\">Lennard Jones Potential (aJ/atom)</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(315.9,413.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">bond length (nm)</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M166.9,63.5 L168.3,90.4 L169.7,114.8 L171.1,136.9 L172.5,157.0 L174.0,175.2 L175.4,191.6 L176.8,206.5 L178.2,219.9 L179.6,232.1 L181.0,243.0 L182.4,252.8 L183.8,261.5 L185.2,269.4 L186.6,276.4 L188.1,282.6 L189.5,288.2 L190.9,293.1 L192.3,297.3 L193.7,301.1 L195.1,304.3 L196.5,307.2 L197.9,309.5 L199.3,311.6 L200.7,313.3 L202.1,314.6 L203.6,315.7 L205.0,316.6 L206.4,317.2 L207.8,317.6 L209.2,317.8 L210.6,317.8 L212.0,317.7 L213.4,317.4 L214.8,317.0 L216.2,316.5 L217.6,315.9 L219.1,315.2 L220.5,314.4 L221.9,313.6 L223.3,312.6 L224.7,311.7 L226.1,310.7 L227.5,309.6 L228.9,308.5 L230.3,307.4 L231.7,306.2 L233.1,305.1 L234.6,303.9 L236.0,302.7 L237.4,301.4 L238.8,300.2 L240.2,299.0 L241.6,297.8 L243.0,296.5 L244.4,295.3 L245.8,294.1 L247.2,292.9 L248.7,291.6 L250.1,290.4 L251.5,289.3 L252.9,288.1 L254.3,286.9 L255.7,285.7 L257.1,284.6 L258.5,283.5 L259.9,282.4 L261.3,281.3 L262.7,280.2 L264.2,279.1 L265.6,278.0 L267.0,277.0 L268.4,276.0 L269.8,275.0 L271.2,274.0 L272.6,273.0 L274.0,272.1 L275.4,271.1 L276.8,270.2 L278.2,269.3 L279.7,268.4 L281.1,267.5 L282.5,266.7 L283.9,265.9 L285.3,265.0 L286.7,264.2 L288.1,263.4 L289.5,262.7 L290.9,261.9 L292.3,261.1 L293.7,260.4 L295.2,259.7 L296.6,259.0 L298.0,258.3 L299.4,257.6 L300.8,257.0 L302.2,256.3 L303.6,255.7 L305.0,255.1 L306.4,254.5 L307.8,253.9 L309.2,253.3 L310.7,252.7 L312.1,252.2 L313.5,251.6 L314.9,251.1 L316.3,250.5 L317.7,250.0 L319.1,249.5 L320.5,249.0 L321.9,248.6 L323.3,248.1 L324.8,247.6 L326.2,247.2 L327.6,246.7 L329.0,246.3 L330.4,245.9 L331.8,245.5 L333.2,245.0 L334.6,244.6 L336.0,244.3 L337.4,243.9 L338.8,243.5 L340.3,243.1 L341.7,242.8 L343.1,242.4 L344.5,242.1 L345.9,241.7 L347.3,241.4 L348.7,241.1 L350.1,240.8 L351.5,240.5 L352.9,240.2 L354.3,239.9 L355.8,239.6 L357.2,239.3 L358.6,239.0 L360.0,238.7 L361.4,238.5 L362.8,238.2 L364.2,238.0 L365.6,237.7 L367.0,237.5 L368.4,237.2 L369.8,237.0 L371.3,236.8 L372.7,236.5 L374.1,236.3 L375.5,236.1 L376.9,235.9 L378.3,235.7 L379.7,235.5 L381.1,235.3 L382.5,235.1 L383.9,234.9 L385.4,234.7 L386.8,234.5 L388.2,234.3 L389.6,234.1 L391.0,234.0 L392.4,233.8 L393.8,233.6 L395.2,233.5 L396.6,233.3 L398.0,233.1 L399.4,233.0 L400.9,232.8 L402.3,232.7 L403.7,232.5 L405.1,232.4 L406.5,232.3 L407.9,232.1 L409.3,232.0 L410.7,231.9 L412.1,231.7 L413.5,231.6 L414.9,231.5 L416.4,231.4 L417.8,231.2 L419.2,231.1 L420.6,231.0 L422.0,230.9 L423.4,230.8 L424.8,230.7 L426.2,230.6 L427.6,230.5 L429.0,230.4 L430.4,230.2 L431.9,230.2 L433.3,230.1 L434.7,230.0 L436.1,229.9 L437.5,229.8 L438.9,229.7 L440.3,229.6 L441.7,229.5 L443.1,229.4 L444.5,229.3 L446.0,229.3 L447.4,229.2 \" stroke=\"rgb( 0, 0, 255)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_2a\"><title>gnuplot_plot_2a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 128, 0)\" transform=\"translate(210.1,317.8) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"</g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb( 0, 128, 0)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"epsilon = 0.039; % kcal/mol\n",
"epsilon = epsilon*6.9477e-21; % J/atom\n",
"epsilon = epsilon*1e18; % aJ/J\n",
"% final units for epsilon are aJ\n",
"\n",
"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",
"ylabel('Lennard Jones Potential (aJ/atom)')\n",
"xlabel('bond length (nm)')\n",
"\n",
"Etotal = @(dx,F) lennard_jones(xmin+dx,sigma,epsilon)-F.*dx;\n"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"88.5,362.4 534.9,362.4 534.9,16.8 88.5,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M88.5,362.4 L101.0,362.4 M535.0,362.4 L522.5,362.4 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(80.2,368.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M88.5,293.3 L101.0,293.3 M535.0,293.3 L522.5,293.3 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(80.2,299.3)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0005</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M88.5,224.1 L101.0,224.1 M535.0,224.1 L522.5,224.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(80.2,230.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.001</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M88.5,155.0 L101.0,155.0 M535.0,155.0 L522.5,155.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(80.2,161.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0015</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M88.5,85.8 L101.0,85.8 M535.0,85.8 L522.5,85.8 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(80.2,91.8)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.002</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M88.5,16.7 L101.0,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(80.2,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0025</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M88.5,362.4 L88.5,349.9 M88.5,16.7 L88.5,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(88.5,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M144.3,362.4 L144.3,349.9 M144.3,16.7 L144.3,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(144.3,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.005</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M200.1,362.4 L200.1,349.9 M200.1,16.7 L200.1,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(200.1,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.01</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M255.9,362.4 L255.9,349.9 M255.9,16.7 L255.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(255.9,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.015</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M311.8,362.4 L311.8,349.9 M311.8,16.7 L311.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(311.8,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M367.6,362.4 L367.6,349.9 M367.6,16.7 L367.6,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(367.6,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.025</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M423.4,362.4 L423.4,349.9 M423.4,16.7 L423.4,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(423.4,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.03</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M479.2,362.4 L479.2,349.9 M479.2,16.7 L479.2,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(479.2,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.035</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,362.4 L535.0,349.9 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,386.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M88.5,16.7 L88.5,362.4 L535.0,362.4 L535.0,16.7 L88.5,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(19.1,189.6) rotate(-90)\">\n",
"\t\t<text><tspan font-family=\"{}\">Force (nN)</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(311.7,413.4)\">\n",
"\t\t<text><tspan font-family=\"{}\">dx (nm)</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M88.5,362.4 L91.3,356.2 L94.2,350.0 L97.1,343.8 L100.0,337.6 L103.0,331.4 L106.1,325.1 L109.2,318.9 L112.4,312.7 L115.6,306.5 L118.9,300.3 L122.2,294.1 L125.7,287.9 L129.1,281.7 L132.7,275.5 L136.4,269.3 L140.1,263.1 L143.9,256.9 L147.8,250.6 L151.8,244.4 L155.9,238.2 L160.1,232.0 L164.4,225.8 L168.9,219.6 L173.4,213.4 L178.1,207.2 L183.0,201.0 L188.0,194.8 L193.1,188.6 L198.5,182.4 L204.0,176.1 L209.8,169.9 L215.7,163.7 L222.0,157.5 L228.5,151.3 L235.3,145.1 L242.4,138.9 L250.0,132.7 L257.9,126.5 L266.4,120.3 L275.4,114.1 L285.2,107.9 L295.7,101.6 L307.3,95.4 L320.1,89.2 L334.5,83.0 L351.3,76.8 L371.6,70.6 L398.3,64.4 L443.4,58.2 \" stroke=\"rgb( 0, 0, 255)\"/></g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb( 0, 0, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"N=50;\n",
"warning('off')\n",
"dx = zeros(1,N); % [in nm]\n",
"F_applied=linspace(0,0.0022,N); % [in nN]\n",
"for i=1:N\n",
" optmin=goldmin(@(dx) Etotal(dx,F_applied(i)),-0.001,0.035);\n",
" dx(i)=optmin;\n",
"end\n",
"\n",
"plot(dx,F_applied)\n",
"xlabel('dx (nm)')\n",
"ylabel('Force (nN)')"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"For this function, it is possible to take a derivative and compare the analytical result:\n",
"\n",
"dE/dx = 0 = d(E_LJ)/dx - F\n",
"\n",
"F= d(E_LJ)/dx"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"F =\n",
"\n",
"@(dx) 4 * epsilon * 6 * (sigma ^ 6 ./ (xmin + dx) .^ 7 - 2 * sigma ^ 12 ./ (xmin + dx) .^ 13)\n",
"\n"
]
},
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"78.8,384.0 534.9,384.0 534.9,16.8 78.8,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M78.8,384.0 L91.3,384.0 M535.0,384.0 L522.5,384.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(70.5,390.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">-0.0005</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M78.8,322.8 L91.3,322.8 M535.0,322.8 L522.5,322.8 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(70.5,328.8)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M78.8,261.6 L91.3,261.6 M535.0,261.6 L522.5,261.6 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(70.5,267.6)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0005</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M78.8,200.3 L91.3,200.3 M535.0,200.3 L522.5,200.3 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(70.5,206.3)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.001</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M78.8,139.1 L91.3,139.1 M535.0,139.1 L522.5,139.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(70.5,145.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0015</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M78.8,77.9 L91.3,77.9 M535.0,77.9 L522.5,77.9 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(70.5,83.9)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.002</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M78.8,16.7 L91.3,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(70.5,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0025</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M78.8,384.0 L78.8,371.5 M78.8,16.7 L78.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(78.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M154.8,384.0 L154.8,371.5 M154.8,16.7 L154.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(154.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.01</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M230.9,384.0 L230.9,371.5 M230.9,16.7 L230.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(230.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M306.9,384.0 L306.9,371.5 M306.9,16.7 L306.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(306.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.03</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M382.9,384.0 L382.9,371.5 M382.9,16.7 L382.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(382.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M459.0,384.0 L459.0,371.5 M459.0,16.7 L459.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(459.0,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.05</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,384.0 L535.0,371.5 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.06</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M78.8,16.7 L78.8,384.0 L535.0,384.0 L535.0,16.7 L78.8,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M78.8,322.8 L88.1,296.8 L97.4,272.9 L106.7,250.8 L116.0,230.4 L125.4,211.6 L134.7,194.4 L144.0,178.5 L153.3,164.0 L162.6,150.7 L171.9,138.6 L181.2,127.6 L190.5,117.6 L199.8,108.5 L209.1,100.4 L218.5,93.0 L227.8,86.4 L237.1,80.6 L246.4,75.4 L255.7,70.9 L265.0,66.9 L274.3,63.5 L283.6,60.6 L292.9,58.2 L302.2,56.2 L311.6,54.6 L320.9,53.4 L330.2,52.6 L339.5,52.0 L348.8,51.8 L358.1,51.9 L367.4,52.2 L376.7,52.8 L386.0,53.6 L395.3,54.6 L404.7,55.8 L414.0,57.2 L423.3,58.7 L432.6,60.4 L441.9,62.2 L451.2,64.1 L460.5,66.2 L469.8,68.3 L479.1,70.5 L488.4,72.9 L497.8,75.3 L507.1,77.7 L516.4,80.2 L525.7,82.8 L535.0,85.4 \" stroke=\"rgb( 0, 0, 255)\"/></g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_2a\"><title>gnuplot_plot_2a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M78.8,322.8 L80.7,317.3 L82.7,311.8 L84.6,306.3 L86.6,300.8 L88.7,295.3 L90.8,289.8 L92.9,284.3 L95.0,278.8 L97.2,273.3 L99.5,267.8 L101.8,262.3 L104.1,256.8 L106.5,251.3 L108.9,245.8 L111.4,240.3 L113.9,234.8 L116.5,229.3 L119.2,223.8 L121.9,218.3 L124.7,212.8 L127.6,207.3 L130.5,201.8 L133.5,196.4 L136.6,190.9 L139.8,185.4 L143.1,179.9 L146.6,174.4 L150.1,168.9 L153.7,163.4 L157.5,157.9 L161.4,152.4 L165.5,146.9 L169.7,141.4 L174.1,135.9 L178.8,130.4 L183.6,124.9 L188.8,119.4 L194.2,113.9 L200.0,108.4 L206.1,102.9 L212.8,97.4 L219.9,91.9 L227.8,86.4 L236.5,80.9 L246.4,75.4 L257.8,69.9 L271.6,64.4 L289.8,58.9 L320.5,53.4 \" stroke=\"rgb( 0, 128, 0)\"/></g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb( 0, 128, 0)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"dx_full=linspace(0,0.06,50);\n",
"F= @(dx) 4*epsilon*6*(sigma^6./(xmin+dx).^7-2*sigma^12./(xmin+dx).^13)\n",
"plot(dx_full,F(dx_full),dx,F_applied)"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"## Curve-fitting\n",
"Another example is minimizing error in your approximation of a function. If you have data (now we have Force-displacement data) we can fit this to a function, such as:\n",
"\n",
"$F(x) = K_{1}\\Delta x + \\frac{1}{2} K_{2}(\\Delta x)^{2}$\n"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"function SSE = sse_of_parabola(K,xdata,ydata)\n",
" % calculate the sum of squares error for a parabola given a function, func, and xdata and ydata\n",
" % output is SSE=sum of squares error\n",
" K1=K(1);\n",
" K2=K(2);\n",
" y_function = K1*xdata+1/2*K2*xdata.^2;\n",
" SSE = sum((ydata-y_function).^2);\n",
"end\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"The nonlinear spring constants are K1=0.16 nN/nm and K2=-5.98 nN/nm^2\n",
"The mininum sum of squares error = 7.35e-08\n"
]
}
],
"source": [
"[K,SSE_min]=fminsearch(@(K) sse_of_parabola(K,dx,F_applied),[1,1]);\n",
"fprintf('\\nThe nonlinear spring constants are K1=%1.2f nN/nm and K2=%1.2f nN/nm^2\\n',K)\n",
"fprintf('The mininum sum of squares error = %1.2e',SSE_min)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"image/svg+xml": [
"<svg height=\"420px\" viewBox=\"0 0 560 420\" width=\"560px\" xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\">\n",
"\n",
"<title>Gnuplot</title>\n",
"<desc>Produced by GNUPLOT 5.0 patchlevel 3 </desc>\n",
"\n",
"<g id=\"gnuplot_canvas\">\n",
"\n",
"<rect fill=\"none\" height=\"420\" width=\"560\" x=\"0\" y=\"0\"/>\n",
"<defs>\n",
"\n",
"\t<circle id=\"gpDot\" r=\"0.5\" stroke-width=\"0.5\"/>\n",
"\t<path d=\"M-1,0 h2 M0,-1 v2\" id=\"gpPt0\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,-1 L1,1 M1,-1 L-1,1\" id=\"gpPt1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<path d=\"M-1,0 L1,0 M0,-1 L0,1 M-1,-1 L1,1 M-1,1 L1,-1\" id=\"gpPt2\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<rect height=\"2\" id=\"gpPt3\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<rect fill=\"currentColor\" height=\"2\" id=\"gpPt4\" stroke=\"currentColor\" stroke-width=\"0.222\" width=\"2\" x=\"-1\" y=\"-1\"/>\n",
"\t<circle cx=\"0\" cy=\"0\" id=\"gpPt5\" r=\"1\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt6\" stroke=\"none\" xlink:href=\"#gpPt5\"/>\n",
"\t<path d=\"M0,-1.33 L-1.33,0.67 L1.33,0.67 z\" id=\"gpPt7\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt8\" stroke=\"none\" xlink:href=\"#gpPt7\"/>\n",
"\t<use id=\"gpPt9\" stroke=\"currentColor\" transform=\"rotate(180)\" xlink:href=\"#gpPt7\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt10\" stroke=\"none\" xlink:href=\"#gpPt9\"/>\n",
"\t<use id=\"gpPt11\" stroke=\"currentColor\" transform=\"rotate(45)\" xlink:href=\"#gpPt3\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt12\" stroke=\"none\" xlink:href=\"#gpPt11\"/>\n",
"\t<path d=\"M0,1.330 L1.265,0.411 L0.782,-1.067 L-0.782,-1.076 L-1.265,0.411 z\" id=\"gpPt13\" stroke=\"currentColor\" stroke-width=\"0.222\"/>\n",
"\t<use fill=\"currentColor\" id=\"gpPt14\" stroke=\"none\" xlink:href=\"#gpPt13\"/>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"textbox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"white\" flood-opacity=\"1\" result=\"bgnd\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"bgnd\" operator=\"atop\"/>\n",
"\t</filter>\n",
"\t<filter filterUnits=\"objectBoundingBox\" height=\"1\" id=\"greybox\" width=\"1\" x=\"0\" y=\"0\">\n",
"\t <feFlood flood-color=\"lightgrey\" flood-opacity=\"1\" result=\"grey\"/>\n",
"\t <feComposite in=\"SourceGraphic\" in2=\"grey\" operator=\"atop\"/>\n",
"\t</filter>\n",
"</defs>\n",
"<g color=\"white\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"1.00\">\n",
"\t<g shape-rendering=\"crispEdges\" stroke=\"none\">\n",
"\t\t<polygon fill=\"rgb(255, 255, 255)\" points=\"70.5,384.0 534.9,384.0 534.9,16.8 70.5,16.8 \"/>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"rgb(255, 255, 255)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M70.5,384.0 L83.0,384.0 M535.0,384.0 L522.5,384.0 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(62.2,390.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M70.5,310.5 L83.0,310.5 M535.0,310.5 L522.5,310.5 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(62.2,316.5)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0005</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M70.5,237.1 L83.0,237.1 M535.0,237.1 L522.5,237.1 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(62.2,243.1)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.001</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M70.5,163.6 L83.0,163.6 M535.0,163.6 L522.5,163.6 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(62.2,169.6)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0015</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M70.5,90.2 L83.0,90.2 M535.0,90.2 L522.5,90.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(62.2,96.2)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.002</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M70.5,16.7 L83.0,16.7 M535.0,16.7 L522.5,16.7 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"end\" transform=\"translate(62.2,22.7)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.0025</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M70.5,384.0 L70.5,371.5 M70.5,16.7 L70.5,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(70.5,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M128.6,384.0 L128.6,371.5 M128.6,16.7 L128.6,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(128.6,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.005</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M186.6,384.0 L186.6,371.5 M186.6,16.7 L186.6,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(186.6,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.01</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M244.7,384.0 L244.7,371.5 M244.7,16.7 L244.7,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(244.7,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.015</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M302.8,384.0 L302.8,371.5 M302.8,16.7 L302.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(302.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.02</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M360.8,384.0 L360.8,371.5 M360.8,16.7 L360.8,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(360.8,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.025</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M418.9,384.0 L418.9,371.5 M418.9,16.7 L418.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(418.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.03</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M476.9,384.0 L476.9,371.5 M476.9,16.7 L476.9,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(476.9,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.035</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M535.0,384.0 L535.0,371.5 M535.0,16.7 L535.0,29.2 \" stroke=\"black\"/>\t<g fill=\"rgb(0,0,0)\" font-family=\"{}\" font-size=\"16.00\" stroke=\"none\" text-anchor=\"middle\" transform=\"translate(535.0,408.0)\">\n",
"\t\t<text><tspan font-family=\"{}\">0.04</tspan></text>\n",
"\t</g>\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"\t<path d=\"M70.5,16.7 L70.5,384.0 L535.0,384.0 L535.0,16.7 L70.5,16.7 Z \" stroke=\"black\"/></g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"\t<g id=\"gnuplot_plot_1a\"><title>gnuplot_plot_1a</title>\n",
"<g color=\"white\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<g onmousemove=\"gnuplot_svg.showHypertext(evt,'')\" onmouseout=\"gnuplot_svg.hideHypertext()\"><title> </title>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(70.5,384.0) scale(9.00)\" xlink:href=\"#gpPt5\"/></g>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(73.4,377.4) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(76.4,370.8) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(79.4,364.2) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(82.5,357.6) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(85.6,351.0) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(88.8,344.4) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(92.0,337.8) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(95.3,331.2) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(98.7,324.6) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(102.1,318.0) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(105.6,311.4) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(109.2,304.8) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(112.8,298.2) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(116.5,291.7) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(120.3,285.1) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(124.2,278.5) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(128.1,271.9) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(132.2,265.3) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(136.4,258.7) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(140.6,252.1) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(145.0,245.5) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(149.5,238.9) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(154.1,232.3) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(158.9,225.7) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(163.7,219.1) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(168.8,212.5) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(174.0,205.9) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(179.3,199.3) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(184.9,192.7) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(190.7,186.1) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(196.6,179.5) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(202.9,172.9) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(209.3,166.3) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(216.1,159.7) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(223.2,153.1) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(230.6,146.5) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(238.5,139.9) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(246.8,133.3) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(255.6,126.7) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(265.0,120.1) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(275.1,113.5) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(286.1,107.0) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(298.1,100.4) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(311.4,93.8) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(326.4,87.2) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(343.9,80.6) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(365.0,74.0) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(392.8,67.4) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"\t<use color=\"rgb( 0, 0, 255)\" transform=\"translate(439.7,60.8) scale(9.00)\" xlink:href=\"#gpPt5\"/>\n",
"</g>\n",
"\t</g>\n",
"\t<g id=\"gnuplot_plot_2a\"><title>gnuplot_plot_2a</title>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"3.00\">\n",
"\t<path d=\"M70.5,384.0 L73.4,378.1 L76.4,372.2 L79.4,366.2 L82.5,360.2 L85.6,354.2 L88.8,348.1 L92.0,342.0 L95.3,335.8 L98.7,329.6 L102.1,323.3 L105.6,317.0 L109.2,310.7 L112.8,304.3 L116.5,297.8 L120.3,291.3 L124.2,284.8 L128.1,278.2 L132.2,271.6 L136.4,264.9 L140.6,258.1 L145.0,251.4 L149.5,244.5 L154.1,237.6 L158.9,230.7 L163.7,223.7 L168.8,216.6 L174.0,209.5 L179.3,202.4 L184.9,195.2 L190.7,187.9 L196.6,180.6 L202.9,173.3 L209.3,165.9 L216.1,158.5 L223.2,151.0 L230.6,143.6 L238.5,136.1 L246.8,128.6 L255.6,121.1 L265.0,113.7 L275.1,106.4 L286.1,99.2 L298.1,92.3 L311.4,85.7 L326.4,79.6 L343.9,74.3 L365.0,70.7 L392.8,70.3 L439.7,81.1 \" stroke=\"rgb( 0, 128, 0)\"/></g>\n",
"\t</g>\n",
"<g color=\"white\" fill=\"none\" stroke=\"rgb( 0, 128, 0)\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"2.00\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"black\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"<g color=\"black\" fill=\"none\" stroke=\"currentColor\" stroke-linecap=\"butt\" stroke-linejoin=\"miter\" stroke-width=\"0.50\">\n",
"</g>\n",
"</g>\n",
"</svg>"
],
"text/plain": [
"<IPython.core.display.SVG object>"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"plot(dx,F_applied,'o',dx,K(1)*dx+1/2*K(2)*dx.^2)"
]
},
{
"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
}