Skip to content

Instantly share code, notes, and snippets.

@Davidnet
Created February 10, 2017 14:32
Show Gist options
  • Save Davidnet/4d691735b9252d258ddc9fc03ec86087 to your computer and use it in GitHub Desktop.
Save Davidnet/4d691735b9252d258ddc9fc03ec86087 to your computer and use it in GitHub Desktop.
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tarea 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Punto 1\n",
"Escriba una fórmula que involucre $a,b$ y $\\epsilon$ para calcular el número de iteraciones necesarias para garantizar que el método de la bisección tenga un error menor a $\\epsilon$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Solución\n",
"Tenemos la siguiente relación:\n",
"$$\n",
"| r - c_n | \\leq 2^{-(n+1)}(b - a) \\\\\n",
"\\epsilon \\leq 2^{-(n+1)}(b - a) \\leq 2^{-n} (b-a)\\\\\n",
"\\frac{\\epsilon}{b-a} \\leq 2^{-n} \\\\\n",
"n \\geq \\log_2 \\frac{ b - a } {\\epsilon}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"# Punto 2\n",
"Sea $ f \\in C^{m+1}([a,b])$ y $r$ una raíz de multiplicidad $m > 1$. Muestre que en este caso el método de Newton tiene órden de convergencia lineal y además:\n",
"\n",
"$$\n",
"\\lim_{n \\rightarrow \\infty} \\frac{ | e_{n+1} | }{ | e_n | } = \\frac{m-1}{m} . \n",
"$$\n",
"\n",
"Mostramos ahora que\n",
"\n",
"$$\n",
"\\lim_{n \\rightarrow \\infty} \\frac{ | e_{n+1} | }{ | e_n | } = \\frac{m-1}{m} . \n",
"$$\n",
"\n",
"Observamos que $ e_{n+1} = x_{n+1} - r $\n",
"Es decir que:\n",
"$$\n",
"e_{n+1} = x_n - \\frac{(x-r)^m g(x) }{ m (x-r)^{m-1}g(x) + (x-r)^m g'(x) } - r\n",
"$$\n",
"Tomando la razon de $e_{n}$, tenemos $x=x_n$\n",
"$$\n",
"\\frac{ e_{n+1} }{e_n} = \\frac{ e_n - \\frac{(x-r)^m g(x) }{ m (x-r)^{m-1}g(x) + (x-r)^m g'(x) }}{e_n} \\\\\n",
"\\frac{ e_{n+1} }{e_n} = 1 - \\frac{(x-r)^m g(x) }{ e_n(m (x-r)^{m-1}g(x) + (x-r)^m g'(x)) } \\\\\n",
"\\frac{ e_{n+1} }{e_n} = 1 - \\frac{(x-r)g(x)}{(x-r)(mg(x) + (x-r)g'(x)} \\\\\n",
"\\frac{ e_{n+1} }{e_n} = 1 - \\frac{ g(x_n) }{mg(x_n) + (x_n -r)g'(x_n)}\n",
"$$\n",
"Tomando el límite\n",
"$$\n",
"\\lim_{n \\rightarrow \\infty} 1 - \\frac{ g(x_n) }{mg(x_n) + (x_n -r)g'(x_n)} \\\\\n",
"\\lim_{n \\rightarrow \\infty} 1 - \\frac{g(x_n)}{mg(x_n)} \\\\\n",
"\\lim_{n \\rightarrow \\infty} 1 - \\frac{1}{m} \\\\\n",
"\\frac{m-1}{m}\n",
"$$\n",
"Como el límite para $m>1$ es mas pequeño que $1$ concluimos que la convergencia es lineal.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Punto 3\n",
"\n",
"Condiciones para que Newton-Raphson tenga convergencia cubica"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Para que $f$ tenga convergencia cubica, se necesita que $f''($"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"using Plots\n",
"using Calculus"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Plots.GRBackend()"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gr()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"BisectionMethod (generic function with 1 method)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function BisectionMethod(f::Function,a::Number,b::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" u = f(a)\n",
" v = f(b) \n",
" e = b - a\n",
" w = 0\n",
" c = 0 \n",
" if sign(u) == sign(v)\n",
" error(\"Not a suitable interval\")\n",
" end\n",
" for i in 1:steps\n",
" e = e/2\n",
" c = a + e\n",
" w = f(c)\n",
" if (abs(e) < δ) || (abs(w) < ϵ)\n",
" return c\n",
" end\n",
" if sign(w) != sign(u)\n",
" b = c\n",
" v = w\n",
" else\n",
" a = c\n",
" u = w\n",
" end\n",
" end\n",
" return c\n",
"end "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"BisectionMethod! (generic function with 1 method)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function BisectionMethod!(f::Function,a::Number,b::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" u = f(a)\n",
" v = f(b) \n",
" e = b - a\n",
" w = 0\n",
" c = 0\n",
" roots = Array{Float64}(0)\n",
" if sign(u) == sign(v)\n",
" error(\"Not a suitable interval\")\n",
" end\n",
" for i in 1:steps\n",
" e = e/2\n",
" c = a + e\n",
" w = f(c)\n",
" push!(roots,c)\n",
" if (abs(e) < δ) || (abs(w) < ϵ)\n",
" return roots\n",
" end\n",
" if sign(w) != sign(u)\n",
" b = c\n",
" v = w\n",
" else\n",
" a = c\n",
" u = w\n",
" end\n",
" end\n",
" return roots\n",
"end "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"NewtonRaphsonMethod (generic function with 1 method)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function NewtonRaphsonMethod(f::Function,fder::Function,x0::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" if abs(v) < ϵ\n",
" return x0\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - v/(fder(x0))\n",
" v = f(x1)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return x1\n",
" end\n",
" x0 = x1\n",
" end\n",
" return x0\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"2.220446049250313e-16"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"eps()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"NewtonRaphsonMethod! (generic function with 1 method)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function NewtonRaphsonMethod!(f::Function,fder::Function,x0::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" roots = Array{Float64}(1)\n",
" if abs(v) < ϵ\n",
" return push!(roots,x0)\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - v/(fder(x0))\n",
" push!(roots,x1)\n",
" v = f(x1)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return roots\n",
" end\n",
" x0 = x1\n",
" end\n",
" return roots\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SecantMethod (generic function with 2 methods)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function SecantMethod(f::Function, x0::Number, x1::Number, args::Tuple=();\n",
" tol::AbstractFloat=1e-12, maxiter::Integer=500)\n",
" x = 0.0\n",
" for _ in 1:maxiter\n",
" y1 = f(x1, args...)\n",
" y0 = f(x0, args...)\n",
" x = x1 - y1 * (x1-x0)/(y1-y0)\n",
" if abs(x-x1) < tol\n",
" return x\n",
" end\n",
" x0 = x1\n",
" x1 = x\n",
" end\n",
" warn(\"Max iteration exceeded\")\n",
" return x\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SecantMethod! (generic function with 2 methods)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function SecantMethod!(f::Function, x0::Number, x1::Number, args::Tuple=();\n",
" tol::AbstractFloat=1e-12, maxiter::Integer=500)\n",
" x = 0.0\n",
" roots = Array{Float64}(0)\n",
" for _ in 1:maxiter\n",
" y1 = f(x1, args...)\n",
" y0 = f(x0, args...)\n",
" x = x1 - y1 * (x1-x0)/(y1-y0)\n",
" push!(roots,x)\n",
" if abs(x-x1) < tol\n",
" return roots\n",
" end\n",
" x0 = x1\n",
" x1 = x\n",
" end\n",
" warn(\"Max iteration exceeded\")\n",
" return roots\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"logpoints (generic function with 1 method)"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function logpoints(x::Array{Float64,1})\n",
" points = Array{Float64}(0)\n",
" for i in 1:(size(x)[1] - 2)\n",
" a = log(abs(x[i+1]))/log(abs(x[i]))\n",
" if (a != 0) && (a != Inf)\n",
" push!(points,a)\n",
" end\n",
" end\n",
" return points\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"f(x) = 1/x - exp(x)\n",
"fprime = f'\n",
"g(x) = x - tan(x)\n",
"gprime = g'\n",
"h(x) = sin(x) + x^2*cos(x) - x^2 - x\n",
"hprime = h';"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Encontramos un cero de $f$."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.5671432904097838"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootf = BisectionMethod(f,0,1)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f(rootf)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Encontremos los valores de $\\frac{e_{n+1}}{e_n}$"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(BisectionMethod!(f,0,1) .- rootf);"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"30.6037,384.952 596.063,384.952 596.063,3.93701 30.6037,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"30\" y=\"3\" width=\"566\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 132.386,379.237 132.386,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 245.478,379.237 245.478,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 358.57,379.237 358.57,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 471.662,379.237 471.662,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 584.754,379.237 584.754,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,272.436 587.581,272.436 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,120.771 587.581,120.771 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 132.386,384.952 132.386,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 245.478,384.952 245.478,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 358.57,384.952 358.57,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 471.662,384.952 471.662,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 584.754,384.952 584.754,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,272.436 39.0856,272.436 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,120.771 39.0856,120.771 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 132.386, 396.952)\" x=\"132.386\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 245.478, 396.952)\" x=\"245.478\" y=\"396.952\">20</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 358.57, 396.952)\" x=\"358.57\" y=\"396.952\">30</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 471.662, 396.952)\" x=\"471.662\" y=\"396.952\">40</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 584.754, 396.952)\" x=\"584.754\" y=\"396.952\">50</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 276.936)\" x=\"29.4037\" y=\"276.936\">1.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 125.271)\" x=\"29.4037\" y=\"125.271\">1.5</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 41.9129,66.9965 53.222,3.93701 64.5312,371.003 75.8404,198.419 87.1496,188.88 98.4588,195.547 109.768,293.494 121.077,199.011 132.386,273.812 \n",
" 143.696,126.732 155.005,352.332 166.314,247.857 177.623,248.295 188.932,246.887 200.241,238.995 211.551,240.927 222.86,279.284 234.169,228.282 245.478,287.5 \n",
" 256.787,245.907 268.097,252.598 279.406,271.464 290.715,210.244 302.024,313.574 313.333,259.792 324.643,259.129 335.952,256.574 347.261,239.006 358.57,288.55 \n",
" 369.879,257.887 381.188,239.005 392.498,290.894 403.807,260.506 415.116,254.222 426.425,268.349 437.734,254.671 449.044,279.166 460.353,256.292 471.662,268.019 \n",
" 482.971,258.585 494.28,275.828 505.59,253.147 516.899,278.677 528.208,258.843 539.517,267.126 550.826,263.966 562.135,270.229 573.445,255.47 584.754,281.507 \n",
" 596.063,263.085 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.5671432904097838"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootf = NewtonRaphsonMethod(f, fprime, 3)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(NewtonRaphsonMethod!(f,fprime,3) .- rootf);"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"12.8259,384.952 596.063,384.952 596.063,3.93701 12.8259,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"12\" y=\"3\" width=\"584\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 12.8259,379.237 12.8259,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 129.473,379.237 129.473,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 246.121,379.237 246.121,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 362.768,379.237 362.768,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 479.416,379.237 479.416,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 596.063,379.237 596.063,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,319.141 587.314,319.141 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,236.688 587.314,236.688 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,154.234 587.314,154.234 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,71.7806 587.314,71.7806 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 12.8259,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 129.473,384.952 129.473,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 246.121,384.952 246.121,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 362.768,384.952 362.768,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 479.416,384.952 479.416,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 596.063,384.952 596.063,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 12.8259,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,319.141 21.5745,319.141 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,236.688 21.5745,236.688 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,154.234 21.5745,154.234 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,71.7806 21.5745,71.7806 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 12.8259, 396.952)\" x=\"12.8259\" y=\"396.952\">1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 129.473, 396.952)\" x=\"129.473\" y=\"396.952\">2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 246.121, 396.952)\" x=\"246.121\" y=\"396.952\">3</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 362.768, 396.952)\" x=\"362.768\" y=\"396.952\">4</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 479.416, 396.952)\" x=\"479.416\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 596.063, 396.952)\" x=\"596.063\" y=\"396.952\">6</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 323.641)\" x=\"11.6259\" y=\"323.641\">0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 241.188)\" x=\"11.6259\" y=\"241.188\">2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 158.734)\" x=\"11.6259\" y=\"158.734\">4</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 76.2806)\" x=\"11.6259\" y=\"76.2806\">6</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,346.394 129.473,384.952 246.121,3.93701 362.768,236.394 479.416,236.431 596.063,236.942 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[1m\u001b[31mWARNING: Max iteration exceeded\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"-1.2835157962052e105"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootf = SecantMethod(f,-1,1,)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[1m\u001b[31mWARNING: Max iteration exceeded\u001b[0m\n"
]
}
],
"source": [
"errors = abs(SecantMethod!(f,-1,1) .- rootf);"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"57.2703,384.952 596.063,384.952 596.063,3.93701 57.2703,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"57\" y=\"3\" width=\"539\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 164.595,379.237 164.595,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 273.004,379.237 273.004,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 381.413,379.237 381.413,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 489.822,379.237 489.822,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 65.3522,290.807 587.981,290.807 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 65.3522,195.184 587.981,195.184 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 65.3522,99.5605 587.981,99.5605 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 65.3522,3.93701 587.981,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 164.595,384.952 164.595,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 273.004,384.952 273.004,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 381.413,384.952 381.413,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 489.822,384.952 489.822,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,384.952 57.2703,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,290.807 65.3522,290.807 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,195.184 65.3522,195.184 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,99.5605 65.3522,99.5605 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,3.93701 65.3522,3.93701 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 164.595, 396.952)\" x=\"164.595\" y=\"396.952\">100</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 273.004, 396.952)\" x=\"273.004\" y=\"396.952\">200</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 381.413, 396.952)\" x=\"381.413\" y=\"396.952\">300</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 489.822, 396.952)\" x=\"489.822\" y=\"396.952\">400</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 56.0703, 295.307)\" x=\"56.0703\" y=\"295.307\">0.9985</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 56.0703, 199.684)\" x=\"56.0703\" y=\"199.684\">0.9990</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 56.0703, 104.06)\" x=\"56.0703\" y=\"104.06\">0.9995</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 56.0703, 8.43701)\" x=\"56.0703\" y=\"8.43701\">1.0000</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,3.93701 58.3544,3.93701 59.4385,3.93701 60.5226,3.93701 61.6067,3.93701 62.6908,3.93701 63.7749,3.93701 64.859,3.93701 65.9431,3.93701 67.0271,3.93701 \n",
" 68.1112,3.93701 69.1953,3.93701 70.2794,3.93701 71.3635,3.93701 72.4476,3.93701 73.5317,3.93701 74.6158,3.93701 75.6999,3.93701 76.784,3.93701 77.868,3.93701 \n",
" 78.9521,3.93701 80.0362,3.93701 81.1203,3.93701 82.2044,3.93701 83.2885,3.93701 84.3726,3.93701 85.4567,3.93701 86.5408,3.93701 87.6249,3.93701 88.7089,3.93701 \n",
" 89.793,3.93701 90.8771,3.93701 91.9612,3.93701 93.0453,3.93701 94.1294,3.93701 95.2135,3.93701 96.2976,3.93701 97.3817,3.93701 98.4658,3.93701 99.5498,3.93701 \n",
" 100.634,3.93701 101.718,3.93701 102.802,3.93701 103.886,3.93701 104.97,3.93701 106.054,3.93701 107.138,3.93701 108.223,3.93701 109.307,3.93701 110.391,3.93701 \n",
" 111.475,3.93701 112.559,3.93701 113.643,3.93701 114.727,3.93701 115.811,3.93701 116.895,3.93701 117.979,3.93701 119.063,3.93701 120.148,3.93701 121.232,3.93701 \n",
" 122.316,3.93701 123.4,3.93701 124.484,3.93701 125.568,3.93701 126.652,3.93701 127.736,3.93701 128.82,3.93701 129.904,3.93701 130.988,3.93701 132.073,3.93701 \n",
" 133.157,3.93701 134.241,3.93701 135.325,3.93701 136.409,3.93701 137.493,3.93701 138.577,3.93701 139.661,3.93701 140.745,3.93701 141.829,3.93701 142.913,3.93701 \n",
" 143.998,3.93701 145.082,3.93701 146.166,3.93701 147.25,3.93701 148.334,3.93701 149.418,3.93701 150.502,3.93701 151.586,3.93701 152.67,3.93701 153.754,3.93701 \n",
" 154.838,3.93701 155.923,3.93701 157.007,3.93701 158.091,3.93701 159.175,3.93701 160.259,3.93701 161.343,3.93701 162.427,3.93701 163.511,3.93701 164.595,3.93701 \n",
" 165.679,3.93701 166.763,3.93701 167.848,3.93701 168.932,3.93701 170.016,3.93701 171.1,3.93701 172.184,3.93701 173.268,3.93701 174.352,3.93701 175.436,3.93701 \n",
" 176.52,3.93701 177.604,3.93701 178.688,3.93701 179.772,3.93701 180.857,3.93701 181.941,3.93701 183.025,3.93701 184.109,3.93701 185.193,3.93701 186.277,3.93701 \n",
" 187.361,3.93701 188.445,3.93701 189.529,3.93701 190.613,3.93701 191.697,3.93701 192.782,3.93701 193.866,3.93701 194.95,3.93701 196.034,3.93701 197.118,3.93701 \n",
" 198.202,3.93701 199.286,3.93701 200.37,3.93701 201.454,3.93701 202.538,3.93701 203.622,3.93701 204.707,3.93701 205.791,3.93701 206.875,3.93701 207.959,3.93701 \n",
" 209.043,3.93701 210.127,3.93701 211.211,3.93701 212.295,3.93701 213.379,3.93701 214.463,3.93701 215.547,3.93701 216.632,3.93701 217.716,3.93701 218.8,3.93701 \n",
" 219.884,3.93701 220.968,3.93701 222.052,3.93701 223.136,3.93701 224.22,3.93701 225.304,3.93701 226.388,3.93701 227.472,3.93701 228.557,3.93701 229.641,3.93701 \n",
" 230.725,3.93701 231.809,3.93701 232.893,3.93701 233.977,3.93701 235.061,3.93701 236.145,3.93701 237.229,3.93701 238.313,3.93701 239.397,3.93701 240.482,3.93701 \n",
" 241.566,3.93701 242.65,3.93701 243.734,3.93701 244.818,3.93701 245.902,3.93701 246.986,3.93701 248.07,3.93701 249.154,3.93701 250.238,3.93701 251.322,3.93701 \n",
" 252.407,3.93701 253.491,3.93701 254.575,3.93701 255.659,3.93701 256.743,3.93701 257.827,3.93701 258.911,3.93701 259.995,3.93701 261.079,3.93701 262.163,3.93701 \n",
" 263.247,3.93701 264.332,3.93701 265.416,3.93701 266.5,3.93701 267.584,3.93701 268.668,3.93701 269.752,3.93701 270.836,3.93701 271.92,3.93701 273.004,3.93701 \n",
" 274.088,3.93701 275.172,3.93701 276.256,3.93701 277.341,3.93701 278.425,3.93701 279.509,3.93701 280.593,3.93701 281.677,3.93701 282.761,3.93701 283.845,3.93701 \n",
" 284.929,3.93701 286.013,3.93701 287.097,3.93701 288.181,3.93701 289.266,3.93701 290.35,3.93701 291.434,3.93701 292.518,3.93701 293.602,3.93701 294.686,3.93701 \n",
" 295.77,3.93701 296.854,3.93701 297.938,3.93701 299.022,3.93701 300.106,3.93701 301.191,3.93701 302.275,3.93701 303.359,3.93701 304.443,3.93701 305.527,3.93701 \n",
" 306.611,3.93701 307.695,3.93701 308.779,3.93701 309.863,3.93701 310.947,3.93701 312.031,3.93701 313.116,3.93701 314.2,3.93701 315.284,3.93701 316.368,3.93701 \n",
" 317.452,3.93701 318.536,3.93701 319.62,3.93701 320.704,3.93701 321.788,3.93701 322.872,3.93701 323.956,3.93701 325.041,3.93701 326.125,3.93701 327.209,3.93701 \n",
" 328.293,3.93701 329.377,3.93701 330.461,3.93701 331.545,3.93701 332.629,3.93701 333.713,3.93701 334.797,3.93701 335.881,3.93701 336.966,3.93701 338.05,3.93701 \n",
" 339.134,3.93701 340.218,3.93701 341.302,3.93701 342.386,3.93701 343.47,3.93701 344.554,3.93701 345.638,3.93701 346.722,3.93701 347.806,3.93701 348.891,3.93701 \n",
" 349.975,3.93701 351.059,3.93701 352.143,3.93701 353.227,3.93701 354.311,3.93701 355.395,3.93701 356.479,3.93701 357.563,3.93701 358.647,3.93701 359.731,3.93701 \n",
" 360.815,3.93701 361.9,3.93701 362.984,3.93701 364.068,3.93701 365.152,3.93701 366.236,3.93701 367.32,3.93701 368.404,3.93701 369.488,3.93701 370.572,3.93701 \n",
" 371.656,3.93701 372.74,3.93701 373.825,3.93701 374.909,3.93701 375.993,3.93701 377.077,3.93701 378.161,3.93701 379.245,3.93701 380.329,3.93701 381.413,3.93701 \n",
" 382.497,3.93701 383.581,3.93701 384.665,3.93701 385.75,3.93701 386.834,3.93701 387.918,3.93701 389.002,3.93701 390.086,3.93701 391.17,3.93701 392.254,3.93701 \n",
" 393.338,3.93701 394.422,3.93701 395.506,3.93701 396.59,3.93701 397.675,3.93701 398.759,3.93701 399.843,3.93701 400.927,3.93701 402.011,3.93701 403.095,3.93701 \n",
" 404.179,3.93701 405.263,3.93701 406.347,3.93701 407.431,3.93701 408.515,3.93701 409.6,3.93701 410.684,3.93701 411.768,3.93701 412.852,3.93701 413.936,3.93701 \n",
" 415.02,3.93701 416.104,3.93701 417.188,3.93701 418.272,3.93701 419.356,3.93701 420.44,3.93701 421.525,3.93701 422.609,3.93701 423.693,3.93701 424.777,3.93701 \n",
" 425.861,3.93701 426.945,3.93701 428.029,3.93701 429.113,3.93701 430.197,3.93701 431.281,3.93701 432.365,3.93701 433.45,3.93701 434.534,3.93701 435.618,3.93701 \n",
" 436.702,3.93701 437.786,3.93701 438.87,3.93701 439.954,3.93701 441.038,3.93701 442.122,3.93701 443.206,3.93701 444.29,3.93701 445.375,3.93701 446.459,3.93701 \n",
" 447.543,3.93701 448.627,3.93701 449.711,3.93701 450.795,3.93701 451.879,3.93701 452.963,3.93701 454.047,3.93701 455.131,3.93701 456.215,3.93701 457.299,3.93701 \n",
" 458.384,3.93701 459.468,3.93701 460.552,3.93701 461.636,3.93701 462.72,3.93701 463.804,3.93701 464.888,3.93701 465.972,3.93701 467.056,3.93701 468.14,3.93701 \n",
" 469.224,3.93701 470.309,3.93701 471.393,3.93701 472.477,3.93701 473.561,3.93701 474.645,3.93701 475.729,3.93701 476.813,3.93701 477.897,3.93701 478.981,3.93701 \n",
" 480.065,3.93701 481.149,3.93701 482.234,3.93701 483.318,3.93701 484.402,3.93701 485.486,3.93701 486.57,3.93701 487.654,3.93701 488.738,3.93701 489.822,3.93701 \n",
" 490.906,3.93701 491.99,3.93701 493.074,3.93701 494.159,3.93701 495.243,3.93701 496.327,3.93701 497.411,3.93701 498.495,3.93701 499.579,3.93701 500.663,3.93701 \n",
" 501.747,3.93701 502.831,3.93701 503.915,3.93701 504.999,3.93701 506.084,3.93701 507.168,3.93701 508.252,3.93701 509.336,3.93701 510.42,3.93701 511.504,3.93701 \n",
" 512.588,3.93701 513.672,3.93701 514.756,3.93701 515.84,3.93701 516.924,3.93701 518.009,3.93701 519.093,3.93701 520.177,3.93701 521.261,3.93701 522.345,3.93701 \n",
" 523.429,3.93701 524.513,3.93701 525.597,3.93701 526.681,3.93701 527.765,3.93701 528.849,3.93701 529.934,3.93701 531.018,3.93701 532.102,3.93701 533.186,3.93701 \n",
" 534.27,3.93701 535.354,3.93701 536.438,3.93701 537.522,3.93701 538.606,3.93701 539.69,3.93701 540.774,3.93701 541.859,3.93701 542.943,3.93701 544.027,3.93701 \n",
" 545.111,3.93701 546.195,3.93701 547.279,3.93701 548.363,3.93701 549.447,3.93701 550.531,3.93701 551.615,3.93701 552.699,3.93701 553.783,3.93701 554.868,3.93701 \n",
" 555.952,3.93701 557.036,3.93701 558.12,3.93702 559.204,3.93702 560.288,3.93703 561.372,3.93705 562.456,3.93707 563.54,3.93711 564.624,3.93717 565.708,3.93727 \n",
" 566.793,3.93743 567.877,3.9377 568.961,3.93812 570.045,3.93881 571.129,3.93992 572.213,3.94172 573.297,3.94463 574.381,3.94934 575.465,3.95696 576.549,3.9693 \n",
" 577.633,3.98925 578.718,4.02155 579.802,4.07382 580.886,4.15842 581.97,4.2954 583.054,4.51724 584.138,4.87675 585.222,5.45993 586.306,6.4074 587.39,7.95066 \n",
" 588.474,10.4749 589.558,14.6318 590.643,21.555 591.727,33.3052 592.811,53.9034 593.895,92.1594 594.979,171.597 596.063,384.952 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ahora para $g$"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"4.493409457909063"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootg = BisectionMethod(g,3.2,4.6)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(BisectionMethod!(g,3.2,4.6) .- rootg);"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"12.8259,384.952 596.063,384.952 596.063,3.93701 12.8259,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"12\" y=\"3\" width=\"584\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 124.51,379.237 124.51,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 248.603,379.237 248.603,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 372.696,379.237 372.696,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 496.789,379.237 496.789,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,323.214 587.314,323.214 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,136.238 587.314,136.238 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 124.51,384.952 124.51,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 248.603,384.952 248.603,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 372.696,384.952 372.696,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 496.789,384.952 496.789,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 12.8259,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,323.214 21.5745,323.214 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,136.238 21.5745,136.238 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 124.51, 396.952)\" x=\"124.51\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 248.603, 396.952)\" x=\"248.603\" y=\"396.952\">20</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 372.696, 396.952)\" x=\"372.696\" y=\"396.952\">30</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 496.789, 396.952)\" x=\"496.789\" y=\"396.952\">40</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 327.714)\" x=\"11.6259\" y=\"327.714\">1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 140.738)\" x=\"11.6259\" y=\"140.738\">2</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,3.93701 25.2352,155.264 37.6445,234.244 50.0538,335.304 62.4631,213.071 74.8724,357.355 87.2817,280.022 99.691,197.471 112.1,384.952 124.51,302.58 \n",
" 136.919,303.524 149.328,302.965 161.737,297.752 174.147,294.575 186.556,333.394 198.965,299.148 211.375,315.82 223.784,307.119 236.193,323.804 248.603,272.941 \n",
" 261.012,354.932 273.421,313.947 285.83,313.72 298.24,312.552 310.649,306.936 323.058,320.786 335.468,304.04 347.877,333.156 360.286,313.091 372.696,288.504 \n",
" 385.105,346.86 397.514,316.925 409.923,316.725 422.333,315.968 434.742,312.899 447.151,316.753 459.561,320.833 471.97,312.056 484.379,327.723 496.789,313.847 \n",
" 509.198,318.96 521.607,318.448 534.016,319.688 546.426,317.814 558.835,321.685 571.244,309.908 583.654,330.693 596.063,315.423 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"4.493409457909064"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootg = NewtonRaphsonMethod(g,gprime,4.4)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(NewtonRaphsonMethod!(g,gprime,4.4) .- rootg);"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"30.6037,384.952 596.063,384.952 596.063,3.93701 30.6037,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"30\" y=\"3\" width=\"566\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.6037,379.237 30.6037,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 171.969,379.237 171.969,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 313.333,379.237 313.333,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 454.698,379.237 454.698,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 596.063,379.237 596.063,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,328.143 587.581,328.143 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,198.649 587.581,198.649 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,69.1552 587.581,69.1552 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 171.969,384.952 171.969,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 313.333,384.952 313.333,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 454.698,384.952 454.698,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 596.063,384.952 596.063,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,328.143 39.0856,328.143 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,198.649 39.0856,198.649 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,69.1552 39.0856,69.1552 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 30.6037, 396.952)\" x=\"30.6037\" y=\"396.952\">1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 171.969, 396.952)\" x=\"171.969\" y=\"396.952\">2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 313.333, 396.952)\" x=\"313.333\" y=\"396.952\">3</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 454.698, 396.952)\" x=\"454.698\" y=\"396.952\">4</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 596.063, 396.952)\" x=\"596.063\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 332.643)\" x=\"29.4037\" y=\"332.643\">1.6</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 203.149)\" x=\"29.4037\" y=\"203.149\">1.8</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 73.6552)\" x=\"29.4037\" y=\"73.6552\">2.0</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,3.93701 171.969,384.952 313.333,279.188 454.698,194.694 596.063,138.953 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(abs(logpoints(errors)))"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"4.493409457909064"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootg = SecantMethod(g,4.4,4.5)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"errors = abs(SecantMethod!(g,4.4,4.5) .- rootg);"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"39.4926,384.952 596.063,384.952 596.063,3.93701 39.4926,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"39\" y=\"3\" width=\"557\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.4926,379.237 39.4926,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 132.254,379.237 132.254,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 225.016,379.237 225.016,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 317.778,379.237 317.778,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 410.54,379.237 410.54,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 503.301,379.237 503.301,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 596.063,379.237 596.063,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 47.8411,272.411 587.714,272.411 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 47.8411,131.923 587.714,131.923 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,384.952 39.4926,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 132.254,384.952 132.254,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 225.016,384.952 225.016,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 317.778,384.952 317.778,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 410.54,384.952 410.54,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 503.301,384.952 503.301,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 596.063,384.952 596.063,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,384.952 39.4926,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,272.411 47.8411,272.411 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,131.923 47.8411,131.923 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 39.4926, 396.952)\" x=\"39.4926\" y=\"396.952\">1.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 132.254, 396.952)\" x=\"132.254\" y=\"396.952\">1.5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 225.016, 396.952)\" x=\"225.016\" y=\"396.952\">2.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 317.778, 396.952)\" x=\"317.778\" y=\"396.952\">2.5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 410.54, 396.952)\" x=\"410.54\" y=\"396.952\">3.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 503.301, 396.952)\" x=\"503.301\" y=\"396.952\">3.5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 596.063, 396.952)\" x=\"596.063\" y=\"396.952\">4.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 38.2926, 276.911)\" x=\"38.2926\" y=\"276.911\">1.50</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 38.2926, 136.423)\" x=\"38.2926\" y=\"136.423\">1.55</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,3.93701 225.016,384.952 410.54,73.647 596.063,104.191 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ahora para $h$"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rooth = BisectionMethod(h,-0.3,0.3)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(BisectionMethod!(h,-.3,3) .- rooth);"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"21.7148,384.952 596.063,384.952 596.063,3.93701 21.7148,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"21\" y=\"3\" width=\"575\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 213.164,379.237 213.164,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 452.476,379.237 452.476,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,374.83 587.448,374.83 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,237.225 587.448,237.225 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,99.6191 587.448,99.6191 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 213.164,384.952 213.164,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 452.476,384.952 452.476,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 21.7148,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,374.83 30.33,374.83 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,237.225 30.33,237.225 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,99.6191 30.33,99.6191 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 213.164, 396.952)\" x=\"213.164\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 452.476, 396.952)\" x=\"452.476\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 379.33)\" x=\"20.5148\" y=\"379.33\">-2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 241.725)\" x=\"20.5148\" y=\"241.725\">0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 104.119)\" x=\"20.5148\" y=\"104.119\">2</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 69.5771,3.93701 117.439,162.68 165.302,101.495 213.164,190.583 261.027,147.895 308.889,142.635 356.751,166.202 404.614,141.261 452.476,181.142 \n",
" 500.338,158.623 548.201,154.432 596.063,167.046 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"1.0353844404253541e-5"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rooth = NewtonRaphsonMethod(h,hprime,0.2)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(NewtonRaphsonMethod!(h,hprime,0.2) .- rooth);"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"30.6037,384.952 596.063,384.952 596.063,3.93701 30.6037,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"30\" y=\"3\" width=\"566\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 128.944,379.237 128.944,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 251.87,379.237 251.87,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 374.796,379.237 374.796,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 497.722,379.237 497.722,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,374.011 587.581,374.011 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,298.827 587.581,298.827 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,223.643 587.581,223.643 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,148.459 587.581,148.459 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,73.2746 587.581,73.2746 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 128.944,384.952 128.944,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 251.87,384.952 251.87,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 374.796,384.952 374.796,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 497.722,384.952 497.722,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,374.011 39.0856,374.011 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,298.827 39.0856,298.827 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,223.643 39.0856,223.643 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,148.459 39.0856,148.459 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,73.2746 39.0856,73.2746 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 128.944, 396.952)\" x=\"128.944\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 251.87, 396.952)\" x=\"251.87\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 374.796, 396.952)\" x=\"374.796\" y=\"396.952\">15</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 497.722, 396.952)\" x=\"497.722\" y=\"396.952\">20</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 378.511)\" x=\"29.4037\" y=\"378.511\">0.2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 303.327)\" x=\"29.4037\" y=\"303.327\">0.4</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 228.143)\" x=\"29.4037\" y=\"228.143\">0.6</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 152.959)\" x=\"29.4037\" y=\"152.959\">0.8</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 77.7746)\" x=\"29.4037\" y=\"77.7746\">1.0</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 55.1889,3.93701 79.774,13.2326 104.359,20.3483 128.944,26.0339 153.53,30.7107 178.115,34.6309 202.7,37.9573 227.285,40.8038 251.87,43.2554 \n",
" 276.456,45.3775 301.041,47.2216 325.626,48.8277 350.211,50.2257 374.796,51.4363 399.381,52.4709 423.967,53.3297 448.552,53.9986 473.137,54.4418 497.722,54.5853 \n",
" 522.307,54.2786 546.893,53.1893 571.478,50.4317 596.063,42.5287 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"-0.3345821606680503"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rooth = SecantMethod(h,-0.5,0.5)"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"errors = abs(SecantMethod!(h,-0.5,0.5) .- rooth);"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"21.7148,384.952 596.063,384.952 596.063,3.93701 21.7148,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"21\" y=\"3\" width=\"575\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 198.437,379.237 198.437,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 419.34,379.237 419.34,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,350.088 587.448,350.088 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,217.673 587.448,217.673 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,85.2577 587.448,85.2577 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 198.437,384.952 198.437,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 419.34,384.952 419.34,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 21.7148,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,350.088 30.33,350.088 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,217.673 30.33,217.673 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,85.2577 30.33,85.2577 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 198.437, 396.952)\" x=\"198.437\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 419.34, 396.952)\" x=\"419.34\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 354.588)\" x=\"20.5148\" y=\"354.588\">-1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 222.173)\" x=\"20.5148\" y=\"222.173\">0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 89.7577)\" x=\"20.5148\" y=\"89.7577\">1</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 65.8954,317.884 110.076,91.7645 154.257,3.93701 198.437,54.2391 242.618,47.1837 286.799,52.5479 330.979,50.3029 375.16,47.84 419.34,42.1266 \n",
" 463.521,34.6992 507.702,26.512 551.882,19.483 596.063,14.141 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"NewtonRaphsonMethodModified! (generic function with 1 method)"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function NewtonRaphsonMethodModified!(f::Function,fder::Function,x0::Number;m::UInt64=1,steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" roots = Array{Float64}(0)\n",
" if abs(v) < ϵ\n",
" return push!(roots,x0)\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - m*(v/(fder(x0)))\n",
" push!(roots,x1)\n",
" v = f(x1)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return roots\n",
" end\n",
" x0 = x1\n",
" end\n",
" return roots\n",
" \n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"NewtonRaphsonMethodModified (generic function with 1 method)"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function NewtonRaphsonMethodModified(f::Function,fder::Function,x0::Number;m::UInt64=1,steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" if abs(v) < ϵ\n",
" return x0\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - m*(v/(fder(x0)))\n",
" v = f(x1)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return x1\n",
" end\n",
" x0 = x1\n",
" end\n",
" return x0\n",
"end\n"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"2.2295541974719528e-7"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rooth = NewtonRaphsonMethodModified(h,hprime,0.2,m=UInt(3),steps=UInt(100))"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"errors = abs(NewtonRaphsonMethodModified!(h,hprime,1,m=UInt(3),steps=UInt(100)) .- rooth);"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"30.6037,384.952 596.063,384.952 596.063,3.93701 30.6037,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"30\" y=\"3\" width=\"566\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.6037,379.237 30.6037,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 171.969,379.237 171.969,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 313.333,379.237 313.333,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 454.698,379.237 454.698,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 596.063,379.237 596.063,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,266.063 587.581,266.063 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,125.213 587.581,125.213 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 171.969,384.952 171.969,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 313.333,384.952 313.333,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 454.698,384.952 454.698,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 596.063,384.952 596.063,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,266.063 39.0856,266.063 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,125.213 39.0856,125.213 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 30.6037, 396.952)\" x=\"30.6037\" y=\"396.952\">1.00</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 171.969, 396.952)\" x=\"171.969\" y=\"396.952\">1.25</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 313.333, 396.952)\" x=\"313.333\" y=\"396.952\">1.50</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 454.698, 396.952)\" x=\"454.698\" y=\"396.952\">1.75</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 596.063, 396.952)\" x=\"596.063\" y=\"396.952\">2.00</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 270.563)\" x=\"29.4037\" y=\"270.563\">2.1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 129.713)\" x=\"29.4037\" y=\"129.713\">2.2</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,3.93701 596.063,384.952 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SteffensenMethod (generic function with 1 method)"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function SteffensenMethod(f::Function,x0::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" if abs(v) < ϵ\n",
" return x0\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - (v^2/((f(x0 + v)-v)))\n",
" v = f(x1)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return x1\n",
" end\n",
" x0 = x1\n",
" end\n",
" return x0\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SteffensenMethod! (generic function with 1 method)"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function SteffensenMethod!(f::Function,x0::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" roots = Array{Float64}(0)\n",
" if abs(v) < ϵ\n",
" return push!(roots,v)\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - (v^2/((f(x0 + v)-v)))\n",
" v = f(x1)\n",
" push!(roots,v)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return roots\n",
" end\n",
" x0 = x1\n",
" end\n",
" return roots\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.567143290409784"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootf = SteffensenMethod(f,0.1,steps=UInt(1000000))"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(SteffensenMethod!(f,0.1,steps=UInt(1000000)) .- rootf);"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"12.8259,384.952 596.063,384.952 596.063,3.93701 12.8259,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"12\" y=\"3\" width=\"584\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 122.183,379.237 122.183,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 304.444,379.237 304.444,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 486.706,379.237 486.706,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,355.307 587.314,355.307 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,270.19 587.314,270.19 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,185.073 587.314,185.073 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,99.9566 587.314,99.9566 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,14.8398 587.314,14.8398 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 122.183,384.952 122.183,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 304.444,384.952 304.444,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 486.706,384.952 486.706,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 12.8259,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,355.307 21.5745,355.307 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,270.19 21.5745,270.19 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,185.073 21.5745,185.073 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,99.9566 21.5745,99.9566 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,14.8398 21.5745,14.8398 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 122.183, 396.952)\" x=\"122.183\" y=\"396.952\">2.5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 304.444, 396.952)\" x=\"304.444\" y=\"396.952\">5.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 486.706, 396.952)\" x=\"486.706\" y=\"396.952\">7.5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 359.807)\" x=\"11.6259\" y=\"359.807\">0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 274.69)\" x=\"11.6259\" y=\"274.69\">1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 189.573)\" x=\"11.6259\" y=\"189.573\">2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 104.457)\" x=\"11.6259\" y=\"104.457\">3</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 19.3398)\" x=\"11.6259\" y=\"19.3398\">4</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,278.953 85.7305,292.457 158.635,384.952 231.54,338.546 304.444,3.93701 377.349,231.593 450.254,266.995 523.158,270.162 596.063,270.19 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"Convergencia cuadratica como podemos ver"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"4.493409457909064"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootg = SteffensenMethod(g,4.5,steps=UInt(1000000))"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"errors = abs(SteffensenMethod!(g,4.5,steps=UInt(1000000)) .- rootg);"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"48.3815,384.952 596.063,384.952 596.063,3.93701 48.3815,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"48\" y=\"3\" width=\"548\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 48.3815,379.237 48.3815,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 185.302,379.237 185.302,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 322.222,379.237 322.222,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 459.143,379.237 459.143,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 596.063,379.237 596.063,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 56.5967,288.135 587.848,288.135 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 56.5967,191.318 587.848,191.318 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 56.5967,94.5007 587.848,94.5007 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,384.952 48.3815,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 185.302,384.952 185.302,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 322.222,384.952 322.222,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 459.143,384.952 459.143,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 596.063,384.952 596.063,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,384.952 48.3815,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,288.135 56.5967,288.135 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,191.318 56.5967,191.318 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,94.5007 56.5967,94.5007 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 48.3815, 396.952)\" x=\"48.3815\" y=\"396.952\">1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 185.302, 396.952)\" x=\"185.302\" y=\"396.952\">2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 322.222, 396.952)\" x=\"322.222\" y=\"396.952\">3</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 459.143, 396.952)\" x=\"459.143\" y=\"396.952\">4</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 596.063, 396.952)\" x=\"596.063\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 47.1815, 292.635)\" x=\"47.1815\" y=\"292.635\">1.002</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 47.1815, 195.818)\" x=\"47.1815\" y=\"195.818\">1.004</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 47.1815, 99.0007)\" x=\"47.1815\" y=\"99.0007\">1.006</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,3.93701 185.302,196.803 322.222,356.304 459.143,384.421 596.063,384.952 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pocas iteraciones para decidir."
]
},
{
"cell_type": "code",
"execution_count": 91,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.00022184119990164566"
]
},
"execution_count": 91,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rooth = SteffensenMethod(h,0.5,steps=UInt(20))"
]
},
{
"cell_type": "code",
"execution_count": 92,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"errors = abs(SteffensenMethod!(h,0.5,steps=UInt(20)) .- rooth);"
]
},
{
"cell_type": "code",
"execution_count": 93,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"30.6037,384.952 596.063,384.952 596.063,3.93701 30.6037,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"30\" y=\"3\" width=\"566\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 163.653,379.237 163.653,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 329.964,379.237 329.964,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 496.276,379.237 496.276,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,247.223 587.581,247.223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,109.493 587.581,109.493 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 163.653,384.952 163.653,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 329.964,384.952 329.964,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 496.276,384.952 496.276,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,247.223 39.0856,247.223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,109.493 39.0856,109.493 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 163.653, 396.952)\" x=\"163.653\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 329.964, 396.952)\" x=\"329.964\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 496.276, 396.952)\" x=\"496.276\" y=\"396.952\">15</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 251.723)\" x=\"29.4037\" y=\"251.723\">1.1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 113.993)\" x=\"29.4037\" y=\"113.993\">1.2</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,3.93701 63.866,115.944 97.1283,202.674 130.391,282.893 163.653,341.014 196.915,369.484 230.178,380.024 263.44,383.443 296.702,384.497 329.964,384.816 \n",
" 363.227,384.911 396.489,384.94 429.751,384.948 463.014,384.951 496.276,384.952 529.538,384.952 562.801,384.952 596.063,384.952 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 93,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Vemos que la convergencia es lineal para h, aunque de orden 4 para las demas funciones, tiene mejor convergencia que el método de la secante ya que evalua en dos puntos la funcion $f$ (aunque sería una desventaja si $f$ es complicada)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Julia 0.5.0",
"language": "julia",
"name": "julia-0.5"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.5.0"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Tarea 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Punto 1\n",
"Escriba una fórmula que involucre $a,b$ y $\\epsilon$ para calcular el número de iteraciones necesarias para garantizar que el método de la bisección tenga un error menor a $\\epsilon$"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Solución\n",
"Tenemos la siguiente relación:\n",
"$$\n",
"| r - c_n | \\leq 2^{-(n+1)}(b - a) \\\\\n",
"\\epsilon \\leq 2^{-(n+1)}(b - a) \\leq 2^{-n} (b-a)\\\\\n",
"\\frac{\\epsilon}{b-a} \\leq 2^{-n} \\\\\n",
"n \\geq \\log_2 \\frac{ b - a } {\\epsilon}\n",
"$$"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": true
},
"source": [
"# Punto 2\n",
"Sea $ f \\in C^{m+1}([a,b])$ y $r$ una raíz de multiplicidad $m > 1$. Muestre que en este caso el método de Newton tiene órden de convergencia lineal y además:\n",
"\n",
"$$\n",
"\\lim_{n \\rightarrow \\infty} \\frac{ | e_{n+1} | }{ | e_n | } = \\frac{m-1}{m} . \n",
"$$\n",
"\n",
"Mostramos ahora que\n",
"\n",
"$$\n",
"\\lim_{n \\rightarrow \\infty} \\frac{ | e_{n+1} | }{ | e_n | } = \\frac{m-1}{m} . \n",
"$$\n",
"\n",
"Observamos que $ e_{n+1} = x_{n+1} - r $\n",
"Es decir que:\n",
"$$\n",
"e_{n+1} = x_n - \\frac{(x-r)^m g(x) }{ m (x-r)^{m-1}g(x) + (x-r)^m g'(x) } - r\n",
"$$\n",
"Tomando la razon de $e_{n}$, tenemos $x=x_n$\n",
"$$\n",
"\\frac{ e_{n+1} }{e_n} = \\frac{ e_n - \\frac{(x-r)^m g(x) }{ m (x-r)^{m-1}g(x) + (x-r)^m g'(x) }}{e_n} \\\\\n",
"\\frac{ e_{n+1} }{e_n} = 1 - \\frac{(x-r)^m g(x) }{ e_n(m (x-r)^{m-1}g(x) + (x-r)^m g'(x)) } \\\\\n",
"\\frac{ e_{n+1} }{e_n} = 1 - \\frac{(x-r)g(x)}{(x-r)(mg(x) + (x-r)g'(x)} \\\\\n",
"\\frac{ e_{n+1} }{e_n} = 1 - \\frac{ g(x_n) }{mg(x_n) + (x_n -r)g'(x_n)}\n",
"$$\n",
"Tomando el límite\n",
"$$\n",
"\\lim_{n \\rightarrow \\infty} 1 - \\frac{ g(x_n) }{mg(x_n) + (x_n -r)g'(x_n)} \\\\\n",
"\\lim_{n \\rightarrow \\infty} 1 - \\frac{g(x_n)}{mg(x_n)} \\\\\n",
"\\lim_{n \\rightarrow \\infty} 1 - \\frac{1}{m} \\\\\n",
"\\frac{m-1}{m}\n",
"$$\n",
"Como el límite para $m>1$ es mas pequeño que $1$ concluimos que la convergencia es lineal.\n"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# Punto 3\n",
"\n",
"Condiciones para que Newton-Raphson tenga convergencia cubica"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Para que $f$ tenga convergencia cubica, se necesita que $f''($"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"using Plots\n",
"using Calculus"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"Plots.GRBackend()"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"gr()"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"BisectionMethod (generic function with 1 method)"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function BisectionMethod(f::Function,a::Number,b::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" u = f(a)\n",
" v = f(b) \n",
" e = b - a\n",
" w = 0\n",
" c = 0 \n",
" if sign(u) == sign(v)\n",
" error(\"Not a suitable interval\")\n",
" end\n",
" for i in 1:steps\n",
" e = e/2\n",
" c = a + e\n",
" w = f(c)\n",
" if (abs(e) < δ) || (abs(w) < ϵ)\n",
" return c\n",
" end\n",
" if sign(w) != sign(u)\n",
" b = c\n",
" v = w\n",
" else\n",
" a = c\n",
" u = w\n",
" end\n",
" end\n",
" return c\n",
"end "
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"BisectionMethod! (generic function with 1 method)"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function BisectionMethod!(f::Function,a::Number,b::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" u = f(a)\n",
" v = f(b) \n",
" e = b - a\n",
" w = 0\n",
" c = 0\n",
" roots = Array{Float64}(0)\n",
" if sign(u) == sign(v)\n",
" error(\"Not a suitable interval\")\n",
" end\n",
" for i in 1:steps\n",
" e = e/2\n",
" c = a + e\n",
" w = f(c)\n",
" push!(roots,c)\n",
" if (abs(e) < δ) || (abs(w) < ϵ)\n",
" return roots\n",
" end\n",
" if sign(w) != sign(u)\n",
" b = c\n",
" v = w\n",
" else\n",
" a = c\n",
" u = w\n",
" end\n",
" end\n",
" return roots\n",
"end "
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"NewtonRaphsonMethod (generic function with 1 method)"
]
},
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function NewtonRaphsonMethod(f::Function,fder::Function,x0::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" if abs(v) < ϵ\n",
" return x0\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - v/(fder(x0))\n",
" v = f(x1)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return x1\n",
" end\n",
" x0 = x1\n",
" end\n",
" return x0\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"2.220446049250313e-16"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"eps()"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"NewtonRaphsonMethod! (generic function with 1 method)"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function NewtonRaphsonMethod!(f::Function,fder::Function,x0::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" roots = Array{Float64}(1)\n",
" if abs(v) < ϵ\n",
" return push!(roots,x0)\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - v/(fder(x0))\n",
" push!(roots,x1)\n",
" v = f(x1)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return roots\n",
" end\n",
" x0 = x1\n",
" end\n",
" return roots\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SecantMethod (generic function with 2 methods)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function SecantMethod(f::Function, x0::Number, x1::Number, args::Tuple=();\n",
" tol::AbstractFloat=1e-12, maxiter::Integer=500)\n",
" x = 0.0\n",
" for _ in 1:maxiter\n",
" y1 = f(x1, args...)\n",
" y0 = f(x0, args...)\n",
" x = x1 - y1 * (x1-x0)/(y1-y0)\n",
" if abs(x-x1) < tol\n",
" return x\n",
" end\n",
" x0 = x1\n",
" x1 = x\n",
" end\n",
" warn(\"Max iteration exceeded\")\n",
" return x\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SecantMethod! (generic function with 2 methods)"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function SecantMethod!(f::Function, x0::Number, x1::Number, args::Tuple=();\n",
" tol::AbstractFloat=1e-12, maxiter::Integer=500)\n",
" x = 0.0\n",
" roots = Array{Float64}(0)\n",
" for _ in 1:maxiter\n",
" y1 = f(x1, args...)\n",
" y0 = f(x0, args...)\n",
" x = x1 - y1 * (x1-x0)/(y1-y0)\n",
" push!(roots,x)\n",
" if abs(x-x1) < tol\n",
" return roots\n",
" end\n",
" x0 = x1\n",
" x1 = x\n",
" end\n",
" warn(\"Max iteration exceeded\")\n",
" return roots\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"logpoints (generic function with 1 method)"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function logpoints(x::Array{Float64,1})\n",
" points = Array{Float64}(0)\n",
" for i in 1:(size(x)[1] - 2)\n",
" a = log(abs(x[i+1]))/log(abs(x[i]))\n",
" if (a != 0) && (a != Inf)\n",
" push!(points,a)\n",
" end\n",
" end\n",
" return points\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"f(x) = 1/x - exp(x)\n",
"fprime = f'\n",
"g(x) = x - tan(x)\n",
"gprime = g'\n",
"h(x) = sin(x) + x^2*cos(x) - x^2 - x\n",
"hprime = h';"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Encontramos un cero de $f$."
]
},
{
"cell_type": "code",
"execution_count": 12,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.5671432904097838"
]
},
"execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootf = BisectionMethod(f,0,1)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 13,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"f(rootf)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Encontremos los valores de $\\frac{e_{n+1}}{e_n}$"
]
},
{
"cell_type": "code",
"execution_count": 14,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(BisectionMethod!(f,0,1) .- rootf);"
]
},
{
"cell_type": "code",
"execution_count": 15,
"metadata": {
"collapsed": false,
"scrolled": true
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"30.6037,384.952 596.063,384.952 596.063,3.93701 30.6037,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"30\" y=\"3\" width=\"566\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 132.386,379.237 132.386,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 245.478,379.237 245.478,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 358.57,379.237 358.57,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 471.662,379.237 471.662,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 584.754,379.237 584.754,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,272.436 587.581,272.436 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,120.771 587.581,120.771 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 132.386,384.952 132.386,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 245.478,384.952 245.478,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 358.57,384.952 358.57,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 471.662,384.952 471.662,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 584.754,384.952 584.754,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,272.436 39.0856,272.436 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,120.771 39.0856,120.771 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 132.386, 396.952)\" x=\"132.386\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 245.478, 396.952)\" x=\"245.478\" y=\"396.952\">20</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 358.57, 396.952)\" x=\"358.57\" y=\"396.952\">30</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 471.662, 396.952)\" x=\"471.662\" y=\"396.952\">40</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 584.754, 396.952)\" x=\"584.754\" y=\"396.952\">50</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 276.936)\" x=\"29.4037\" y=\"276.936\">1.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 125.271)\" x=\"29.4037\" y=\"125.271\">1.5</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 41.9129,66.9965 53.222,3.93701 64.5312,371.003 75.8404,198.419 87.1496,188.88 98.4588,195.547 109.768,293.494 121.077,199.011 132.386,273.812 \n",
" 143.696,126.732 155.005,352.332 166.314,247.857 177.623,248.295 188.932,246.887 200.241,238.995 211.551,240.927 222.86,279.284 234.169,228.282 245.478,287.5 \n",
" 256.787,245.907 268.097,252.598 279.406,271.464 290.715,210.244 302.024,313.574 313.333,259.792 324.643,259.129 335.952,256.574 347.261,239.006 358.57,288.55 \n",
" 369.879,257.887 381.188,239.005 392.498,290.894 403.807,260.506 415.116,254.222 426.425,268.349 437.734,254.671 449.044,279.166 460.353,256.292 471.662,268.019 \n",
" 482.971,258.585 494.28,275.828 505.59,253.147 516.899,278.677 528.208,258.843 539.517,267.126 550.826,263.966 562.135,270.229 573.445,255.47 584.754,281.507 \n",
" 596.063,263.085 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 15,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.5671432904097838"
]
},
"execution_count": 16,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootf = NewtonRaphsonMethod(f, fprime, 3)"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(NewtonRaphsonMethod!(f,fprime,3) .- rootf);"
]
},
{
"cell_type": "code",
"execution_count": 18,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"12.8259,384.952 596.063,384.952 596.063,3.93701 12.8259,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"12\" y=\"3\" width=\"584\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 12.8259,379.237 12.8259,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 129.473,379.237 129.473,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 246.121,379.237 246.121,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 362.768,379.237 362.768,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 479.416,379.237 479.416,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 596.063,379.237 596.063,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,319.141 587.314,319.141 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,236.688 587.314,236.688 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,154.234 587.314,154.234 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,71.7806 587.314,71.7806 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 12.8259,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 129.473,384.952 129.473,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 246.121,384.952 246.121,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 362.768,384.952 362.768,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 479.416,384.952 479.416,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 596.063,384.952 596.063,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 12.8259,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,319.141 21.5745,319.141 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,236.688 21.5745,236.688 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,154.234 21.5745,154.234 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,71.7806 21.5745,71.7806 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 12.8259, 396.952)\" x=\"12.8259\" y=\"396.952\">1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 129.473, 396.952)\" x=\"129.473\" y=\"396.952\">2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 246.121, 396.952)\" x=\"246.121\" y=\"396.952\">3</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 362.768, 396.952)\" x=\"362.768\" y=\"396.952\">4</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 479.416, 396.952)\" x=\"479.416\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 596.063, 396.952)\" x=\"596.063\" y=\"396.952\">6</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 323.641)\" x=\"11.6259\" y=\"323.641\">0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 241.188)\" x=\"11.6259\" y=\"241.188\">2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 158.734)\" x=\"11.6259\" y=\"158.734\">4</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 76.2806)\" x=\"11.6259\" y=\"76.2806\">6</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,346.394 129.473,384.952 246.121,3.93701 362.768,236.394 479.416,236.431 596.063,236.942 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 19,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[1m\u001b[31mWARNING: Max iteration exceeded\u001b[0m\n"
]
},
{
"data": {
"text/plain": [
"-1.2835157962052e105"
]
},
"execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootf = SecantMethod(f,-1,1,)"
]
},
{
"cell_type": "code",
"execution_count": 20,
"metadata": {
"collapsed": false
},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"\u001b[1m\u001b[31mWARNING: Max iteration exceeded\u001b[0m\n"
]
}
],
"source": [
"errors = abs(SecantMethod!(f,-1,1) .- rootf);"
]
},
{
"cell_type": "code",
"execution_count": 21,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"57.2703,384.952 596.063,384.952 596.063,3.93701 57.2703,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"57\" y=\"3\" width=\"539\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 164.595,379.237 164.595,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 273.004,379.237 273.004,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 381.413,379.237 381.413,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 489.822,379.237 489.822,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 65.3522,290.807 587.981,290.807 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 65.3522,195.184 587.981,195.184 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 65.3522,99.5605 587.981,99.5605 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 65.3522,3.93701 587.981,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 164.595,384.952 164.595,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 273.004,384.952 273.004,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 381.413,384.952 381.413,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 489.822,384.952 489.822,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,384.952 57.2703,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,290.807 65.3522,290.807 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,195.184 65.3522,195.184 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,99.5605 65.3522,99.5605 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,3.93701 65.3522,3.93701 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 164.595, 396.952)\" x=\"164.595\" y=\"396.952\">100</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 273.004, 396.952)\" x=\"273.004\" y=\"396.952\">200</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 381.413, 396.952)\" x=\"381.413\" y=\"396.952\">300</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 489.822, 396.952)\" x=\"489.822\" y=\"396.952\">400</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 56.0703, 295.307)\" x=\"56.0703\" y=\"295.307\">0.9985</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 56.0703, 199.684)\" x=\"56.0703\" y=\"199.684\">0.9990</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 56.0703, 104.06)\" x=\"56.0703\" y=\"104.06\">0.9995</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 56.0703, 8.43701)\" x=\"56.0703\" y=\"8.43701\">1.0000</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 57.2703,3.93701 58.3544,3.93701 59.4385,3.93701 60.5226,3.93701 61.6067,3.93701 62.6908,3.93701 63.7749,3.93701 64.859,3.93701 65.9431,3.93701 67.0271,3.93701 \n",
" 68.1112,3.93701 69.1953,3.93701 70.2794,3.93701 71.3635,3.93701 72.4476,3.93701 73.5317,3.93701 74.6158,3.93701 75.6999,3.93701 76.784,3.93701 77.868,3.93701 \n",
" 78.9521,3.93701 80.0362,3.93701 81.1203,3.93701 82.2044,3.93701 83.2885,3.93701 84.3726,3.93701 85.4567,3.93701 86.5408,3.93701 87.6249,3.93701 88.7089,3.93701 \n",
" 89.793,3.93701 90.8771,3.93701 91.9612,3.93701 93.0453,3.93701 94.1294,3.93701 95.2135,3.93701 96.2976,3.93701 97.3817,3.93701 98.4658,3.93701 99.5498,3.93701 \n",
" 100.634,3.93701 101.718,3.93701 102.802,3.93701 103.886,3.93701 104.97,3.93701 106.054,3.93701 107.138,3.93701 108.223,3.93701 109.307,3.93701 110.391,3.93701 \n",
" 111.475,3.93701 112.559,3.93701 113.643,3.93701 114.727,3.93701 115.811,3.93701 116.895,3.93701 117.979,3.93701 119.063,3.93701 120.148,3.93701 121.232,3.93701 \n",
" 122.316,3.93701 123.4,3.93701 124.484,3.93701 125.568,3.93701 126.652,3.93701 127.736,3.93701 128.82,3.93701 129.904,3.93701 130.988,3.93701 132.073,3.93701 \n",
" 133.157,3.93701 134.241,3.93701 135.325,3.93701 136.409,3.93701 137.493,3.93701 138.577,3.93701 139.661,3.93701 140.745,3.93701 141.829,3.93701 142.913,3.93701 \n",
" 143.998,3.93701 145.082,3.93701 146.166,3.93701 147.25,3.93701 148.334,3.93701 149.418,3.93701 150.502,3.93701 151.586,3.93701 152.67,3.93701 153.754,3.93701 \n",
" 154.838,3.93701 155.923,3.93701 157.007,3.93701 158.091,3.93701 159.175,3.93701 160.259,3.93701 161.343,3.93701 162.427,3.93701 163.511,3.93701 164.595,3.93701 \n",
" 165.679,3.93701 166.763,3.93701 167.848,3.93701 168.932,3.93701 170.016,3.93701 171.1,3.93701 172.184,3.93701 173.268,3.93701 174.352,3.93701 175.436,3.93701 \n",
" 176.52,3.93701 177.604,3.93701 178.688,3.93701 179.772,3.93701 180.857,3.93701 181.941,3.93701 183.025,3.93701 184.109,3.93701 185.193,3.93701 186.277,3.93701 \n",
" 187.361,3.93701 188.445,3.93701 189.529,3.93701 190.613,3.93701 191.697,3.93701 192.782,3.93701 193.866,3.93701 194.95,3.93701 196.034,3.93701 197.118,3.93701 \n",
" 198.202,3.93701 199.286,3.93701 200.37,3.93701 201.454,3.93701 202.538,3.93701 203.622,3.93701 204.707,3.93701 205.791,3.93701 206.875,3.93701 207.959,3.93701 \n",
" 209.043,3.93701 210.127,3.93701 211.211,3.93701 212.295,3.93701 213.379,3.93701 214.463,3.93701 215.547,3.93701 216.632,3.93701 217.716,3.93701 218.8,3.93701 \n",
" 219.884,3.93701 220.968,3.93701 222.052,3.93701 223.136,3.93701 224.22,3.93701 225.304,3.93701 226.388,3.93701 227.472,3.93701 228.557,3.93701 229.641,3.93701 \n",
" 230.725,3.93701 231.809,3.93701 232.893,3.93701 233.977,3.93701 235.061,3.93701 236.145,3.93701 237.229,3.93701 238.313,3.93701 239.397,3.93701 240.482,3.93701 \n",
" 241.566,3.93701 242.65,3.93701 243.734,3.93701 244.818,3.93701 245.902,3.93701 246.986,3.93701 248.07,3.93701 249.154,3.93701 250.238,3.93701 251.322,3.93701 \n",
" 252.407,3.93701 253.491,3.93701 254.575,3.93701 255.659,3.93701 256.743,3.93701 257.827,3.93701 258.911,3.93701 259.995,3.93701 261.079,3.93701 262.163,3.93701 \n",
" 263.247,3.93701 264.332,3.93701 265.416,3.93701 266.5,3.93701 267.584,3.93701 268.668,3.93701 269.752,3.93701 270.836,3.93701 271.92,3.93701 273.004,3.93701 \n",
" 274.088,3.93701 275.172,3.93701 276.256,3.93701 277.341,3.93701 278.425,3.93701 279.509,3.93701 280.593,3.93701 281.677,3.93701 282.761,3.93701 283.845,3.93701 \n",
" 284.929,3.93701 286.013,3.93701 287.097,3.93701 288.181,3.93701 289.266,3.93701 290.35,3.93701 291.434,3.93701 292.518,3.93701 293.602,3.93701 294.686,3.93701 \n",
" 295.77,3.93701 296.854,3.93701 297.938,3.93701 299.022,3.93701 300.106,3.93701 301.191,3.93701 302.275,3.93701 303.359,3.93701 304.443,3.93701 305.527,3.93701 \n",
" 306.611,3.93701 307.695,3.93701 308.779,3.93701 309.863,3.93701 310.947,3.93701 312.031,3.93701 313.116,3.93701 314.2,3.93701 315.284,3.93701 316.368,3.93701 \n",
" 317.452,3.93701 318.536,3.93701 319.62,3.93701 320.704,3.93701 321.788,3.93701 322.872,3.93701 323.956,3.93701 325.041,3.93701 326.125,3.93701 327.209,3.93701 \n",
" 328.293,3.93701 329.377,3.93701 330.461,3.93701 331.545,3.93701 332.629,3.93701 333.713,3.93701 334.797,3.93701 335.881,3.93701 336.966,3.93701 338.05,3.93701 \n",
" 339.134,3.93701 340.218,3.93701 341.302,3.93701 342.386,3.93701 343.47,3.93701 344.554,3.93701 345.638,3.93701 346.722,3.93701 347.806,3.93701 348.891,3.93701 \n",
" 349.975,3.93701 351.059,3.93701 352.143,3.93701 353.227,3.93701 354.311,3.93701 355.395,3.93701 356.479,3.93701 357.563,3.93701 358.647,3.93701 359.731,3.93701 \n",
" 360.815,3.93701 361.9,3.93701 362.984,3.93701 364.068,3.93701 365.152,3.93701 366.236,3.93701 367.32,3.93701 368.404,3.93701 369.488,3.93701 370.572,3.93701 \n",
" 371.656,3.93701 372.74,3.93701 373.825,3.93701 374.909,3.93701 375.993,3.93701 377.077,3.93701 378.161,3.93701 379.245,3.93701 380.329,3.93701 381.413,3.93701 \n",
" 382.497,3.93701 383.581,3.93701 384.665,3.93701 385.75,3.93701 386.834,3.93701 387.918,3.93701 389.002,3.93701 390.086,3.93701 391.17,3.93701 392.254,3.93701 \n",
" 393.338,3.93701 394.422,3.93701 395.506,3.93701 396.59,3.93701 397.675,3.93701 398.759,3.93701 399.843,3.93701 400.927,3.93701 402.011,3.93701 403.095,3.93701 \n",
" 404.179,3.93701 405.263,3.93701 406.347,3.93701 407.431,3.93701 408.515,3.93701 409.6,3.93701 410.684,3.93701 411.768,3.93701 412.852,3.93701 413.936,3.93701 \n",
" 415.02,3.93701 416.104,3.93701 417.188,3.93701 418.272,3.93701 419.356,3.93701 420.44,3.93701 421.525,3.93701 422.609,3.93701 423.693,3.93701 424.777,3.93701 \n",
" 425.861,3.93701 426.945,3.93701 428.029,3.93701 429.113,3.93701 430.197,3.93701 431.281,3.93701 432.365,3.93701 433.45,3.93701 434.534,3.93701 435.618,3.93701 \n",
" 436.702,3.93701 437.786,3.93701 438.87,3.93701 439.954,3.93701 441.038,3.93701 442.122,3.93701 443.206,3.93701 444.29,3.93701 445.375,3.93701 446.459,3.93701 \n",
" 447.543,3.93701 448.627,3.93701 449.711,3.93701 450.795,3.93701 451.879,3.93701 452.963,3.93701 454.047,3.93701 455.131,3.93701 456.215,3.93701 457.299,3.93701 \n",
" 458.384,3.93701 459.468,3.93701 460.552,3.93701 461.636,3.93701 462.72,3.93701 463.804,3.93701 464.888,3.93701 465.972,3.93701 467.056,3.93701 468.14,3.93701 \n",
" 469.224,3.93701 470.309,3.93701 471.393,3.93701 472.477,3.93701 473.561,3.93701 474.645,3.93701 475.729,3.93701 476.813,3.93701 477.897,3.93701 478.981,3.93701 \n",
" 480.065,3.93701 481.149,3.93701 482.234,3.93701 483.318,3.93701 484.402,3.93701 485.486,3.93701 486.57,3.93701 487.654,3.93701 488.738,3.93701 489.822,3.93701 \n",
" 490.906,3.93701 491.99,3.93701 493.074,3.93701 494.159,3.93701 495.243,3.93701 496.327,3.93701 497.411,3.93701 498.495,3.93701 499.579,3.93701 500.663,3.93701 \n",
" 501.747,3.93701 502.831,3.93701 503.915,3.93701 504.999,3.93701 506.084,3.93701 507.168,3.93701 508.252,3.93701 509.336,3.93701 510.42,3.93701 511.504,3.93701 \n",
" 512.588,3.93701 513.672,3.93701 514.756,3.93701 515.84,3.93701 516.924,3.93701 518.009,3.93701 519.093,3.93701 520.177,3.93701 521.261,3.93701 522.345,3.93701 \n",
" 523.429,3.93701 524.513,3.93701 525.597,3.93701 526.681,3.93701 527.765,3.93701 528.849,3.93701 529.934,3.93701 531.018,3.93701 532.102,3.93701 533.186,3.93701 \n",
" 534.27,3.93701 535.354,3.93701 536.438,3.93701 537.522,3.93701 538.606,3.93701 539.69,3.93701 540.774,3.93701 541.859,3.93701 542.943,3.93701 544.027,3.93701 \n",
" 545.111,3.93701 546.195,3.93701 547.279,3.93701 548.363,3.93701 549.447,3.93701 550.531,3.93701 551.615,3.93701 552.699,3.93701 553.783,3.93701 554.868,3.93701 \n",
" 555.952,3.93701 557.036,3.93701 558.12,3.93702 559.204,3.93702 560.288,3.93703 561.372,3.93705 562.456,3.93707 563.54,3.93711 564.624,3.93717 565.708,3.93727 \n",
" 566.793,3.93743 567.877,3.9377 568.961,3.93812 570.045,3.93881 571.129,3.93992 572.213,3.94172 573.297,3.94463 574.381,3.94934 575.465,3.95696 576.549,3.9693 \n",
" 577.633,3.98925 578.718,4.02155 579.802,4.07382 580.886,4.15842 581.97,4.2954 583.054,4.51724 584.138,4.87675 585.222,5.45993 586.306,6.4074 587.39,7.95066 \n",
" 588.474,10.4749 589.558,14.6318 590.643,21.555 591.727,33.3052 592.811,53.9034 593.895,92.1594 594.979,171.597 596.063,384.952 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 21,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ahora para $g$"
]
},
{
"cell_type": "code",
"execution_count": 22,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"4.493409457909063"
]
},
"execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootg = BisectionMethod(g,3.2,4.6)"
]
},
{
"cell_type": "code",
"execution_count": 23,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(BisectionMethod!(g,3.2,4.6) .- rootg);"
]
},
{
"cell_type": "code",
"execution_count": 24,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"12.8259,384.952 596.063,384.952 596.063,3.93701 12.8259,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"12\" y=\"3\" width=\"584\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 124.51,379.237 124.51,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 248.603,379.237 248.603,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 372.696,379.237 372.696,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 496.789,379.237 496.789,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,323.214 587.314,323.214 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,136.238 587.314,136.238 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 124.51,384.952 124.51,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 248.603,384.952 248.603,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 372.696,384.952 372.696,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 496.789,384.952 496.789,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 12.8259,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,323.214 21.5745,323.214 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,136.238 21.5745,136.238 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 124.51, 396.952)\" x=\"124.51\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 248.603, 396.952)\" x=\"248.603\" y=\"396.952\">20</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 372.696, 396.952)\" x=\"372.696\" y=\"396.952\">30</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 496.789, 396.952)\" x=\"496.789\" y=\"396.952\">40</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 327.714)\" x=\"11.6259\" y=\"327.714\">1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 140.738)\" x=\"11.6259\" y=\"140.738\">2</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,3.93701 25.2352,155.264 37.6445,234.244 50.0538,335.304 62.4631,213.071 74.8724,357.355 87.2817,280.022 99.691,197.471 112.1,384.952 124.51,302.58 \n",
" 136.919,303.524 149.328,302.965 161.737,297.752 174.147,294.575 186.556,333.394 198.965,299.148 211.375,315.82 223.784,307.119 236.193,323.804 248.603,272.941 \n",
" 261.012,354.932 273.421,313.947 285.83,313.72 298.24,312.552 310.649,306.936 323.058,320.786 335.468,304.04 347.877,333.156 360.286,313.091 372.696,288.504 \n",
" 385.105,346.86 397.514,316.925 409.923,316.725 422.333,315.968 434.742,312.899 447.151,316.753 459.561,320.833 471.97,312.056 484.379,327.723 496.789,313.847 \n",
" 509.198,318.96 521.607,318.448 534.016,319.688 546.426,317.814 558.835,321.685 571.244,309.908 583.654,330.693 596.063,315.423 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 24,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"4.493409457909064"
]
},
"execution_count": 25,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootg = NewtonRaphsonMethod(g,gprime,4.4)"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(NewtonRaphsonMethod!(g,gprime,4.4) .- rootg);"
]
},
{
"cell_type": "code",
"execution_count": 27,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"30.6037,384.952 596.063,384.952 596.063,3.93701 30.6037,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"30\" y=\"3\" width=\"566\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.6037,379.237 30.6037,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 171.969,379.237 171.969,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 313.333,379.237 313.333,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 454.698,379.237 454.698,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 596.063,379.237 596.063,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,328.143 587.581,328.143 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,198.649 587.581,198.649 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,69.1552 587.581,69.1552 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 171.969,384.952 171.969,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 313.333,384.952 313.333,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 454.698,384.952 454.698,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 596.063,384.952 596.063,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,328.143 39.0856,328.143 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,198.649 39.0856,198.649 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,69.1552 39.0856,69.1552 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 30.6037, 396.952)\" x=\"30.6037\" y=\"396.952\">1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 171.969, 396.952)\" x=\"171.969\" y=\"396.952\">2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 313.333, 396.952)\" x=\"313.333\" y=\"396.952\">3</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 454.698, 396.952)\" x=\"454.698\" y=\"396.952\">4</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 596.063, 396.952)\" x=\"596.063\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 332.643)\" x=\"29.4037\" y=\"332.643\">1.6</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 203.149)\" x=\"29.4037\" y=\"203.149\">1.8</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 73.6552)\" x=\"29.4037\" y=\"73.6552\">2.0</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,3.93701 171.969,384.952 313.333,279.188 454.698,194.694 596.063,138.953 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(abs(logpoints(errors)))"
]
},
{
"cell_type": "code",
"execution_count": 28,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"4.493409457909064"
]
},
"execution_count": 28,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootg = SecantMethod(g,4.4,4.5)"
]
},
{
"cell_type": "code",
"execution_count": 29,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"errors = abs(SecantMethod!(g,4.4,4.5) .- rootg);"
]
},
{
"cell_type": "code",
"execution_count": 30,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"39.4926,384.952 596.063,384.952 596.063,3.93701 39.4926,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"39\" y=\"3\" width=\"557\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.4926,379.237 39.4926,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 132.254,379.237 132.254,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 225.016,379.237 225.016,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 317.778,379.237 317.778,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 410.54,379.237 410.54,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 503.301,379.237 503.301,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 596.063,379.237 596.063,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 47.8411,272.411 587.714,272.411 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 47.8411,131.923 587.714,131.923 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,384.952 39.4926,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 132.254,384.952 132.254,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 225.016,384.952 225.016,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 317.778,384.952 317.778,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 410.54,384.952 410.54,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 503.301,384.952 503.301,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 596.063,384.952 596.063,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,384.952 39.4926,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,272.411 47.8411,272.411 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,131.923 47.8411,131.923 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 39.4926, 396.952)\" x=\"39.4926\" y=\"396.952\">1.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 132.254, 396.952)\" x=\"132.254\" y=\"396.952\">1.5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 225.016, 396.952)\" x=\"225.016\" y=\"396.952\">2.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 317.778, 396.952)\" x=\"317.778\" y=\"396.952\">2.5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 410.54, 396.952)\" x=\"410.54\" y=\"396.952\">3.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 503.301, 396.952)\" x=\"503.301\" y=\"396.952\">3.5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 596.063, 396.952)\" x=\"596.063\" y=\"396.952\">4.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 38.2926, 276.911)\" x=\"38.2926\" y=\"276.911\">1.50</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 38.2926, 136.423)\" x=\"38.2926\" y=\"136.423\">1.55</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 39.4926,3.93701 225.016,384.952 410.54,73.647 596.063,104.191 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Ahora para $h$"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.0"
]
},
"execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rooth = BisectionMethod(h,-0.3,0.3)"
]
},
{
"cell_type": "code",
"execution_count": 32,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(BisectionMethod!(h,-.3,3) .- rooth);"
]
},
{
"cell_type": "code",
"execution_count": 33,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"21.7148,384.952 596.063,384.952 596.063,3.93701 21.7148,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"21\" y=\"3\" width=\"575\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 213.164,379.237 213.164,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 452.476,379.237 452.476,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,374.83 587.448,374.83 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,237.225 587.448,237.225 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,99.6191 587.448,99.6191 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 213.164,384.952 213.164,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 452.476,384.952 452.476,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 21.7148,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,374.83 30.33,374.83 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,237.225 30.33,237.225 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,99.6191 30.33,99.6191 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 213.164, 396.952)\" x=\"213.164\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 452.476, 396.952)\" x=\"452.476\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 379.33)\" x=\"20.5148\" y=\"379.33\">-2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 241.725)\" x=\"20.5148\" y=\"241.725\">0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 104.119)\" x=\"20.5148\" y=\"104.119\">2</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 69.5771,3.93701 117.439,162.68 165.302,101.495 213.164,190.583 261.027,147.895 308.889,142.635 356.751,166.202 404.614,141.261 452.476,181.142 \n",
" 500.338,158.623 548.201,154.432 596.063,167.046 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 33,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 34,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"1.0353844404253541e-5"
]
},
"execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rooth = NewtonRaphsonMethod(h,hprime,0.2)"
]
},
{
"cell_type": "code",
"execution_count": 35,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(NewtonRaphsonMethod!(h,hprime,0.2) .- rooth);"
]
},
{
"cell_type": "code",
"execution_count": 36,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"30.6037,384.952 596.063,384.952 596.063,3.93701 30.6037,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"30\" y=\"3\" width=\"566\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 128.944,379.237 128.944,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 251.87,379.237 251.87,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 374.796,379.237 374.796,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 497.722,379.237 497.722,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,374.011 587.581,374.011 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,298.827 587.581,298.827 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,223.643 587.581,223.643 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,148.459 587.581,148.459 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,73.2746 587.581,73.2746 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 128.944,384.952 128.944,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 251.87,384.952 251.87,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 374.796,384.952 374.796,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 497.722,384.952 497.722,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,374.011 39.0856,374.011 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,298.827 39.0856,298.827 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,223.643 39.0856,223.643 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,148.459 39.0856,148.459 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,73.2746 39.0856,73.2746 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 128.944, 396.952)\" x=\"128.944\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 251.87, 396.952)\" x=\"251.87\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 374.796, 396.952)\" x=\"374.796\" y=\"396.952\">15</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 497.722, 396.952)\" x=\"497.722\" y=\"396.952\">20</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 378.511)\" x=\"29.4037\" y=\"378.511\">0.2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 303.327)\" x=\"29.4037\" y=\"303.327\">0.4</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 228.143)\" x=\"29.4037\" y=\"228.143\">0.6</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 152.959)\" x=\"29.4037\" y=\"152.959\">0.8</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 77.7746)\" x=\"29.4037\" y=\"77.7746\">1.0</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 55.1889,3.93701 79.774,13.2326 104.359,20.3483 128.944,26.0339 153.53,30.7107 178.115,34.6309 202.7,37.9573 227.285,40.8038 251.87,43.2554 \n",
" 276.456,45.3775 301.041,47.2216 325.626,48.8277 350.211,50.2257 374.796,51.4363 399.381,52.4709 423.967,53.3297 448.552,53.9986 473.137,54.4418 497.722,54.5853 \n",
" 522.307,54.2786 546.893,53.1893 571.478,50.4317 596.063,42.5287 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 36,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"-0.3345821606680503"
]
},
"execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rooth = SecantMethod(h,-0.5,0.5)"
]
},
{
"cell_type": "code",
"execution_count": 38,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"errors = abs(SecantMethod!(h,-0.5,0.5) .- rooth);"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"21.7148,384.952 596.063,384.952 596.063,3.93701 21.7148,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"21\" y=\"3\" width=\"575\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 198.437,379.237 198.437,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 419.34,379.237 419.34,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,350.088 587.448,350.088 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,217.673 587.448,217.673 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.33,85.2577 587.448,85.2577 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 198.437,384.952 198.437,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 419.34,384.952 419.34,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 21.7148,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,350.088 30.33,350.088 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,217.673 30.33,217.673 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,85.2577 30.33,85.2577 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 198.437, 396.952)\" x=\"198.437\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 419.34, 396.952)\" x=\"419.34\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 354.588)\" x=\"20.5148\" y=\"354.588\">-1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 222.173)\" x=\"20.5148\" y=\"222.173\">0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 20.5148, 89.7577)\" x=\"20.5148\" y=\"89.7577\">1</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 21.7148,384.952 65.8954,317.884 110.076,91.7645 154.257,3.93701 198.437,54.2391 242.618,47.1837 286.799,52.5479 330.979,50.3029 375.16,47.84 419.34,42.1266 \n",
" 463.521,34.6992 507.702,26.512 551.882,19.483 596.063,14.141 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 40,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"NewtonRaphsonMethodModified! (generic function with 1 method)"
]
},
"execution_count": 40,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function NewtonRaphsonMethodModified!(f::Function,fder::Function,x0::Number;m::UInt64=1,steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" roots = Array{Float64}(0)\n",
" if abs(v) < ϵ\n",
" return push!(roots,x0)\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - m*(v/(fder(x0)))\n",
" push!(roots,x1)\n",
" v = f(x1)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return roots\n",
" end\n",
" x0 = x1\n",
" end\n",
" return roots\n",
" \n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"NewtonRaphsonMethodModified (generic function with 1 method)"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function NewtonRaphsonMethodModified(f::Function,fder::Function,x0::Number;m::UInt64=1,steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" if abs(v) < ϵ\n",
" return x0\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - m*(v/(fder(x0)))\n",
" v = f(x1)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return x1\n",
" end\n",
" x0 = x1\n",
" end\n",
" return x0\n",
"end\n"
]
},
{
"cell_type": "code",
"execution_count": 42,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"2.2295541974719528e-7"
]
},
"execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rooth = NewtonRaphsonMethodModified(h,hprime,0.2,m=UInt(3),steps=UInt(100))"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"errors = abs(NewtonRaphsonMethodModified!(h,hprime,1,m=UInt(3),steps=UInt(100)) .- rooth);"
]
},
{
"cell_type": "code",
"execution_count": 44,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"30.6037,384.952 596.063,384.952 596.063,3.93701 30.6037,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"30\" y=\"3\" width=\"566\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 30.6037,379.237 30.6037,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 171.969,379.237 171.969,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 313.333,379.237 313.333,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 454.698,379.237 454.698,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 596.063,379.237 596.063,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,266.063 587.581,266.063 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,125.213 587.581,125.213 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 171.969,384.952 171.969,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 313.333,384.952 313.333,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 454.698,384.952 454.698,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 596.063,384.952 596.063,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,266.063 39.0856,266.063 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,125.213 39.0856,125.213 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 30.6037, 396.952)\" x=\"30.6037\" y=\"396.952\">1.00</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 171.969, 396.952)\" x=\"171.969\" y=\"396.952\">1.25</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 313.333, 396.952)\" x=\"313.333\" y=\"396.952\">1.50</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 454.698, 396.952)\" x=\"454.698\" y=\"396.952\">1.75</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 596.063, 396.952)\" x=\"596.063\" y=\"396.952\">2.00</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 270.563)\" x=\"29.4037\" y=\"270.563\">2.1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 129.713)\" x=\"29.4037\" y=\"129.713\">2.2</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,3.93701 596.063,384.952 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SteffensenMethod (generic function with 1 method)"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function SteffensenMethod(f::Function,x0::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" if abs(v) < ϵ\n",
" return x0\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - (v^2/((f(x0 + v)-v)))\n",
" v = f(x1)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return x1\n",
" end\n",
" x0 = x1\n",
" end\n",
" return x0\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 46,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"SteffensenMethod! (generic function with 1 method)"
]
},
"execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function SteffensenMethod!(f::Function,x0::Number;steps::UInt64=typemax(UInt64),δ::Float64=eps(),ϵ::Float64=eps())\n",
" v = f(x0)\n",
" roots = Array{Float64}(0)\n",
" if abs(v) < ϵ\n",
" return push!(roots,v)\n",
" end\n",
" for i in 1:steps\n",
" x1 = x0 - (v^2/((f(x0 + v)-v)))\n",
" v = f(x1)\n",
" push!(roots,v)\n",
" if (abs(x1 - x0) < δ) || abs(v) < ϵ\n",
" return roots\n",
" end\n",
" x0 = x1\n",
" end\n",
" return roots\n",
"end"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.567143290409784"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootf = SteffensenMethod(f,0.1,steps=UInt(1000000))"
]
},
{
"cell_type": "code",
"execution_count": 52,
"metadata": {
"collapsed": false
},
"outputs": [],
"source": [
"errors = abs(SteffensenMethod!(f,0.1,steps=UInt(1000000)) .- rootf);"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"12.8259,384.952 596.063,384.952 596.063,3.93701 12.8259,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"12\" y=\"3\" width=\"584\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 122.183,379.237 122.183,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 304.444,379.237 304.444,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 486.706,379.237 486.706,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,355.307 587.314,355.307 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,270.19 587.314,270.19 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,185.073 587.314,185.073 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,99.9566 587.314,99.9566 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 21.5745,14.8398 587.314,14.8398 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 122.183,384.952 122.183,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 304.444,384.952 304.444,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 486.706,384.952 486.706,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,384.952 12.8259,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,355.307 21.5745,355.307 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,270.19 21.5745,270.19 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,185.073 21.5745,185.073 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,99.9566 21.5745,99.9566 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,14.8398 21.5745,14.8398 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 122.183, 396.952)\" x=\"122.183\" y=\"396.952\">2.5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 304.444, 396.952)\" x=\"304.444\" y=\"396.952\">5.0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 486.706, 396.952)\" x=\"486.706\" y=\"396.952\">7.5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 359.807)\" x=\"11.6259\" y=\"359.807\">0</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 274.69)\" x=\"11.6259\" y=\"274.69\">1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 189.573)\" x=\"11.6259\" y=\"189.573\">2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 104.457)\" x=\"11.6259\" y=\"104.457\">3</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 11.6259, 19.3398)\" x=\"11.6259\" y=\"19.3398\">4</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 12.8259,278.953 85.7305,292.457 158.635,384.952 231.54,338.546 304.444,3.93701 377.349,231.593 450.254,266.995 523.158,270.162 596.063,270.19 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "markdown",
"metadata": {
"collapsed": false
},
"source": [
"Convergencia cuadratica como podemos ver"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"4.493409457909064"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rootg = SteffensenMethod(g,4.5,steps=UInt(1000000))"
]
},
{
"cell_type": "code",
"execution_count": 58,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"errors = abs(SteffensenMethod!(g,4.5,steps=UInt(1000000)) .- rootg);"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"48.3815,384.952 596.063,384.952 596.063,3.93701 48.3815,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"48\" y=\"3\" width=\"548\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 48.3815,379.237 48.3815,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 185.302,379.237 185.302,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 322.222,379.237 322.222,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 459.143,379.237 459.143,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 596.063,379.237 596.063,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 56.5967,288.135 587.848,288.135 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 56.5967,191.318 587.848,191.318 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 56.5967,94.5007 587.848,94.5007 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,384.952 48.3815,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 185.302,384.952 185.302,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 322.222,384.952 322.222,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 459.143,384.952 459.143,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 596.063,384.952 596.063,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,384.952 48.3815,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,288.135 56.5967,288.135 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,191.318 56.5967,191.318 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,94.5007 56.5967,94.5007 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 48.3815, 396.952)\" x=\"48.3815\" y=\"396.952\">1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 185.302, 396.952)\" x=\"185.302\" y=\"396.952\">2</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 322.222, 396.952)\" x=\"322.222\" y=\"396.952\">3</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 459.143, 396.952)\" x=\"459.143\" y=\"396.952\">4</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 596.063, 396.952)\" x=\"596.063\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 47.1815, 292.635)\" x=\"47.1815\" y=\"292.635\">1.002</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 47.1815, 195.818)\" x=\"47.1815\" y=\"195.818\">1.004</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 47.1815, 99.0007)\" x=\"47.1815\" y=\"99.0007\">1.006</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 48.3815,3.93701 185.302,196.803 322.222,356.304 459.143,384.421 596.063,384.952 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Pocas iteraciones para decidir."
]
},
{
"cell_type": "code",
"execution_count": 91,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/plain": [
"0.00022184119990164566"
]
},
"execution_count": 91,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"rooth = SteffensenMethod(h,0.5,steps=UInt(20))"
]
},
{
"cell_type": "code",
"execution_count": 92,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"errors = abs(SteffensenMethod!(h,0.5,steps=UInt(20)) .- rooth);"
]
},
{
"cell_type": "code",
"execution_count": 93,
"metadata": {
"collapsed": false
},
"outputs": [
{
"data": {
"text/html": [
"<?xml version=\"1.0\" encoding=\"utf-8\"?>\n",
"<svg xmlns=\"http://www.w3.org/2000/svg\" xmlns:xlink=\"http://www.w3.org/1999/xlink\" width=\"600\" height=\"400\" viewBox=\"0 0 600 400\">\n",
"<defs>\n",
" <clipPath id=\"clip00\">\n",
" <rect x=\"0\" y=\"0\" width=\"600\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"0,400 600,400 600,0 0,0 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip01\">\n",
" <rect x=\"120\" y=\"0\" width=\"421\" height=\"400\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"30.6037,384.952 596.063,384.952 596.063,3.93701 30.6037,3.93701 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<defs>\n",
" <clipPath id=\"clip02\">\n",
" <rect x=\"30\" y=\"3\" width=\"566\" height=\"382\"/>\n",
" </clipPath>\n",
"</defs>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 163.653,379.237 163.653,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 329.964,379.237 329.964,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 496.276,379.237 496.276,9.65223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,247.223 587.581,247.223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:0.5; fill:none\" stroke-dasharray=\"1, 2\" points=\"\n",
" 39.0856,109.493 587.581,109.493 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 596.063,384.952 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 163.653,384.952 163.653,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 329.964,384.952 329.964,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 496.276,384.952 496.276,379.237 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,384.952 30.6037,3.93701 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,247.223 39.0856,247.223 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,109.493 39.0856,109.493 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 163.653, 396.952)\" x=\"163.653\" y=\"396.952\">5</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 329.964, 396.952)\" x=\"329.964\" y=\"396.952\">10</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:middle;\" transform=\"rotate(0, 496.276, 396.952)\" x=\"496.276\" y=\"396.952\">15</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 251.723)\" x=\"29.4037\" y=\"251.723\">1.1</text>\n",
"</g>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:end;\" transform=\"rotate(0, 29.4037, 113.993)\" x=\"29.4037\" y=\"113.993\">1.2</text>\n",
"</g>\n",
"<polyline clip-path=\"url(#clip02)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 30.6037,3.93701 63.866,115.944 97.1283,202.674 130.391,282.893 163.653,341.014 196.915,369.484 230.178,380.024 263.44,383.443 296.702,384.497 329.964,384.816 \n",
" 363.227,384.911 396.489,384.94 429.751,384.948 463.014,384.951 496.276,384.952 529.538,384.952 562.801,384.952 596.063,384.952 \n",
" \"/>\n",
"<polygon clip-path=\"url(#clip00)\" points=\"\n",
"505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 \n",
" \" fill=\"#ffffff\" fill-opacity=\"1\"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#00002d; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 505.547,55.057 578.063,55.057 578.063,24.817 505.547,24.817 505.547,55.057 \n",
" \"/>\n",
"<polyline clip-path=\"url(#clip00)\" style=\"stroke:#0099ff; stroke-width:0.8; stroke-opacity:1; fill:none\" points=\"\n",
" 511.547,39.937 547.547,39.937 \n",
" \"/>\n",
"<g clip-path=\"url(#clip00)\">\n",
"<text style=\"fill:#00002d; fill-opacity:1; font-family:Arial,Helvetica Neue,Helvetica,sans-serif; font-size:12; text-anchor:start;\" transform=\"rotate(0, 553.547, 44.437)\" x=\"553.547\" y=\"44.437\">y1</text>\n",
"</g>\n",
"</svg>\n"
]
},
"execution_count": 93,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"plot(logpoints(errors))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Vemos que la convergencia es lineal para h, aunque de orden 4 para las demas funciones, tiene mejor convergencia que el método de la secante ya que evalua en dos puntos la funcion $f$ (aunque sería una desventaja si $f$ es complicada)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"anaconda-cloud": {},
"kernelspec": {
"display_name": "Julia 0.5.0",
"language": "julia",
"name": "julia-0.5"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "0.5.0"
}
},
"nbformat": 4,
"nbformat_minor": 1
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment