<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>exp_2: Second Order Reverse Mode</title>
<meta name="description" id="description" content="exp_2: Second Order Reverse Mode"/>
<meta name="keywords" id="keywords" content=" exp_2 reverse mode example second order "/>
<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='_exp_2_rev2_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="exp_2_for2.cpp.xml" target="_top">Prev</a>
</td><td><a href="exp_2_rev2.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>Introduction</option>
<option>exp_2</option>
<option>exp_2_rev2</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>preprocessor</option>
<option>multi_thread</option>
<option>library</option>
<option>ipopt_solve</option>
<option>Example</option>
<option>speed</option>
<option>Appendix</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>Introduction-&gt;</option>
<option>get_started.cpp</option>
<option>exp_2</option>
<option>exp_eps</option>
<option>exp_apx_main.cpp</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>exp_2-&gt;</option>
<option>exp_2.hpp</option>
<option>exp_2.cpp</option>
<option>exp_2_for0</option>
<option>exp_2_for1</option>
<option>exp_2_rev1</option>
<option>exp_2_for2</option>
<option>exp_2_rev2</option>
<option>exp_2_cppad</option>
</select>
</td>
<td>
<select onchange='choose_down0(this)'>
<option>exp_2_rev2-&gt;</option>
<option>exp_2_rev2.cpp</option>
</select>
</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Purpose</option>
<option>Mathematical Form</option>
<option>f_5</option>
<option>Index 5: f_4</option>
<option>Index 4: f_3</option>
<option>Index 3: f_2</option>
<option>Index 2: f_1</option>
<option>Verification</option>
<option>Exercises</option>
</select>
</td>
</tr></table><br/>



<center><b><big><big>exp_2: Second Order Reverse Mode</big></big></b></center>
<br/>
<b><big><a name="Purpose" id="Purpose">Purpose</a></big></b>
<br/>
In general, a second order reverse sweep is given the
<a href="exp_2_for1.xml#First Order Expansion" target="_top"><span style='white-space: nowrap'>first&#xA0;order&#xA0;expansion</span></a>

for all of the variables in an operation sequence.
Given a choice of a particular variable, 
it computes the derivative, 
of that variables first order expansion coefficient, 
with respect to all of the independent variables.

<br/>
<br/>
<b><big><a name="Mathematical Form" id="Mathematical Form">Mathematical Form</a></big></b>
<br/>
Suppose that we use the algorithm <a href="exp_2.hpp.xml" target="_top"><span style='white-space: nowrap'>exp_2.hpp</span></a>
 to compute 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mi mathvariant='italic'>f</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mn>1</mn>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">+</mo>
<msup><mi mathvariant='italic'>x</mi>
<mn>2</mn>
</msup>
<mo stretchy="false">/</mo>
<mn>2</mn>
</mrow></math>

The corresponding second derivative is 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mfrac><mrow><msup><mo stretchy="false">&#x02202;</mo>
<mrow><mn>2</mn>
</mrow>
</msup>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msup><mrow><mi mathvariant='italic'>x</mi>
</mrow>
<mrow><mn>2</mn>
</mrow>
</msup>
</mrow>
</mfrac>
<mi mathvariant='italic'>f</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mn>1</mn>
</mrow></math>

<br/>
<b><big><a name="f_5" id="f_5">f_5</a></big></b>
<br/>
For our example, we chose to compute the derivative of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>


with respect to all the independent variable.
For the case computed for the
<a href="exp_2_for1.xml#Operation Sequence.Sweep" target="_top"><span style='white-space: nowrap'>first&#xA0;order&#xA0;sweep</span></a>
,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>

 is the derivative 
of the value returned by <a href="exp_2.hpp.xml" target="_top"><span style='white-space: nowrap'>exp_2.hpp</span></a>
.
This the value computed will be the second derivative of 
the value returned by  <a href="exp_2.hpp.xml" target="_top"><span style='white-space: nowrap'>exp_2.hpp</span></a>
.
We begin with the function 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>5</mn>
</msub>
</mrow></math>

 where 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>

 
is both an argument and the value of the function; i.e.,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<msub><mi mathvariant='italic'>f</mi>
<mn>5</mn>
</msub>
<mrow><mo stretchy="true">(</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow><mo stretchy="true">)</mo></mrow>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd></mtr><mtr><mtd columnalign="right" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>5</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mn>1</mn>
</mtd></mtr></mtable>
</mrow></math>

All the other partial derivatives of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>5</mn>
</msub>
</mrow></math>

 are zero.

<br/>
<br/>
<b><big><a name="Index 5: f_4" id="Index 5: f_4">Index 5: f_4</a></big></b>
<br/>
Second order reverse mode starts with the last operation in the sequence.
For the case in question, this is the operation with index 5.
The zero and first order sweep representations of this operation are

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">+</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd></mtr><mtr><mtd columnalign="right" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">+</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd></mtr></mtable>
</mrow></math>

