<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>Reverse Mode Second Partial Derivative Driver</title>
<meta name="description" id="description" content="Reverse Mode Second Partial Derivative Driver"/>
<meta name="keywords" id="keywords" content=" partial second order driver easy "/>
<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='_revtwo_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="fortwo.cpp.xml" target="_top">Prev</a>
</td><td><a href="revtwo.cpp.xml" target="_top">Next</a>
</td><td>
<select onchange='choose_across0(this)'>
<option>Index-&gt;</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-&gt;</option>
<option>CppAD</option>
<option>ADFun</option>
<option>Drivers</option>
<option>RevTwo</option>
</select>
</td>
<td>
<select onchange='choose_down3(this)'>
<option>CppAD-&gt;</option>
<option>Install</option>
<option>Introduction</option>
<option>AD</option>
<option>ADFun</option>
<option>multi_thread</option>
<option>library</option>
<option>cppad_ipopt_nlp</option>
<option>Example</option>
<option>preprocessor</option>
<option>Appendix</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>ADFun-&gt;</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>optimize</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>Drivers-&gt;</option>
<option>Jacobian</option>
<option>ForOne</option>
<option>RevOne</option>
<option>Hessian</option>
<option>ForTwo</option>
<option>RevTwo</option>
<option>sparse_jacobian</option>
<option>sparse_hessian</option>
</select>
</td>
<td>
<select onchange='choose_down0(this)'>
<option>RevTwo-&gt;</option>
<option>RevTwo.cpp</option>
</select>
</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Syntax</option>
<option>Purpose</option>
<option>f</option>
<option>x</option>
<option>i</option>
<option>j</option>
<option>ddw</option>
<option>VectorBase</option>
<option>VectorSize_t</option>
<option>RevTwo Uses Forward</option>
<option>Examples</option>
</select>
</td>
</tr></table><br/>













<center><b><big><big>Reverse Mode Second Partial Derivative Driver</big></big></b></center>
<br/>
<b><big><a name="Syntax" id="Syntax">Syntax</a></big></b>

<br/>

<code><i><font color="black"><span style='white-space: nowrap'>ddw</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>f</span></font></i><font color="blue"><span style='white-space: nowrap'>.RevTwo(</span></font><i><font color="black"><span style='white-space: nowrap'>x</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>i</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>j</span></font></i><font color="blue"><span style='white-space: nowrap'>)</span></font></code>



<br/>
<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">&#x02192;</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&#xA0;function</span></a>
 corresponding to 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
.
The syntax above sets 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mi mathvariant='italic'>ddw</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">*</mo>
<mi mathvariant='italic'>p</mi>
<mo stretchy="false">+</mo>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">]</mo>
<mo stretchy="false">=</mo>
<mfrac><mrow><msup><mo stretchy="false">&#x02202;</mo>
<mn>2</mn>
</msup>
<msub><mi mathvariant='italic'>F</mi>
<mrow><mi mathvariant='italic'>i</mi>
<mo stretchy="false">[</mo>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">]</mo>
</mrow>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>x</mi>
<mrow><mi mathvariant='italic'>j</mi>
<mo stretchy="false">[</mo>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">]</mo>
</mrow>
</msub>
<mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>k</mi>
</msub>
</mrow>
</mfrac>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
</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">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>n</mi>
<mn>-1</mn>
</mrow></math>


and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>p</mi>
</mrow></math>

,
where 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>p</mi>
</mrow></math>

 is the size of the vectors 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
 and 
<code><i><font color="black"><span style='white-space: nowrap'>j</span></font></i></code>
.

<br/>
<br/>
<b><big><a name="f" id="f">f</a></big></b>
<br/>
The object 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
 has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;ADFun&lt;</span></font><i><font color="black"><span style='white-space: nowrap'>Base</span></font></i><font color="blue"><span style='white-space: nowrap'>&gt;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>f</span></font></i><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 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
 is not <code><font color="blue">const</font></code>
(see <a href="revtwo.xml#RevTwo Uses Forward" target="_top"><span style='white-space: nowrap'>RevTwo&#xA0;Uses&#xA0;Forward</span></a>
 below).

<br/>
<br/>
<b><big><a name="x" id="x">x</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>x</span></font></i></code>
 has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;const&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>VectorBase</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>x</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
(see <a href="revtwo.xml#VectorBase" target="_top"><span style='white-space: nowrap'>VectorBase</span></a>
 below)
and its size 
must be equal to 
<code><i><font color="black"><span style='white-space: nowrap'>n</span></font></i></code>
, the dimension of the
<a href="seq_property.xml#Domain" target="_top"><span style='white-space: nowrap'>domain</span></a>
 space for 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
.
It specifies
that point at which to evaluate the partial derivatives listed above.

<br/>
<br/>
<b><big><a name="i" id="i">i</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
 has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;const&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>VectorSize_t</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>i</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
(see <a href="revtwo.xml#VectorSize_t" target="_top"><span style='white-space: nowrap'>VectorSize_t</span></a>
 below)
We use 
<code><i><font color="black"><span style='white-space: nowrap'>p</span></font></i></code>
 to denote the size of the vector 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
.
All of the indices in 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
 
must be less than 
<code><i><font color="black"><span style='white-space: nowrap'>m</span></font></i></code>
, the dimension of the
<a href="seq_property.xml#Range" target="_top"><span style='white-space: nowrap'>range</span></a>
 space for 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
; i.e.,
for 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>p</mi>
<mn>-1</mn>
</mrow></math>

, 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">[</mo>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">]</mo>
<mo stretchy="false">&lt;</mo>
<mi mathvariant='italic'>m</mi>
</mrow></math>

.

<br/>
<br/>
<b><big><a name="j" id="j">j</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>j</span></font></i></code>
 has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;const&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>VectorSize_t</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>j</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
(see <a href="revtwo.xml#VectorSize_t" target="_top"><span style='white-space: nowrap'>VectorSize_t</span></a>
 below)
and its size must be equal to 
<code><i><font color="black"><span style='white-space: nowrap'>p</span></font></i></code>
,
the size of the vector 
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i></code>
.
All of the indices in 
<code><i><font color="black"><span style='white-space: nowrap'>j</span></font></i></code>
 
must be less than 
<code><i><font color="black"><span style='white-space: nowrap'>n</span></font></i></code>
; i.e.,
for 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>p</mi>
<mn>-1</mn>
</mrow></math>

, 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">[</mo>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">]</mo>
<mo stretchy="false">&lt;</mo>
<mi mathvariant='italic'>n</mi>
</mrow></math>

