|
6 | 6 | <!--
|
7 | 7 | This HTML was auto-generated from MATLAB code.
|
8 | 8 | To make changes, update the MATLAB code and republish this document.
|
9 |
| - --><title>iderivative</title><meta name="generator" content="MATLAB 9.11"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2021-11-23"><meta name="DC.source" content="iderivative_doc.m"><style type="text/css"> |
| 9 | + --><title>iderivative</title><meta name="generator" content="MATLAB 9.11"><link rel="schema.DC" href="http://purl.org/dc/elements/1.1/"><meta name="DC.date" content="2021-12-10"><meta name="DC.source" content="iderivative_doc.m"><style type="text/css"> |
10 | 10 | html,body,div,span,applet,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,a,abbr,acronym,address,big,cite,code,del,dfn,em,font,img,ins,kbd,q,s,samp,small,strike,strong,tt,var,b,u,i,center,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}body{line-height:1}ol,ul{list-style:none}blockquote,q{quotes:none}blockquote:before,blockquote:after,q:before,q:after{content:'';content:none}:focus{outine:0}ins{text-decoration:none}del{text-decoration:line-through}table{border-collapse:collapse;border-spacing:0}
|
11 | 11 |
|
12 | 12 | html { min-height:100%; margin-bottom:1px; }
|
|
67 | 67 |
|
68 | 68 |
|
69 | 69 |
|
70 |
| - </style></head><body><div class="content"><h1><tt>iderivative</tt></h1><!--introduction--><p>Derivative of a univariate, scalar or vector-valued function using the complex-step approximation.</p><p><a href="index.html">Back to Numerical Differentiation Toolbox Contents</a>.</p><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Syntax</a></li><li><a href="#2">Input/Output Parameters</a></li><li><a href="#3">Example #1: Derivative of a scalar-valued function.</a></li><li><a href="#6">Example #2: Derivative of a vector-valued function.</a></li><li><a href="#9">See also</a></li></ul></div><h2 id="1">Syntax</h2><pre class="language-matlab">df = iderivative(f,x0) |
| 70 | + </style></head><body><div class="content"><h1><tt>iderivative</tt></h1><!--introduction--><p>Derivative of a univariate, scalar or vector-valued function using the complex-step approximation.</p><p><a href="index.html">Back to Numerical Differentiation Toolbox Contents</a>.</p><!--/introduction--><h2>Contents</h2><div><ul><li><a href="#1">Syntax</a></li><li><a href="#2">Description</a></li><li><a href="#3">Input/Output Parameters</a></li><li><a href="#4">Example #1: Derivative of a scalar-valued function.</a></li><li><a href="#7">Example #2: Derivative of a vector-valued function.</a></li><li><a href="#10">See also</a></li></ul></div><h2 id="1">Syntax</h2><pre class="language-matlab">df = iderivative(f,x0) |
71 | 71 | df = iderivative(f,x0,h)
|
72 |
| -</pre><h2 id="2">Input/Output Parameters</h2><p> |
| 72 | +</pre><h2 id="2">Description</h2><p><tt>df = iderivative(f,x0)</tt> numerically evaluates the derivative of <img src="iderivative_doc_eq15621115338434299399.png" alt="$\mathbf{f}(x)$" style="width:19px;height:11px;"> at <img src="iderivative_doc_eq15895670344772995363.png" alt="$x=x_{0}$" style="width:31px;height:7px;"> using the complex-step approximation with a default step size of <img src="iderivative_doc_eq12016976132402243107.png" alt="$h=\sqrt{\varepsilon}$" style="width:35px;height:12px;">, where <img src="iderivative_doc_eq13794615980392037191.png" alt="$\varepsilon$" style="width:5px;height:6px;"> is the machine precision.</p><p><tt>df = iderivative(f,x0,h)</tt> numerically evaluates the derivative of <img src="iderivative_doc_eq15621115338434299399.png" alt="$\mathbf{f}(x)$" style="width:19px;height:11px;"> at <img src="iderivative_doc_eq15895670344772995363.png" alt="$x=x_{0}$" style="width:31px;height:7px;"> using the complex-step approximation with a user-specified step size <img src="iderivative_doc_eq16410644637423230129.png" alt="$h$" style="width:6px;height:8px;">.</p><h2 id="3">Input/Output Parameters</h2><p> |
73 | 73 | <table border=1>
|
74 | 74 | <tr>
|
75 | 75 | <td></td>
|
|
105 | 105 | <td style="text-align:center">m×1<BR>double</td>
|
106 | 106 | </tr>
|
107 | 107 | </table>
|
108 |
| -</p><p><b>NOTE:</b> This function also works for scalar-valued functions (in that case, we simply have <img src="iderivative_doc_eq14613861381496079316.png" alt="$m=1$" style="width:29px;height:8px;">).</p><h2 id="3">Example #1: Derivative of a scalar-valued function.</h2><p><i>Approximate the derivative of <img src="iderivative_doc_eq07863013981449083213.png" alt="$f(x)=x^{3}$" style="width:46px;height:12px;"> at <img src="iderivative_doc_eq04851200360885152548.png" alt="$x=2$" style="width:26px;height:8px;"> using the <tt>iderivative</tt> function, and compare the result to the true result of <img src="iderivative_doc_eq13447770136917483844.png" alt="$f'(2)=12$" style="width:48px;height:12px;"></i>.</p><p>Approximating the derivative,</p><pre class="codeinput">f = @(x) x^3; |
| 108 | +</p><p><b>NOTE:</b> This function also works for scalar-valued functions (in that case, we simply have <img src="iderivative_doc_eq14613861381496079316.png" alt="$m=1$" style="width:29px;height:8px;">).</p><h2 id="4">Example #1: Derivative of a scalar-valued function.</h2><p><i>Approximate the derivative of <img src="iderivative_doc_eq07863013981449083213.png" alt="$f(x)=x^{3}$" style="width:46px;height:12px;"> at <img src="iderivative_doc_eq04851200360885152548.png" alt="$x=2$" style="width:26px;height:8px;"> using the <tt>iderivative</tt> function, and compare the result to the true result of <img src="iderivative_doc_eq13447770136917483844.png" alt="$f'(2)=12$" style="width:48px;height:12px;"></i>.</p><p>Approximating the derivative,</p><pre class="codeinput">f = @(x) x^3; |
109 | 109 | df = iderivative(f,2)
|
110 | 110 | </pre><pre class="codeoutput">
|
111 | 111 | df =
|
|
118 | 118 |
|
119 | 119 | 0
|
120 | 120 |
|
121 |
| -</pre><p>The approximation is therefore accurate to double precision.</p><h2 id="6">Example #2: Derivative of a vector-valued function.</h2><p><i>Approximate the derivative of</i></p><p><img src="iderivative_doc_eq05437446654055475759.png" alt="$$\mathbf{f}(t)=\pmatrix{\sin{t}\cr\cos{t}}$$" style="width:71px;height:27px;"></p><p><i>at <img src="iderivative_doc_eq06658196661290597197.png" alt="$t=1$" style="width:23px;height:8px;"> using the <tt>iderivative</tt> function, and compare the result to the true result of</i></p><p><img src="iderivative_doc_eq07637929496866620270.png" alt="$$\left.\frac{d\mathbf{f}}{dx}\right|_{t=1}=\pmatrix{\cos{(1)}\cr-\sin{(1)}}$$" style="width:103px;height:28px;"></p><p>Approximating the derivative,</p><pre class="codeinput">f = @(t) [sin(t);cos(t)]; |
| 121 | +</pre><p>The approximation is therefore accurate to double precision.</p><h2 id="7">Example #2: Derivative of a vector-valued function.</h2><p><i>Approximate the derivative of</i></p><p><img src="iderivative_doc_eq05437446654055475759.png" alt="$$\mathbf{f}(t)=\pmatrix{\sin{t}\cr\cos{t}}$$" style="width:71px;height:27px;"></p><p><i>at <img src="iderivative_doc_eq06658196661290597197.png" alt="$t=1$" style="width:23px;height:8px;"> using the <tt>iderivative</tt> function, and compare the result to the true result of</i></p><p><img src="iderivative_doc_eq07637929496866620270.png" alt="$$\left.\frac{d\mathbf{f}}{dx}\right|_{t=1}=\pmatrix{\cos{(1)}\cr-\sin{(1)}}$$" style="width:103px;height:28px;"></p><p>Approximating the derivative,</p><pre class="codeinput">f = @(t) [sin(t);cos(t)]; |
122 | 122 | df = iderivative(f,1)
|
123 | 123 | </pre><pre class="codeoutput">
|
124 | 124 | df =
|
|
133 | 133 | 0
|
134 | 134 | 0
|
135 | 135 |
|
136 |
| -</pre><p>The approximation is therefore accurate to double precision.</p><h2 id="9">See also</h2><p><a href="ipartial_doc.html"><tt>ipartial</tt></a> | <a href="igradient_doc.html"><tt>igradient</tt></a> | <a href="idirectional_doc.html"><tt>idirectional</tt></a> | <a href="ijacobian_doc.html"><tt>ijacobian</tt></a> | <a href="ihessian_doc.html"><tt>ihessian</tt></a></p><p class="footer"><br><a href="https://www.mathworks.com/products/matlab/">Published with MATLAB® R2021b</a><br></p></div><!-- |
| 136 | +</pre><p>The approximation is therefore accurate to double precision.</p><h2 id="10">See also</h2><p><a href="ipartial_doc.html"><tt>ipartial</tt></a> | <a href="igradient_doc.html"><tt>igradient</tt></a> | <a href="idirectional_doc.html"><tt>idirectional</tt></a> | <a href="ijacobian_doc.html"><tt>ijacobian</tt></a> | <a href="ihessian_doc.html"><tt>ihessian</tt></a></p><p class="footer"><br><a href="https://www.mathworks.com/products/matlab/">Published with MATLAB® R2021b</a><br></p></div><!-- |
137 | 137 | ##### SOURCE BEGIN #####
|
138 | 138 | %% |iderivative|
|
139 | 139 | % Derivative of a univariate, scalar or vector-valued function using the complex-step approximation.
|
|
142 | 142 | %% Syntax
|
143 | 143 | % df = iderivative(f,x0)
|
144 | 144 | % df = iderivative(f,x0,h)
|
| 145 | +%% Description |
| 146 | +% |df = iderivative(f,x0)| numerically evaluates the derivative of |
| 147 | +% $\mathbf{f}(x)$ at $x=x_{0}$ using the complex-step approximation with a |
| 148 | +% default step size of $h=\sqrt{\varepsilon}$, where $\varepsilon$ is the |
| 149 | +% machine precision. |
| 150 | +% |
| 151 | +% |df = iderivative(f,x0,h)| numerically evaluates the derivative of |
| 152 | +% $\mathbf{f}(x)$ at $x=x_{0}$ using the complex-step approximation with a |
| 153 | +% user-specified step size $h$. |
145 | 154 | %% Input/Output Parameters
|
146 | 155 | % <html>
|
147 | 156 | % <table border=1>
|
|
0 commit comments