We define the function 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>4</mn>
</msub>
<mrow><mo stretchy="true">(</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow><mo stretchy="true">)</mo></mrow>
</mrow></math>


as equal to 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>5</mn>
</msub>
</mrow></math>


except that 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>

 and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>

 are eliminated using 
this operation; i.e.

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>4</mn>
</msub>
<mo stretchy="false">=</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>5</mn>
</msub>
<mrow><mo stretchy="true">[</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mrow><mo stretchy="true">(</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow><mo stretchy="true">)</mo></mrow>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mrow><mo stretchy="true">(</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow><mo stretchy="true">)</mo></mrow>
</mrow><mo stretchy="true">]</mo></mrow>
</mrow></math>

It follows that 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>4</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>5</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">+</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>5</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">*</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="left" >
<mo stretchy="false">=</mo>
<mn>1</mn>
</mtd></mtr><mtr><mtd columnalign="right" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>4</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>5</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">+</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>5</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">*</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>v</mi>
<mn>5</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="left" >
<mo stretchy="false">=</mo>
<mn>1</mn>
</mtd></mtr></mtable>
</mrow></math>

All the other partial derivatives of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>4</mn>
</msub>
</mrow></math>

 are zero.

<br/>
<br/>
<b><big><a name="Index 4: f_3" id="Index 4: f_3">Index 4: f_3</a></big></b>
<br/>
The next operation has index 4, 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">/</mo>
<mn>2</mn>
</mtd></mtr><mtr><mtd columnalign="right" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">/</mo>
<mn>2</mn>
</mtd></mtr></mtable>
</mrow></math>

We define the function 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
<mrow><mo stretchy="true">(</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow><mo stretchy="true">)</mo></mrow>
</mrow></math>


as equal to 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>4</mn>
</msub>
</mrow></math>


except that 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>

 and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>

 
are eliminated using this operation; i.e.,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
<mo stretchy="false">=</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>4</mn>
</msub>
<mrow><mo stretchy="true">[</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mrow><mo stretchy="true">(</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow><mo stretchy="true">)</mo></mrow>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mrow><mo stretchy="true">(</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow><mo stretchy="true">)</mo></mrow>
</mrow><mo stretchy="true">]</mo></mrow>
</mrow></math>

It follows that 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>4</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="left" >
<mo stretchy="false">=</mo>
<mn>1</mn>
</mtd></mtr><mtr><mtd columnalign="right" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>4</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">+</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>4</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">*</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>4</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="left" >
<mo stretchy="false">=</mo>
<mn>0.5</mn>
</mtd></mtr></mtable>
</mrow></math>

All the other partial derivatives of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
</mrow></math>

 are zero.

<br/>
<br/>
<b><big><a name="Index 3: f_2" id="Index 3: f_2">Index 3: f_2</a></big></b>
<br/>
The next operation has index 3,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">*</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd></mtr><mtr><mtd columnalign="right" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mn>2</mn>
<mo stretchy="false">*</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">*</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd></mtr></mtable>
</mrow></math>

We define the function 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
<mrow><mo stretchy="true">(</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow><mo stretchy="true">)</mo></mrow>
</mrow></math>


as equal to 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
</mrow></math>


except that 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>

 and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>

 are
eliminated using this operation; i.e.,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
<mo stretchy="false">=</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
<mrow><mo stretchy="true">[</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">(</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">)</mo>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">(</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">)</mo>
</mrow><mo stretchy="true">]</mo></mrow>
</mrow></math>

Note that, from the 
<a href="exp_2_for1.xml#Operation Sequence.Sweep" target="_top"><span style='white-space: nowrap'>first&#xA0;order&#xA0;forward&#xA0;sweep</span></a>
,
the value of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>

 is equal to 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mn>.5</mn>
</mrow></math>


and  
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>

 is equal 1. 
It follows that 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">+</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">*</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">+</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">*</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="left" >
<mo stretchy="false">=</mo>
<mn>1</mn>
</mtd></mtr><mtr><mtd columnalign="right" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">+</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">*</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>3</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="left" >
<mo stretchy="false">=</mo>
<mn>0.5</mn>
</mtd></mtr><mtr><mtd columnalign="right" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="left" >
<mo stretchy="false">=</mo>
<mn>0</mn>
</mtd></mtr><mtr><mtd columnalign="right" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>3</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="left" >
<mo stretchy="false">=</mo>
<mn>1</mn>
</mtd></mtr></mtable>
</mrow></math>

<br/>
<b><big><a name="Index 2: f_1" id="Index 2: f_1">Index 2: f_1</a></big></b>
<br/>
The next operation has index 2,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mn>1</mn>
<mo stretchy="false">+</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd></mtr><mtr><mtd columnalign="right" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mtd></mtr></mtable>
</mrow></math>

We define the function 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">(</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">)</mo>
</mrow></math>


as equal to 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
</mrow></math>


except that 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>

 and  
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow></math>