.

<br/>
<br/>
<b><big><a name="ddw" id="ddw">ddw</a></big></b>
<br/>
The result 
<code><i><font color="black"><span style='white-space: nowrap'>ddw</span></font></i></code>
 has prototype

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>VectorBase</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>ddw</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
(see <a href="revtwo.xml#VectorBase" target="_top"><span style='white-space: nowrap'>VectorBase</span></a>
 below)
and its size is 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>n</mi>
<mo stretchy="false">*</mo>
<mi mathvariant='italic'>p</mi>
</mrow></math>

.
It contains the requested partial derivatives; to be specific,
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">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>n</mi>
<mo stretchy="false">-</mo>
<mn>1</mn>
</mrow></math>

 
and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>p</mi>
<mo stretchy="false">-</mo>
<mn>1</mn>
</mrow></math>



<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mi mathvariant='italic'>ddw</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>k</mi>
<mo stretchy="false">*</mo>
<mi mathvariant='italic'>p</mi>
<mo stretchy="false">+</mo>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">]</mo>
<mo stretchy="false">=</mo>
<mfrac><mrow><msup><mo stretchy="false">&#x02202;</mo>
<mn>2</mn>
</msup>
<msub><mi mathvariant='italic'>F</mi>
<mrow><mi mathvariant='italic'>i</mi>
<mo stretchy="false">[</mo>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">]</mo>
</mrow>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>x</mi>
<mrow><mi mathvariant='italic'>j</mi>
<mo stretchy="false">[</mo>
<mo stretchy="false">&#x02113;</mo>
<mo stretchy="false">]</mo>
</mrow>
</msub>
<mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>x</mi>
<mi mathvariant='italic'>k</mi>
</msub>
</mrow>
</mfrac>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
</mrow></math>

<br/>
<b><big><a name="VectorBase" id="VectorBase">VectorBase</a></big></b>
<br/>
The type 
<code><i><font color="black"><span style='white-space: nowrap'>VectorBase</span></font></i></code>
 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&#xA0;of&#xA0;type&#xA0;Base</span></a>
.
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="VectorSize_t" id="VectorSize_t">VectorSize_t</a></big></b>
<br/>
The type 
<code><i><font color="black"><span style='white-space: nowrap'>VectorSize_t</span></font></i></code>
 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&#xA0;of&#xA0;type&#xA0;size_t</span></a>
.
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="RevTwo Uses Forward" id="RevTwo Uses Forward">RevTwo Uses Forward</a></big></b>
<br/>
After each call to <a href="forward.xml" target="_top"><span style='white-space: nowrap'>Forward</span></a>
,
the object 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
 contains the corresponding 
<a href="glossary.xml#Taylor Coefficient" target="_top"><span style='white-space: nowrap'>Taylor&#xA0;coefficients</span></a>
.
After <code><font color="blue">RevTwo</font></code>,
the previous calls to <a href="forward.xml" target="_top"><span style='white-space: nowrap'>Forward</span></a>
 are undefined.

<br/>
<br/>
<b><big><a name="Examples" id="Examples">Examples</a></big></b>

<br/>
The routine 
<a href="revtwo.cpp.xml" target="_top"><span style='white-space: nowrap'>RevTwo</span></a>
 is both an example and test.
It returns <code><font color="blue">true</font></code>, if it succeeds and <code><font color="blue">false</font></code> otherwise.


<hr/>Input File: cppad/local/rev_two.hpp

</body>
</html>

