<?xml version='1.0'?> <?xml-stylesheet type='text/xsl' href='pmathml.xsl'?> <html xmlns='http://www.w3.org/1999/xhtml'> <head> <title>Any Order Forward Mode</title> <meta name="description" id="description" content="Any Order Forward Mode"/> <meta name="keywords" id="keywords" content=" forward mode derivative calculate "/> <style type='text/css'> body { color : black } body { background-color : white } A:link { color : blue } A:visited { color : purple } A:active { color : purple } </style> <script type='text/javascript' language='JavaScript' src='_forwardany_xml.js'> </script> </head> <body> <table><tr> <td> <a href="http://www.coin-or.org/CppAD/" target="_top"><img border="0" src="_image.gif"/></a> </td> <td><a href="forwardone.xml" target="_top">Prev</a> </td><td><a href="size_taylor.xml" target="_top">Next</a> </td><td> <select onchange='choose_across0(this)'> <option>Index-></option> <option>contents</option> <option>reference</option> <option>index</option> <option>search</option> <option>external</option> </select> </td> <td> <select onchange='choose_up0(this)'> <option>Up-></option> <option>CppAD</option> <option>ADFun</option> <option>FunEval</option> <option>Forward</option> <option>ForwardAny</option> </select> </td> <td> <select onchange='choose_down3(this)'> <option>ADFun-></option> <option>Independent</option> <option>FunConstruct</option> <option>Dependent</option> <option>abort_recording</option> <option>seq_property</option> <option>FunEval</option> <option>Drivers</option> <option>FunCheck</option> <option>omp_max_thread</option> <option>optimize</option> <option>FunDeprecated</option> </select> </td> <td> <select onchange='choose_down2(this)'> <option>FunEval-></option> <option>Forward</option> <option>Reverse</option> <option>Sparse</option> </select> </td> <td> <select onchange='choose_down1(this)'> <option>Forward-></option> <option>ForwardZero</option> <option>ForwardOne</option> <option>ForwardAny</option> <option>size_taylor</option> <option>CompareChange</option> <option>capacity_taylor</option> <option>Forward.cpp</option> </select> </td> <td>ForwardAny</td> <td> <select onchange='choose_current0(this)'> <option>Headings-></option> <option>Syntax</option> <option>Purpose</option> <option>---..Function Values</option> <option>---..Derivative Values</option> <option>X(t)</option> <option>Y(t)</option> <option>f</option> <option>p</option> <option>x_p</option> <option>y_p</option> <option>Vector</option> <option>Zero Order</option> <option>First Order</option> <option>Second Order</option> <option>Example</option> </select> </td> </tr></table><br/> <center><b><big><big>Any Order Forward Mode</big></big></b></center> <br/> <b><big><a name="Syntax" id="Syntax">Syntax</a></big></b> <br/> <code><font color="blue"></font></code><i><span style='white-space: nowrap'>y_p</span></i><code><font color="blue"><span style='white-space: nowrap'> = </span></font></code><i><span style='white-space: nowrap'>f</span></i><code><font color="blue"><span style='white-space: nowrap'>.Forward(</span></font></code><i><span style='white-space: nowrap'>p</span></i><code><font color="blue"><span style='white-space: nowrap'>, </span></font></code><i><span style='white-space: nowrap'>x_p</span></i><code><font color="blue"><span style='white-space: nowrap'> )</span></font></code> <code><span style='white-space: nowrap'><br/> </span></code><br/> <b><big><a name="Purpose" id="Purpose">Purpose</a></big></b> <br/> We use <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>F</mi> <mo stretchy="false">:</mo> <msup><mi mathvariant='italic'>B</mi> <mi mathvariant='italic'>n</mi> </msup> <mo stretchy="false">→</mo> <msup><mi mathvariant='italic'>B</mi> <mi mathvariant='italic'>m</mi> </msup> </mrow></math> to denote the <a href="glossary.xml#AD Function" target="_top"><span style='white-space: nowrap'>AD function</span></a> corresponding to <i>f</i>. Given a function <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>X</mi> <mo stretchy="false">:</mo> <mi mathvariant='italic'>B</mi> <mo stretchy="false">→</mo> <msup><mi mathvariant='italic'>B</mi> <mi mathvariant='italic'>n</mi> </msup> </mrow></math> , defined by its <a href="glossary.xml#Taylor Coefficient" target="_top"><span style='white-space: nowrap'>Taylor coefficients</span></a> , forward mode computes the Taylor coefficients for the function <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow> <mi mathvariant='italic'>Y</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> <mo stretchy="false">=</mo> <mi mathvariant='italic'>F</mi> <mo stretchy="false">[</mo> <mi mathvariant='italic'>X</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> <mo stretchy="false">]</mo> </mrow></math> . <br/> <br/> <b><a name="Purpose.Function Values" id="Purpose.Function Values">Function Values</a></b> <br/> If you are using forward mode to compute values for <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>F</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>x</mi> <mo stretchy="false">)</mo> </mrow></math> , <a href="forwardzero.xml" target="_top"><span style='white-space: nowrap'>ForwardZero</span></a> is simpler to understand than this explanation of the general case. <br/> <br/> <b><a name="Purpose.Derivative Values" id="Purpose.Derivative Values">Derivative Values</a></b> <br/> If you are using forward mode to compute values for <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>F</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">(</mo> <mi mathvariant='italic'>x</mi> <mo stretchy="false">)</mo> <mo stretchy="false">*</mo> <mi mathvariant='italic'>dx</mi> </mrow></math> , <a href="forwardone.xml" target="_top"><span style='white-space: nowrap'>ForwardOne</span></a> is simpler to understand than this explanation of the general case. <br/> <br/> <b><big><a name="X(t)" id="X(t)">X(t)</a></big></b> <br/> The function <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>X</mi> <mo stretchy="false">:</mo> <mi mathvariant='italic'>B</mi> <mo stretchy="false">→</mo> <msup><mi mathvariant='italic'>B</mi> <mi mathvariant='italic'>n</mi> </msup> </mrow></math> is defined using a sequence of Taylor coefficients <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>k</mi> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">∈</mo> <msup><mi mathvariant='italic'>B</mi> <mi mathvariant='italic'>n</mi> </msup> </mrow></math> : <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow> <mi mathvariant='italic'>X</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> <mo stretchy="false">=</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">+</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">*</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">+</mo> <mo stretchy="false">⋯</mo> <mo stretchy="false">+</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>p</mi> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">*</mo> <msup><mi mathvariant='italic'>t</mi> <mi mathvariant='italic'>p</mi> </msup> </mrow></math> For <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>k</mi> <mo stretchy="false">=</mo> <mn>0</mn> <mo stretchy="false">,</mo> <mo stretchy="false">…</mo> <mo stretchy="false">,</mo> <mi mathvariant='italic'>p</mi> </mrow></math> , the vector <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>k</mi> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> above is defined as the value of <i>x_k</i> in the previous call (counting this call) of the form <code><font color="blue"><span style='white-space: nowrap'><br/>      </span></font></code><i><span style='white-space: nowrap'>f</span></i><code><font color="blue"><span style='white-space: nowrap'>.Forward(</span></font></code><i><span style='white-space: nowrap'>k</span></i><code><font color="blue"><span style='white-space: nowrap'>, </span></font></code><i><span style='white-space: nowrap'>x_k</span></i><code><font color="blue"><span style='white-space: nowrap'>)<br/> </span></font></code>If there is no previous call with <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>k</mi> <mo stretchy="false">=</mo> <mn>0</mn> </mrow></math> , <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> is the value of the independent variables when the corresponding AD of <i>Base</i> <a href="glossary.xml#Operation.Sequence" target="_top"><span style='white-space: nowrap'>operation sequence</span></a> was recorded. Note that <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>k</mi> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> is related to the <i>k</i>-th derivative of <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>X</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> </mrow></math> by <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>k</mi> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">=</mo> <mfrac><mrow><mn>1</mn> </mrow> <mrow><mi mathvariant='italic'>k</mi> <mo stretchy="false">!</mo> </mrow> </mfrac> <msup><mi mathvariant='italic'>X</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>k</mi> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow></math> <br/> <b><big><a name="Y(t)" id="Y(t)">Y(t)</a></big></b> <br/> The function <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>Y</mi> <mo stretchy="false">:</mo> <mi mathvariant='italic'>B</mi> <mo stretchy="false">→</mo> <msup><mi mathvariant='italic'>B</mi> <mi mathvariant='italic'>m</mi> </msup> </mrow></math> is defined by <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>Y</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> <mo stretchy="false">=</mo> <mi mathvariant='italic'>F</mi> <mo stretchy="false">[</mo> <mi mathvariant='italic'>X</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> <mo stretchy="false">]</mo> </mrow></math> . We use <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>k</mi> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">∈</mo> <msup><mi mathvariant='italic'>B</mi> <mi mathvariant='italic'>m</mi> </msup> </mrow></math> to denote the <i>k</i>-th order Taylor coefficient of <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>Y</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> </mrow></math> ; i.e., <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow> <mi mathvariant='italic'>Y</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> <mo stretchy="false">=</mo> <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">+</mo> <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">*</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">+</mo> <mo stretchy="false">⋯</mo> <mo stretchy="false">,</mo> <mo stretchy="false">+</mo> <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>p</mi> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">*</mo> <msup><mi mathvariant='italic'>t</mi> <mi mathvariant='italic'>p</mi> </msup> <mo stretchy="false">+</mo> <mi mathvariant='italic'>o</mi> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>t</mi> <mi mathvariant='italic'>p</mi> </msup> <mo stretchy="false">)</mo> </mrow></math> where <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>o</mi> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>t</mi> <mi mathvariant='italic'>p</mi> </msup> <mo stretchy="false">)</mo> <mo stretchy="false">*</mo> <msup><mi mathvariant='italic'>t</mi> <mrow><mo stretchy="false">-</mo> <mi mathvariant='italic'>p</mi> </mrow> </msup> <mo stretchy="false">→</mo> <mn>0</mn> </mrow></math> as <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>t</mi> <mo stretchy="false">→</mo> <mn>0</mn> </mrow></math> . Note that <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>k</mi> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> is related to the <i>k</i>-th derivative of <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>Y</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> </mrow></math> by <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow> <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>k</mi> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">=</mo> <mfrac><mrow><mn>1</mn> </mrow> <mrow><mi mathvariant='italic'>k</mi> <mo stretchy="false">!</mo> </mrow> </mfrac> <msup><mi mathvariant='italic'>Y</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>k</mi> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow></math> <br/> <b><big><a name="f" id="f">f</a></big></b> <br/> The <a href="adfun.xml" target="_top"><span style='white-space: nowrap'>ADFun</span></a> object <i>f</i> has prototype <code><font color="blue"><span style='white-space: nowrap'><br/>      ADFun<</span></font></code><i><span style='white-space: nowrap'>Base</span></i><code><font color="blue"><span style='white-space: nowrap'>> </span></font></code><i><span style='white-space: nowrap'>f</span></i><code><font color="blue"><span style='white-space: nowrap'><br/> </span></font></code>Note that the <a href="adfun.xml" target="_top"><span style='white-space: nowrap'>ADFun</span></a> object <i>f</i> is not <code><font color="blue">const</font></code>. Before this call to <code><font color="blue">Forward</font></code>, the value returned by <code><font color="blue"><span style='white-space: nowrap'><br/>      </span></font></code><i><span style='white-space: nowrap'>f</span></i><code><font color="blue"><span style='white-space: nowrap'>.size_taylor()<br/> </span></font></code>must be greater than or equal <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>p</mi> </mrow></math> . After this call it will be will be <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>p</mi> <mo stretchy="false">+</mo> <mn>1</mn> </mrow></math> (see <a href="size_taylor.xml" target="_top"><span style='white-space: nowrap'>size_taylor</span></a> ). <br/> <br/> <b><big><a name="p" id="p">p</a></big></b> <br/> The argument <i>p</i> has prototype <code><font color="blue"><span style='white-space: nowrap'><br/>      size_t </span></font></code><i><span style='white-space: nowrap'>p</span></i><code><font color="blue"><span style='white-space: nowrap'><br/> </span></font></code>and specifies the order of the Taylor coefficients to be calculated. <br/> <br/> <b><big><a name="x_p" id="x_p">x_p</a></big></b> <br/> The argument <i>x_p</i> has prototype <code><font color="blue"><span style='white-space: nowrap'><br/>      const </span></font></code><i><span style='white-space: nowrap'>Vector</span></i><code><font color="blue"><span style='white-space: nowrap'> &</span></font></code><i><span style='white-space: nowrap'>x_p</span></i><code><font color="blue"><span style='white-space: nowrap'><br/> </span></font></code>(see <a href="forwardany.xml#Vector" target="_top"><span style='white-space: nowrap'>Vector</span></a> below) and its size must be equal to <i>n</i>, the dimension of the <a href="seq_property.xml#Domain" target="_top"><span style='white-space: nowrap'>domain</span></a> space for <i>f</i>. The <i>p</i>-th order Taylor coefficient for <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>X</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> </mrow></math> is defined by this value; i.e., <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>p</mi> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">=</mo> <mi mathvariant='italic'>x</mi> <mo stretchy="false">_</mo> <mi mathvariant='italic'>p</mi> </mrow></math> . (The lower order Taylor coefficients for <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>X</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> </mrow></math> are defined by previous calls to <code><font color="blue">Forward</font></code>.) <br/> <br/> <b><big><a name="y_p" id="y_p">y_p</a></big></b> <br/> The return value <i>y_p</i> has prototype <code><font color="blue"><span style='white-space: nowrap'><br/>      </span></font></code><i><span style='white-space: nowrap'>Vector</span></i><code><font color="blue"><span style='white-space: nowrap'> </span></font></code><i><span style='white-space: nowrap'>y_p</span></i><code><font color="blue"><span style='white-space: nowrap'><br/> </span></font></code>(see <a href="forwardany.xml#Vector" target="_top"><span style='white-space: nowrap'>Vector</span></a> below) and its value is The <i>p</i>-th order Taylor coefficient for <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>Y</mi> <mo stretchy="false">(</mo> <mi mathvariant='italic'>t</mi> <mo stretchy="false">)</mo> </mrow></math> ; i.e., <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mi mathvariant='italic'>p</mi> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">=</mo> <mi mathvariant='italic'>y</mi> <mo stretchy="false">_</mo> <mi mathvariant='italic'>p</mi> </mrow></math> . The size of <i>y_p</i> is equal to <i>m</i>, the dimension of the <a href="seq_property.xml#Range" target="_top"><span style='white-space: nowrap'>range</span></a> space for <i>f</i>. <br/> <br/> <b><big><a name="Vector" id="Vector">Vector</a></big></b> <br/> The type <i>Vector</i> must be a <a href="simplevector.xml" target="_top"><span style='white-space: nowrap'>SimpleVector</span></a> class with <a href="simplevector.xml#Elements of Specified Type" target="_top"><span style='white-space: nowrap'>elements of type</span></a> <i>Base</i>. The routine <a href="checksimplevector.xml" target="_top"><span style='white-space: nowrap'>CheckSimpleVector</span></a> will generate an error message if this is not the case. <br/> <br/> <b><big><a name="Zero Order" id="Zero Order">Zero Order</a></big></b> <br/> In the case where <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>p</mi> <mo stretchy="false">=</mo> <mn>0</mn> </mrow></math> , the result <i>y_p</i> is given by <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow> <mtable rowalign="center" ><mtr><mtd columnalign="right" > <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mtd><mtd columnalign="center" > <mo stretchy="false">=</mo> </mtd><mtd columnalign="left" > <mo stretchy="false">(</mo> <mi mathvariant='italic'>F</mi> <mo stretchy="false">∘</mo> <mi mathvariant='italic'>X</mi> <mo stretchy="false">)</mo> <mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mtd></mtr><mtr><mtd columnalign="right" > </mtd><mtd columnalign="center" > <mo stretchy="false">=</mo> </mtd><mtd columnalign="left" > <mi mathvariant='italic'>F</mi> <mo stretchy="false">[</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">]</mo> </mtd></mtr></mtable> </mrow></math> The agrees with the simplification where <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>p</mi> </mrow></math> , <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> , and <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> above are replaced by <code><font color="blue">0</font></code>, <i>x</i>, and <i>y</i> in <a href="forwardzero.xml" target="_top"><span style='white-space: nowrap'>ForwardZero</span></a> . <br/> <br/> <b><big><a name="First Order" id="First Order">First Order</a></big></b> <br/> In the case where <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>p</mi> <mo stretchy="false">=</mo> <mn>1</mn> </mrow></math> , the result <i>y_p</i> is given by <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow> <mtable rowalign="center" ><mtr><mtd columnalign="right" > <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mtd><mtd columnalign="center" > <mo stretchy="false">=</mo> </mtd><mtd columnalign="left" > <mo stretchy="false">(</mo> <mi mathvariant='italic'>F</mi> <mo stretchy="false">∘</mo> <mi mathvariant='italic'>X</mi> <msup><mo stretchy="false">)</mo> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mtd></mtr><mtr><mtd columnalign="right" > </mtd><mtd columnalign="center" > <mo stretchy="false">=</mo> </mtd><mtd columnalign="left" > <msup><mi mathvariant='italic'>F</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">[</mo> <mi mathvariant='italic'>X</mi> <mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> <mo stretchy="false">]</mo> <mo stretchy="false">*</mo> <msup><mi mathvariant='italic'>X</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mtd></mtr><mtr><mtd columnalign="right" > </mtd><mtd columnalign="center" > <mo stretchy="false">=</mo> </mtd><mtd columnalign="left" > <msup><mi mathvariant='italic'>F</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> <mo stretchy="false">*</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mtd></mtr></mtable> </mrow></math> The agrees with the simplification where <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>p</mi> </mrow></math> , <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> , <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> , and <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> above are replaced by <code><font color="blue">1</font></code>, <i>x</i>, <i>dx</i>, and <i>dy</i> in <a href="forwardone.xml" target="_top"><span style='white-space: nowrap'>ForwardOne</span></a> . <code><span style='white-space: nowrap'><br/> <br/> </span></code>Note that if <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> is the <i>j</i>-th <a href="glossary.xml#Elementary Vector" target="_top"><span style='white-space: nowrap'>elementary vector</span></a> <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow> <msup><mi mathvariant='italic'>y</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">=</mo> <mfrac><mrow><mo stretchy="false">∂</mo> <mi mathvariant='italic'>F</mi> </mrow> <mrow><mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mi mathvariant='italic'>j</mi> </msub> </mrow> </mfrac> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> </mrow></math> <br/> <b><big><a name="Second Order" id="Second Order">Second Order</a></big></b> <br/> In the case where <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <mi mathvariant='italic'>p</mi> <mo stretchy="false">=</mo> <mn>2</mn> </mrow></math> , the <i>i</i>-th element of the result <i>y_p</i> is given by <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow> <mtable rowalign="center" ><mtr><mtd columnalign="right" > <msubsup><mi mathvariant='italic'>y</mi> <mi mathvariant='italic'>i</mi> <mrow><mo stretchy="false">(</mo> <mn>2</mn> <mo stretchy="false">)</mo> </mrow> </msubsup> </mtd><mtd columnalign="center" > <mo stretchy="false">=</mo> </mtd><mtd columnalign="left" > <mfrac><mrow><mn>1</mn> </mrow> <mrow><mn>2</mn> </mrow> </mfrac> <mo stretchy="false">(</mo> <msub><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> </msub> <mo stretchy="false">∘</mo> <mi mathvariant='italic'>X</mi> <msup><mo stretchy="false">)</mo> <mrow><mo stretchy="false">(</mo> <mn>2</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mtd></mtr><mtr><mtd columnalign="right" > </mtd><mtd columnalign="center" > <mo stretchy="false">=</mo> </mtd><mtd columnalign="left" > <mfrac><mrow><mn>1</mn> </mrow> <mrow><mn>2</mn> </mrow> </mfrac> <mrow><mo stretchy="true">[</mo><mrow><msubsup><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msubsup> <mo stretchy="false">[</mo> <mi mathvariant='italic'>X</mi> <mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> <mo stretchy="false">]</mo> <mo stretchy="false">*</mo> <msup><mi mathvariant='italic'>X</mi> <mrow><mo stretchy="false">(</mo> <mn>2</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> <mo stretchy="false">+</mo> <msup><mi mathvariant='italic'>X</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">(</mo> <mn>0</mn> <msup><mo stretchy="false">)</mo> <mi mathvariant='italic'>T</mi> </msup> <mo stretchy="false">*</mo> <msubsup><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> <mrow><mo stretchy="false">(</mo> <mn>2</mn> <mo stretchy="false">)</mo> </mrow> </msubsup> <mo stretchy="false">[</mo> <mi mathvariant='italic'>X</mi> <mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> <mo stretchy="false">]</mo> <mo stretchy="false">*</mo> <msup><mi mathvariant='italic'>X</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow><mo stretchy="true">]</mo></mrow> </mtd></mtr><mtr><mtd columnalign="right" > </mtd><mtd columnalign="center" > <mo stretchy="false">=</mo> </mtd><mtd columnalign="left" > <mfrac><mrow><mn>1</mn> </mrow> <mrow><mn>2</mn> </mrow> </mfrac> <mrow><mo stretchy="true">[</mo><mrow><mn>2</mn> <mo stretchy="false">*</mo> <msubsup><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msubsup> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> <mo stretchy="false">*</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>2</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">+</mo> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> <msup><mo stretchy="false">)</mo> <mi mathvariant='italic'>T</mi> </msup> <mo stretchy="false">*</mo> <msubsup><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> <mrow><mo stretchy="false">(</mo> <mn>2</mn> <mo stretchy="false">)</mo> </mrow> </msubsup> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> <mo stretchy="false">*</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow><mo stretchy="true">]</mo></mrow> </mtd></mtr></mtable> </mrow></math> Note that if <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> is the <i>j</i>-th <a href="glossary.xml#Elementary Vector" target="_top"><span style='white-space: nowrap'>elementary vector</span></a> and <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>2</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> is zero, <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow> <mtable rowalign="center" ><mtr><mtd columnalign="right" > <mfrac><mrow><msup><mo stretchy="false">∂</mo> <mn>2</mn> </msup> <msub><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> </msub> </mrow> <mrow><mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mi mathvariant='italic'>j</mi> </msub> <mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mi mathvariant='italic'>j</mi> </msub> </mrow> </mfrac> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> <mo stretchy="false">=</mo> <mn>2</mn> <msubsup><mi mathvariant='italic'>y</mi> <mi mathvariant='italic'>i</mi> <mrow><mo stretchy="false">(</mo> <mn>2</mn> <mo stretchy="false">)</mo> </mrow> </msubsup> </mtd></mtr></mtable> </mrow></math> If <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>1</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> is the sum of the <i>j</i>-th and <i>l</i>-th <a href="glossary.xml#Elementary Vector" target="_top"><span style='white-space: nowrap'>elementary vectors</span></a> and <math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>2</mn> <mo stretchy="false">)</mo> </mrow> </msup> </mrow></math> is zero, <math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow> <mtable rowalign="center" ><mtr><mtd columnalign="right" > <msubsup><mi mathvariant='italic'>y</mi> <mi mathvariant='italic'>i</mi> <mrow><mo stretchy="false">(</mo> <mn>2</mn> <mo stretchy="false">)</mo> </mrow> </msubsup> </mtd><mtd columnalign="center" > <mo stretchy="false">=</mo> </mtd><mtd columnalign="left" > <mfrac><mrow><mn>1</mn> </mrow> <mrow><mn>2</mn> </mrow> </mfrac> <mrow><mo stretchy="true">[</mo><mrow><mfrac><mrow><msup><mo stretchy="false">∂</mo> <mn>2</mn> </msup> <msub><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> </msub> </mrow> <mrow><mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mi mathvariant='italic'>j</mi> </msub> <mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mi mathvariant='italic'>j</mi> </msub> </mrow> </mfrac> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> <mo stretchy="false">+</mo> <mfrac><mrow><msup><mo stretchy="false">∂</mo> <mn>2</mn> </msup> <msub><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> </msub> </mrow> <mrow><mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mi mathvariant='italic'>j</mi> </msub> <mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mo stretchy="false">ℓ</mo> </msub> </mrow> </mfrac> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> <mo stretchy="false">+</mo> <mfrac><mrow><msup><mo stretchy="false">∂</mo> <mn>2</mn> </msup> <msub><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> </msub> </mrow> <mrow><mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mo stretchy="false">ℓ</mo> </msub> <mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mi mathvariant='italic'>j</mi> </msub> </mrow> </mfrac> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> <mo stretchy="false">+</mo> <mfrac><mrow><msup><mo stretchy="false">∂</mo> <mn>2</mn> </msup> <msub><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> </msub> </mrow> <mrow><mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mo stretchy="false">ℓ</mo> </msub> <mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mo stretchy="false">ℓ</mo> </msub> </mrow> </mfrac> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> </mrow><mo stretchy="true">]</mo></mrow> </mtd></mtr><mtr><mtd columnalign="right" > <mfrac><mrow><msup><mo stretchy="false">∂</mo> <mn>2</mn> </msup> <msub><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> </msub> </mrow> <mrow><mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mo stretchy="false">ℓ</mo> </msub> <mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mi mathvariant='italic'>j</mi> </msub> </mrow> </mfrac> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> </mtd><mtd columnalign="center" > <mo stretchy="false">=</mo> </mtd><mtd columnalign="left" > <msubsup><mi mathvariant='italic'>y</mi> <mi mathvariant='italic'>i</mi> <mrow><mo stretchy="false">(</mo> <mn>2</mn> <mo stretchy="false">)</mo> </mrow> </msubsup> <mo stretchy="false">-</mo> <mfrac><mrow><mn>1</mn> </mrow> <mrow><mn>2</mn> </mrow> </mfrac> <mfrac><mrow><msup><mo stretchy="false">∂</mo> <mn>2</mn> </msup> <msub><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> </msub> </mrow> <mrow><mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mi mathvariant='italic'>j</mi> </msub> <mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mi mathvariant='italic'>j</mi> </msub> </mrow> </mfrac> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> <mo stretchy="false">-</mo> <mfrac><mrow><mn>1</mn> </mrow> <mrow><mn>2</mn> </mrow> </mfrac> <mfrac><mrow><msup><mo stretchy="false">∂</mo> <mn>2</mn> </msup> <msub><mi mathvariant='italic'>F</mi> <mi mathvariant='italic'>i</mi> </msub> </mrow> <mrow><mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mo stretchy="false">ℓ</mo> </msub> <mo stretchy="false">∂</mo> <msub><mi mathvariant='italic'>x</mi> <mo stretchy="false">ℓ</mo> </msub> </mrow> </mfrac> <mo stretchy="false">(</mo> <msup><mi mathvariant='italic'>x</mi> <mrow><mo stretchy="false">(</mo> <mn>0</mn> <mo stretchy="false">)</mo> </mrow> </msup> <mo stretchy="false">)</mo> </mtd></mtr></mtable> </mrow></math> <br/> <b><big><a name="Example" id="Example">Example</a></big></b> <br/> The file <a href="forward.cpp.xml" target="_top"><span style='white-space: nowrap'>Forward.cpp</span></a> contains an example and test of this operation. It returns true if it succeeds and false otherwise. <hr/>Input File: omh/forward.omh </body> </html>