are eliminated using this operation; i.e.,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">=</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
<mrow><mo stretchy="true">[</mo><mrow><msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">(</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">)</mo>
<mo stretchy="false">,</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">(</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">)</mo>
</mrow><mo stretchy="true">]</mo></mrow>
</mrow></math>

It follows that 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>1</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">+</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">*</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="left" >
<mo stretchy="false">=</mo>
<mn>1</mn>
</mtd></mtr><mtr><mtd columnalign="right" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>1</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">+</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>2</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">*</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>2</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
</mtd><mtd columnalign="left" >
<mo stretchy="false">=</mo>
<mn>1.5</mn>
</mtd></mtr></mtable>
</mrow></math>

Note that 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>v</mi>
<mn>1</mn>
</msub>
</mrow></math>

 is equal to 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>x</mi>
</mrow></math>

,
so the second derivative of 
the function defined by <a href="exp_2.hpp.xml" target="_top"><span style='white-space: nowrap'>exp_2.hpp</span></a>
 at 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">=</mo>
<mn>.5</mn>
</mrow></math>


is given by

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mfrac><mrow><msup><mo stretchy="false">&#x02202;</mo>
<mrow><mn>2</mn>
</mrow>
</msup>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msup><mrow><mi mathvariant='italic'>x</mi>
</mrow>
<mrow><mn>2</mn>
</mrow>
</msup>
</mrow>
</mfrac>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
<mo stretchy="false">=</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<mi mathvariant='italic'>x</mi>
</mrow>
</mfrac>
<mo stretchy="false">=</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>5</mn>
<mrow><mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">=</mo>
<mfrac><mrow><mo stretchy="false">&#x02202;</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>1</mn>
</msub>
</mrow>
<mrow><mo stretchy="false">&#x02202;</mo>
<msubsup><mi mathvariant='italic'>v</mi>
<mn>1</mn>
<mrow><mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">)</mo>
</mrow>
</msubsup>
</mrow>
</mfrac>
<mo stretchy="false">=</mo>
<mn>1</mn>
</mrow></math>

There is a theorem about Algorithmic Differentiation that explains why
the other partial of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>1</mn>
</msub>
</mrow></math>

 is equal to the
first derivative of 
the function defined by <a href="exp_2.hpp.xml" target="_top"><span style='white-space: nowrap'>exp_2.hpp</span></a>
 at 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">=</mo>
<mn>.5</mn>
</mrow></math>

.



<br/>
<br/>
<b><big><a name="Verification" id="Verification">Verification</a></big></b>
<br/>
The file <a href="exp_2_rev2.cpp.xml" target="_top"><span style='white-space: nowrap'>exp_2_rev2.cpp</span></a>
 contains a routine 
which verifies the values computed above.
It returns true for success and false for failure.
It only tests the partial derivatives of

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mi mathvariant='italic'>j</mi>
</msub>
</mrow></math>

 that might not be equal to the corresponding
partials of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mrow><mi mathvariant='italic'>j</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
</mrow>
</msub>
</mrow></math>

; i.e., the
other partials of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mi mathvariant='italic'>j</mi>
</msub>
</mrow></math>

 must be equal to the corresponding
partials of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mrow><mi mathvariant='italic'>j</mi>
<mo stretchy="false">+</mo>
<mn>1</mn>
</mrow>
</msub>
</mrow></math>

.

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

<ol type="1"><li>
Which statement in the routine defined by <a href="exp_2_rev2.cpp.xml" target="_top"><span style='white-space: nowrap'>exp_2_rev2.cpp</span></a>
 uses 
the values that are calculated by the routine 
defined by <a href="exp_2_for0.cpp.xml" target="_top"><span style='white-space: nowrap'>exp_2_for0.cpp</span></a>
 ?
Which statements use values that are calculate by the routine
defined in <a href="exp_2_for1.cpp.xml" target="_top"><span style='white-space: nowrap'>exp_2_for1.cpp</span></a>
 ?
</li><li>

Consider the case where 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">=</mo>
<mn>.1</mn>
</mrow></math>


and we first preform a zero order forward sweep,
then a first order sweep,
for the operation sequence used above.
What are the results of a 
second order reverse sweep; i.e.,
what are the corresponding derivatives of

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>f</mi>
<mn>5</mn>
</msub>
<mo stretchy="false">,</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>4</mn>
</msub>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<msub><mi mathvariant='italic'>f</mi>
<mn>1</mn>
</msub>
</mrow></math>

.
</li><li>

Create a modified version of 
<a href="exp_2_rev2.cpp.xml" target="_top"><span style='white-space: nowrap'>exp_2_rev2.cpp</span></a>
 
that verifies the values you obtained for the previous exercise.
Also create and run a main program that reports the result
of calling the modified version of
<a href="exp_2_rev2.cpp.xml" target="_top"><span style='white-space: nowrap'>exp_2_rev2.cpp</span></a>
.
</li></ol>



<hr/>Input File: introduction/exp_apx/exp_2.omh

</body>
</html>
