15 lines
27 KiB
JSON
15 lines
27 KiB
JSON
{
|
||
"hash": "fe3c54470301329c957a645aba211eb9",
|
||
"result": {
|
||
"markdown": "# Numeric derivatives\n\n\n\nThis section uses these add-on packages:\n\n``` {.julia .cell-code}\nusing CalculusWithJulia\nusing Plots\nusing ForwardDiff\nusing SymPy\nusing Roots\n```\n\n\n\n\n---\n\n\n`SymPy` returns symbolic derivatives. Up to choices of simplification, these answers match those that would be derived by hand. This is useful when comparing with known answers and for seeing the structure of the answer. However, there are times we just want to work with the answer numerically. For that we have other options within `Julia`. We discuss approximate derivatives and automatic derivatives. The latter will find wide usage in these notes.\n\n\n### Approximate derivatives\n\n\nBy approximating the limit of the secant line with a value for a small, but positive, $h$, we get an approximation to the derivative. That is\n\n\n\n$$\nf'(x) \\approx \\frac{f(x+h) - f(x)}{h}.\n$$\n\n\nThis is the forward-difference approximation. The central difference approximation looks both ways:\n\n\n\n$$\nf'(x) \\approx \\frac{f(x+h) - f(x-h)}{2h}.\n$$\n\n\nThough in general they are different, they are both approximations. The central difference is usually more accurate for the same size $h$. However, both are susceptible to round-off errors. The numerator is a subtraction of like-size numbers - a perfect opportunity to lose precision.\n\n\nAs such there is a balancing act:\n\n\n * if $h$ is too small the round-off errors are problematic,\n * if $h$ is too big, the approximation to the limit is not good.\n\n\nFor the forward difference $h$ values around $10^{-8}$ are typically good, for the central difference, values around $10^{-6}$ are typically good.\n\n\n##### Example\n\n\nLet's verify that the forward difference isn't too far off.\n\n::: {.cell execution_count=4}\n``` {.julia .cell-code}\nf(x) = exp(-x^2/2)\nc = 1\nh = 1e-8\nfapprox = (f(c+h) - f(c)) / h\n```\n\n::: {.cell-output .cell-output-display execution_count=5}\n```\n-0.6065306479285937\n```\n:::\n:::\n\n\nWe can compare to the actual with:\n\n::: {.cell execution_count=5}\n``` {.julia .cell-code}\n@syms x\ndf = diff(f(x), x)\nfactual = N(df(c))\nabs(factual - fapprox)\n```\n\n::: {.cell-output .cell-output-display execution_count=6}\n```\n1.178403974334123392219821170344191813548718695568289215873505651941374433299215e-08\n```\n:::\n:::\n\n\nThe error is about $1$ part in $100$ million.\n\n\nThe central difference is better here:\n\n::: {.cell hold='true' execution_count=6}\n``` {.julia .cell-code}\nh = 1e-6\ncdapprox = (f(c+h) - f(c-h)) / (2h)\nabs(factual - cdapprox)\n```\n\n::: {.cell-output .cell-output-display execution_count=7}\n```\n1.567568231457459370771602167922282298718695568289215873505651941374433299214873e-11\n```\n:::\n:::\n\n\n---\n\nThe [FiniteDifferences](https://github.com/JuliaDiff/FiniteDifferences.jl) and [FiniteDiff](https://github.com/JuliaDiff/FiniteDiff.jl) packages provide performant interfaces for differentiation based on finite differences.\n\n\n### Automatic derivatives\n\n\nThere are some other ways to compute derivatives numerically that give much more accuracy at the expense of slightly increased computing time. Automatic differentiation is the general name for a few different approaches. These approaches promise less complexity - in some cases - than symbolic derivatives and more accuracy than approximate derivatives; the accuracy is on the order of machine precision.\n\n\nThe `ForwardDiff` package provides one of [several](https://juliadiff.org/) ways for `Julia` to compute automatic derivatives. `ForwardDiff` is well suited for functions encountered in these notes, which depend on at most a few variables and output no more than a few values at once.\n\n\nThe `ForwardDiff` package was loaded in this section; in general its features are available when the `CalculusWithJulia` package is loaded, as that package provides a more convenient interface. The `derivative` function is not exported by `FiniteDiff`, so its usage requires qualification. To illustrate, to find the derivative of $f(x)$ at a *point* we have this syntax:\n\n::: {.cell execution_count=7}\n``` {.julia .cell-code}\nForwardDiff.derivative(f, c) # derivative is qualified by a module name\n```\n\n::: {.cell-output .cell-output-display execution_count=8}\n```\n-0.6065306597126334\n```\n:::\n:::\n\n\nThe `CalculusWithJulia` package defines an operator `D` which goes from finding a derivative at a point with `ForwardDiff.derivative` to defining a function which evaluates the derivative at each point. It is defined along the lines of `D(f) = x -> ForwardDiff.derivative(f,x)` in parallel to how the derivative operation for a function is defined mathematically from the definition for its value at a point.\n\n\nHere we see the error in estimating $f'(1)$:\n\n::: {.cell execution_count=8}\n``` {.julia .cell-code}\nfauto = D(f)(c) # D(f) is a function, D(f)(c) is the function called on c\nabs(factual - fauto)\n```\n\n::: {.cell-output .cell-output-display execution_count=9}\n```\n6.593178415491414032952187053331255443171078412649434805862556670078512733295529e-19\n```\n:::\n:::\n\n\nIn this case, it is exact.\n\n\nThe `D` operator is defined for most all functions in `Julia`, though, like the `diff` operator in `SymPy` there are some for which it won't work.\n\n\n##### Example\n\n\nFor $f(x) = \\sqrt{1 + \\sin(\\cos(x))}$ compare the difference between the forward derivative with $h=1e-8$ and that computed by `D` at $x=\\pi/4$.\n\n\nThe forward derivative is found with:\n\n::: {.cell execution_count=9}\n``` {.julia .cell-code}\n𝒇(x) = sqrt(1 + sin(cos(x)))\n𝒄, 𝒉 = pi/4, 1e-8\nfwd = (𝒇(𝒄+𝒉) - 𝒇(𝒄))/𝒉\n```\n\n::: {.cell-output .cell-output-display execution_count=10}\n```\n-0.20927346522370271\n```\n:::\n:::\n\n\nThat given by `D` is:\n\n::: {.cell execution_count=10}\n``` {.julia .cell-code}\nds_value = D(𝒇)(𝒄)\nds_value, fwd, ds_value - fwd\n```\n\n::: {.cell-output .cell-output-display execution_count=11}\n```\n(-0.20927346371432803, -0.20927346522370271, 1.5093746807970376e-9)\n```\n:::\n:::\n\n\nFinally, `SymPy` gives an exact value we use to compare:\n\n::: {.cell execution_count=11}\n``` {.julia .cell-code}\n𝒇𝒑 = diff(𝒇(x), x)\n```\n\n::: {.cell-output .cell-output-display execution_count=12}\n```{=html}\n<span class=\"math-left-align\" style=\"padding-left: 4px; width:0; float:left;\"> \n\\[\n- \\frac{\\sin{\\left(x \\right)} \\cos{\\left(\\cos{\\left(x \\right)} \\right)}}{2 \\sqrt{\\sin{\\left(\\cos{\\left(x \\right)} \\right)} + 1}}\n\\]\n</span>\n```\n:::\n:::\n\n\n::: {.cell execution_count=12}\n``` {.julia .cell-code}\nactual = N(𝒇𝒑(PI/4))\nactual - ds_value, actual - fwd\n```\n\n::: {.cell-output .cell-output-display execution_count=13}\n```\n(-5.2941373495493281085179064170722727004081123938542546154188381086149403149753e-17, 1.509374627855664131196135271205690010185476120918876061457453845811618913850597e-09)\n```\n:::\n:::\n\n\n#### Convenient notation\n\n\n`Julia` allows the possibility of extending functions to different types. Out of the box, the `'` notation is not employed for functions, but is used for matrices. It is used in postfix position, as with `A'`. We can define it to do the same thing as `D` for functions and then, we can evaluate derivatives with the familiar `f'(x)`. This is done in `CalculusWithJulia` along the lines of `Base.adjoint(f::Function) = D(f)`.\n\n\nThen, we have, for example:\n\n::: {.cell hold='true' execution_count=13}\n``` {.julia .cell-code}\nf(x) = sin(x)\nf'(pi), f''(pi)\n```\n\n::: {.cell-output .cell-output-display execution_count=14}\n```\n(-1.0, -1.2246467991473532e-16)\n```\n:::\n:::\n\n\n##### Example\n\n\nSuppose our task is to find a zero of the second derivative of $k(x) = e^{-x^2/2}$ in $[0, 10]$, a known bracket. The `D` function takes a second argument to indicate the order of the derivative (e.g., `D(f,2)`), but we use the more familiar notation:\n\n::: {.cell hold='true' execution_count=14}\n``` {.julia .cell-code}\nk(x) = exp(-x^2/2)\nfind_zero(k'', 0..10)\n```\n\n::: {.cell-output .cell-output-display execution_count=15}\n```\n1.0\n```\n:::\n:::\n\n\nWe pass in the function object, `k''`, and not the evaluated function.\n\n\n## Recap on derivatives in Julia\n\n\nA quick summary for finding derivatives in `Julia`, as there are $3$ different manners:\n\n\n * Symbolic derivatives are found using `diff` from `SymPy`\n * Automatic derivatives are found using the notation `f'` using `ForwardDiff.derivative`\n * approximate derivatives at a point, `c`, for a given `h` are found with `(f(c+h)-f(c))/h`.\n\n\nFor example, here all three are computed and compared:\n\n::: {.cell hold='true' execution_count=15}\n``` {.julia .cell-code}\nf(x) = exp(-x)*sin(x)\n\nc = pi\nh = 1e-8\n\nfp = diff(f(x),x)\n\nfp, fp(c), f'(c), (f(c+h) - f(c))/h\n```\n\n::: {.cell-output .cell-output-display execution_count=16}\n```\n(-exp(-x)*sin(x) + exp(-x)*cos(x), -exp(-pi), -0.043213918263772265, -0.04321391756900175)\n```\n:::\n:::\n\n\n:::{.callout-note}\n## Note\nThe use of `'` to find derivatives provided by `CalculusWithJulia` is convenient, and used extensively in these notes, but it needs to be noted that it does **not conform** with the generic meaning of `'` within `Julia`'s wider package ecosystem and may cause issue with linear algebra operations; the symbol is meant for the adjoint of a matrix.\n\n:::\n\n## Questions\n\n\n##### Question\n\n\nFind the derivative using a forward difference approximation of $f(x) = x^x$ at the point $x=2$ using `h=0.1`:\n\n::: {.cell hold='true' execution_count=16}\n\n::: {.cell-output .cell-output-display execution_count=17}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='9823501780711659799' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_9823501780711659799\">\n <div style=\"padding-top: 5px\">\n </br>\n<div class=\"input-group\">\n <input id=\"9823501780711659799\" type=\"number\" class=\"form-control\" placeholder=\"Numeric answer\">\n</div>\n\n \n </div>\n </div>\n <div id='9823501780711659799_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.getElementById(\"9823501780711659799\").addEventListener(\"change\", function() {\n var correct = (Math.abs(this.value - 7.496380917422423) <= 0.001);\n var msgBox = document.getElementById('9823501780711659799_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍 Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_9823501780711659799\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎 Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_9823501780711659799\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n});\n\n</script>\n```\n:::\n:::\n\n\nUsing `D` or `f'` find the value using automatic differentiation\n\n::: {.cell hold='true' execution_count=17}\n\n::: {.cell-output .cell-output-display execution_count=18}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='11011518791021729862' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_11011518791021729862\">\n <div style=\"padding-top: 5px\">\n </br>\n<div class=\"input-group\">\n <input id=\"11011518791021729862\" type=\"number\" class=\"form-control\" placeholder=\"Numeric answer\">\n</div>\n\n \n </div>\n </div>\n <div id='11011518791021729862_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.getElementById(\"11011518791021729862\").addEventListener(\"change\", function() {\n var correct = (Math.abs(this.value - 6.772588722239782) <= 0.001);\n var msgBox = document.getElementById('11011518791021729862_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍 Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_11011518791021729862\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎 Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_11011518791021729862\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n});\n\n</script>\n```\n:::\n:::\n\n\n##### Question\n\n\nMathematically, as the value of `h` in the forward difference gets smaller the forward difference approximation gets better. On the computer, this is thwarted by floating point representation issues (in particular the error in subtracting two like-sized numbers in forming $f(x+h)-f(x)$.)\n\n\nFor `1e-16` what is the error (in absolute value) in finding the forward difference approximation for the derivative of $\\sin(x)$ at $x=0$?\n\n::: {.cell hold='true' execution_count=18}\n\n::: {.cell-output .cell-output-display execution_count=19}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='3301518363794164169' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_3301518363794164169\">\n <div style=\"padding-top: 5px\">\n </br>\n<div class=\"input-group\">\n <input id=\"3301518363794164169\" type=\"number\" class=\"form-control\" placeholder=\"Numeric answer\">\n</div>\n\n \n </div>\n </div>\n <div id='3301518363794164169_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.getElementById(\"3301518363794164169\").addEventListener(\"change\", function() {\n var correct = (Math.abs(this.value - 0.0) <= 0.001);\n var msgBox = document.getElementById('3301518363794164169_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍 Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_3301518363794164169\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎 Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_3301518363794164169\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n});\n\n</script>\n```\n:::\n:::\n\n\nRepeat for $x=\\pi/4$:\n\n::: {.cell hold='true' execution_count=19}\n\n::: {.cell-output .cell-output-display execution_count=20}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='15376675165751302394' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_15376675165751302394\">\n <div style=\"padding-top: 5px\">\n </br>\n<div class=\"input-group\">\n <input id=\"15376675165751302394\" type=\"number\" class=\"form-control\" placeholder=\"Numeric answer\">\n</div>\n\n \n </div>\n </div>\n <div id='15376675165751302394_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.getElementById(\"15376675165751302394\").addEventListener(\"change\", function() {\n var correct = (Math.abs(this.value - 0.11022302462515654) <= 0.001);\n var msgBox = document.getElementById('15376675165751302394_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍 Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_15376675165751302394\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎 Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_15376675165751302394\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nLet $f(x) = x^x$. Using `D`, find $f'(3)$.\n\n::: {.cell hold='true' execution_count=20}\n\n::: {.cell-output .cell-output-display execution_count=21}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='15987202012850482760' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_15987202012850482760\">\n <div style=\"padding-top: 5px\">\n </br>\n<div class=\"input-group\">\n <input id=\"15987202012850482760\" type=\"number\" class=\"form-control\" placeholder=\"Numeric answer\">\n</div>\n\n \n </div>\n </div>\n <div id='15987202012850482760_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.getElementById(\"15987202012850482760\").addEventListener(\"change\", function() {\n var correct = (Math.abs(this.value - 56.66253179403897) <= 0.001);\n var msgBox = document.getElementById('15987202012850482760_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍 Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_15987202012850482760\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎 Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_15987202012850482760\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nLet $f(x) = \\lvert 1 - \\sqrt{1 + x}\\rvert$. Using `D`, find $f'(3)$.\n\n::: {.cell hold='true' execution_count=21}\n\n::: {.cell-output .cell-output-display execution_count=22}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='7818065138058472881' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_7818065138058472881\">\n <div style=\"padding-top: 5px\">\n </br>\n<div class=\"input-group\">\n <input id=\"7818065138058472881\" type=\"number\" class=\"form-control\" placeholder=\"Numeric answer\">\n</div>\n\n \n </div>\n </div>\n <div id='7818065138058472881_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.getElementById(\"7818065138058472881\").addEventListener(\"change\", function() {\n var correct = (Math.abs(this.value - 0.25) <= 0.001);\n var msgBox = document.getElementById('7818065138058472881_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍 Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_7818065138058472881\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎 Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_7818065138058472881\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nLet $f(x) = e^{\\sin(x)}$. Using `D`, find $f'(3)$.\n\n::: {.cell hold='true' execution_count=22}\n\n::: {.cell-output .cell-output-display execution_count=23}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='4810001939710740611' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_4810001939710740611\">\n <div style=\"padding-top: 5px\">\n </br>\n<div class=\"input-group\">\n <input id=\"4810001939710740611\" type=\"number\" class=\"form-control\" placeholder=\"Numeric answer\">\n</div>\n\n \n </div>\n </div>\n <div id='4810001939710740611_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.getElementById(\"4810001939710740611\").addEventListener(\"change\", function() {\n var correct = (Math.abs(this.value - -1.1400385675133151) <= 0.001);\n var msgBox = document.getElementById('4810001939710740611_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍 Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_4810001939710740611\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎 Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_4810001939710740611\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nFor `Julia`'s `airyai` function find a numeric derivative using the forward difference. For $c=3$ and $h=10^{-8}$ find the forward difference approximation to $f'(3)$ for the `airyai` function.\n\n::: {.cell hold='true' execution_count=23}\n\n::: {.cell-output .cell-output-display execution_count=24}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='11028361868027052577' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_11028361868027052577\">\n <div style=\"padding-top: 5px\">\n </br>\n<div class=\"input-group\">\n <input id=\"11028361868027052577\" type=\"number\" class=\"form-control\" placeholder=\"Numeric answer\">\n</div>\n\n \n </div>\n </div>\n <div id='11028361868027052577_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.getElementById(\"11028361868027052577\").addEventListener(\"change\", function() {\n var correct = (Math.abs(this.value - -0.011912976768252426) <= 0.001);\n var msgBox = document.getElementById('11028361868027052577_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍 Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_11028361868027052577\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎 Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_11028361868027052577\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nFind the rate of change with respect to time of the function $f(t)= 64 - 16t^2$ at $t=1$.\n\n::: {.cell hold='true' execution_count=24}\n\n::: {.cell-output .cell-output-display execution_count=25}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='12306238913086766008' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_12306238913086766008\">\n <div style=\"padding-top: 5px\">\n </br>\n<div class=\"input-group\">\n <input id=\"12306238913086766008\" type=\"number\" class=\"form-control\" placeholder=\"Numeric answer\">\n</div>\n\n \n </div>\n </div>\n <div id='12306238913086766008_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.getElementById(\"12306238913086766008\").addEventListener(\"change\", function() {\n var correct = (Math.abs(this.value - -32) <= 0);\n var msgBox = document.getElementById('12306238913086766008_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍 Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_12306238913086766008\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎 Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_12306238913086766008\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n});\n\n</script>\n```\n:::\n:::\n\n\n###### Question\n\n\nFind the rate of change with respect to height, $h$, of $f(h) = 32h^3 - 62 h + 12$ at $h=2$.\n\n::: {.cell hold='true' execution_count=25}\n\n::: {.cell-output .cell-output-display execution_count=26}\n```{=html}\n<form class=\"mx-2 my-3 mw-100\" name='WeaveQuestion' data-id='12159557367518429600' data-controltype=''>\n <div class='form-group '>\n <div class='controls'>\n <div class=\"form\" id=\"controls_12159557367518429600\">\n <div style=\"padding-top: 5px\">\n </br>\n<div class=\"input-group\">\n <input id=\"12159557367518429600\" type=\"number\" class=\"form-control\" placeholder=\"Numeric answer\">\n</div>\n\n \n </div>\n </div>\n <div id='12159557367518429600_message' style=\"padding-bottom: 15px\"></div>\n </div>\n </div>\n</form>\n\n<script text='text/javascript'>\ndocument.getElementById(\"12159557367518429600\").addEventListener(\"change\", function() {\n var correct = (Math.abs(this.value - 322) <= 0);\n var msgBox = document.getElementById('12159557367518429600_message');\n if(correct) {\n msgBox.innerHTML = \"<div class='pluto-output admonition note alert alert-success'><span> 👍 Correct </span></div>\";\n var explanation = document.getElementById(\"explanation_12159557367518429600\")\n if (explanation != null) {\n explanation.style.display = \"none\";\n }\n } else {\n msgBox.innerHTML = \"<div class='pluto-output admonition alert alert-danger'><span>👎 Incorrect </span></div>\";\n var explanation = document.getElementById(\"explanation_12159557367518429600\")\n if (explanation != null) {\n explanation.style.display = \"block\";\n }\n }\n\n});\n\n</script>\n```\n:::\n:::\n\n\n",
|
||
"supporting": [
|
||
"numeric_derivatives_files"
|
||
],
|
||
"filters": [],
|
||
"includes": {
|
||
"include-in-header": [
|
||
"<script src=\"https://cdnjs.cloudflare.com/ajax/libs/require.js/2.3.6/require.min.js\" integrity=\"sha512-c3Nl8+7g4LMSTdrm621y7kf9v3SDPnhxLNhcjFJbKECVnmZHTdo+IRO05sNLTH/D3vA6u1X32ehoLC7WFVdheg==\" crossorigin=\"anonymous\"></script>\n<script src=\"https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.1/jquery.min.js\" integrity=\"sha512-bLT0Qm9VnAYZDflyKcBaQ2gg0hSYNQrJ8RilYldYQ1FxQYoCLtUjuuRuZo+fjqhx/qtq/1itJ0C2ejDxltZVFg==\" crossorigin=\"anonymous\"></script>\n<script type=\"application/javascript\">define('jquery', [],function() {return window.jQuery;})</script>\n"
|
||
]
|
||
}
|
||
}
|
||
} |