<?xml version='1.0'?>
<?xml-stylesheet type='text/xsl' href='pmathml.xsl'?>
<html xmlns='http://www.w3.org/1999/xhtml'>
<head>
<title>A 3rd and 4th Order Rosenbrock ODE Solver</title>
<meta name="description" id="description" content="A 3rd and 4th Order Rosenbrock ODE Solver"/>
<meta name="keywords" id="keywords" content=" Rosen34 Ode Rosenbrock solve stiff differential equation parallel "/>
<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='_rosen34_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="runge_45_2.cpp.xml" target="_top">Prev</a>
</td><td><a href="rosen34.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>library</option>
<option>Rosen34</option>
</select>
</td>
<td>
<select onchange='choose_down2(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_down1(this)'>
<option>library-&gt;</option>
<option>ErrorHandler</option>
<option>NearEqual</option>
<option>speed_test</option>
<option>SpeedTest</option>
<option>time_test</option>
<option>NumericType</option>
<option>CheckNumericType</option>
<option>SimpleVector</option>
<option>CheckSimpleVector</option>
<option>nan</option>
<option>pow_int</option>
<option>Poly</option>
<option>LuDetAndSolve</option>
<option>RombergOne</option>
<option>RombergMul</option>
<option>Runge45</option>
<option>Rosen34</option>
<option>OdeErrControl</option>
<option>OdeGear</option>
<option>OdeGearControl</option>
<option>BenderQuad</option>
<option>opt_val_hes</option>
<option>LuRatio</option>
<option>CppAD_vector</option>
<option>thread_alloc</option>
<option>memory_leak</option>
</select>
</td>
<td>
<select onchange='choose_down0(this)'>
<option>Rosen34-&gt;</option>
<option>Rosen34.cpp</option>
</select>
</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Syntax</option>
<option>Description</option>
<option>Include</option>
<option>xf</option>
<option>Fun</option>
<option>---..t</option>
<option>---..x</option>
<option>---..f</option>
<option>---..f_t</option>
<option>---..f_x</option>
<option>---..Nan</option>
<option>---..Warning</option>
<option>---..Optimization</option>
<option>M</option>
<option>ti</option>
<option>tf</option>
<option>xi</option>
<option>e</option>
<option>Scalar</option>
<option>Vector</option>
<option>Parallel Mode</option>
<option>Example</option>
<option>Source Code</option>
</select>
</td>
</tr></table><br/>










 
<center><b><big><big>A 3rd and 4th Order Rosenbrock ODE Solver</big></big></b></center>
<br/>
<b><big><a name="Syntax" id="Syntax">Syntax</a></big></b>

<br/>

<code><font color="blue"><span style='white-space: nowrap'>#&#xA0;include&#xA0;&lt;cppad/rosen_34.hpp&gt;<br/>
</span></font></code>

<code><i><font color="black"><span style='white-space: nowrap'>xf</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;Rosen34(</span></font><i><font color="black"><span style='white-space: nowrap'>F</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>M</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>ti</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>tf</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>xi</span></font></i><font color="blue"><span style='white-space: nowrap'>)<br/>
</span></font></code>

<code><i><font color="black"><span style='white-space: nowrap'>xf</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;=&#xA0;Rosen34(</span></font><i><font color="black"><span style='white-space: nowrap'>F</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>M</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>ti</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>tf</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>xi</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>e</span></font></i><font color="blue"><span style='white-space: nowrap'>)<br/>
</span></font></code>
<br/>
<b><big><a name="Description" id="Description">Description</a></big></b>
<br/>
This is an embedded 3rd and 4th order Rosenbrock ODE solver 
(see Section 16.6 of <a href="bib.xml#Numerical Recipes" target="_top"><span style='white-space: nowrap'>Numerical&#xA0;Recipes</span></a>

for a description of Rosenbrock ODE solvers).
In particular, we use the formulas taken from page 100 of
<a href="bib.xml#Shampine, L.F." target="_top"><span style='white-space: nowrap'>Shampine,&#xA0;L.F.</span></a>

(except that the fraction 98/108 has been correction to be 97/108).
<code><span style='white-space: nowrap'><br/>
<br/>
</span></code>We use 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>n</mi>
</mrow></math>

 for the size of the vector 
<code><i><font color="black"><span style='white-space: nowrap'>xi</span></font></i></code>
.
Let 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
</mrow></math>

 denote the real numbers
and let 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>F</mi>
<mo stretchy="false">:</mo>
<mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mo stretchy="false">&#x000D7;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mi mathvariant='italic'>n</mi>
</msup>
<mo stretchy="false">&#x02192;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mi mathvariant='italic'>n</mi>
</msup>
</mrow></math>

 be a smooth function.
The return value 
<code><i><font color="black"><span style='white-space: nowrap'>xf</span></font></i></code>
 contains a 5th order
approximation for the value 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>X</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>tf</mi>
<mo stretchy="false">)</mo>
</mrow></math>

 where 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>X</mi>
<mo stretchy="false">:</mo>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>ti</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>tf</mi>
<mo stretchy="false">]</mo>
<mo stretchy="false">&#x02192;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mi mathvariant='italic'>n</mi>
</msup>
</mrow></math>

 is defined by 
the following initial value problem:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<mi mathvariant='italic'>X</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>ti</mi>
<mo stretchy="false">)</mo>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mi mathvariant='italic'>xi</mi>
</mtd></mtr><mtr><mtd columnalign="right" >
<mi mathvariant='italic'>X</mi>
<mo stretchy="false">'</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mi mathvariant='italic'>F</mi>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>t</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>
</mtd></mtr></mtable>
</mrow></math>

If your set of  ordinary differential equations are not stiff
an explicit method may be better (perhaps <a href="runge45.xml" target="_top"><span style='white-space: nowrap'>Runge45</span></a>
.)

<br/>
<br/>
<b><big><a name="Include" id="Include">Include</a></big></b>
<br/>
The file <code><font color="blue">cppad/rosen_34.hpp</font></code> is included by <code><font color="blue">cppad/cppad.hpp</font></code>
but it can also be included separately with out the rest of 
the <code><font color="blue">CppAD</font></code> routines.

<br/>
<br/>
<b><big><a name="xf" id="xf">xf</a></big></b>
<br/>
The return value 
<code><i><font color="black"><span style='white-space: nowrap'>xf</span></font></i></code>
 has the 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'>Vector</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>xf</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
and the size of 
<code><i><font color="black"><span style='white-space: nowrap'>xf</span></font></i></code>
 is equal to <i>n</i> 
(see description of <a href="rosen34.xml#Vector" target="_top"><span style='white-space: nowrap'>Vector</span></a>
 below).

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mi mathvariant='italic'>X</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>tf</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mi mathvariant='italic'>xf</mi>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>O</mi>
<mo stretchy="false">(</mo>
<msup><mi mathvariant='italic'>h</mi>
<mn>5</mn>
</msup>
<mo stretchy="false">)</mo>
</mrow></math>

where 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>h</mi>
<mo stretchy="false">=</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>tf</mi>
<mo stretchy="false">-</mo>
<mi mathvariant='italic'>ti</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">/</mo>
<mi mathvariant='italic'>M</mi>
</mrow></math>

 is the step size.
If 
<code><i><font color="black"><span style='white-space: nowrap'>xf</span></font></i></code>
 contains not a number <a href="nan.xml" target="_top"><span style='white-space: nowrap'>nan</span></a>
,
see the discussion of <a href="rosen34.xml#Fun.Nan" target="_top"><span style='white-space: nowrap'>f</span></a>
.

<br/>
<br/>
<b><big><a name="Fun" id="Fun">Fun</a></big></b>
<br/>
The class 
<code><i><font color="black"><span style='white-space: nowrap'>Fun</span></font></i></code>
 
and the object 
<code><i><font color="black"><span style='white-space: nowrap'>F</span></font></i></code>
 satisfy the 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'>Fun</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</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>
This must support the following set of calls

<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'>F</span></font></i><font color="blue"><span style='white-space: nowrap'>.Ode(</span></font><i><font color="black"><span style='white-space: nowrap'>t</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</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'>f</span></font></i><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'>F</span></font></i><font color="blue"><span style='white-space: nowrap'>.Ode_ind(</span></font><i><font color="black"><span style='white-space: nowrap'>t</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</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'>f_t</span></font></i><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'>F</span></font></i><font color="blue"><span style='white-space: nowrap'>.Ode_dep(</span></font><i><font color="black"><span style='white-space: nowrap'>t</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</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'>f_x</span></font></i><font color="blue"><span style='white-space: nowrap'>)<br/>
</span></font></code>
<br/>
<b><a name="Fun.t" id="Fun.t">t</a></b>
<br/>
In all three cases, 
the argument 
<code><i><font color="black"><span style='white-space: nowrap'>t</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'>Scalar</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>t</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
(see description of <a href="rosen34.xml#Scalar" target="_top"><span style='white-space: nowrap'>Scalar</span></a>
 below). 

<br/>
<br/>
<b><a name="Fun.x" id="Fun.x">x</a></b>
<br/>
In all three cases,
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'>Vector</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>
and has size 
<code><i><font color="black"><span style='white-space: nowrap'>n</span></font></i></code>

(see description of <a href="rosen34.xml#Vector" target="_top"><span style='white-space: nowrap'>Vector</span></a>
 below). 

<br/>
<br/>
<b><a name="Fun.f" id="Fun.f">f</a></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
 to 
<code><i><font color="black"><span style='white-space: nowrap'>F</span></font></i><font color="blue"><span style='white-space: nowrap'>.Ode</span></font></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'>Vector</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</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>
On input and output, 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
 is a vector of size <i>n</i>
and the input values of the elements of 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
 do not matter.
On output,

<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
 is set equal to 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>F</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
</mrow></math>


(see 
<code><i><font color="black"><span style='white-space: nowrap'>F(t,&#xA0;x)</span></font></i></code>
 in <a href="rosen34.xml#Description" target="_top"><span style='white-space: nowrap'>Description</span></a>
). 

<br/>
<br/>
<b><a name="Fun.f_t" id="Fun.f_t">f_t</a></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>f_t</span></font></i></code>
 to 
<code><i><font color="black"><span style='white-space: nowrap'>F</span></font></i><font color="blue"><span style='white-space: nowrap'>.Ode_ind</span></font></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'>Vector</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>f_t</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
On input and output, 
<code><i><font color="black"><span style='white-space: nowrap'>f_t</span></font></i></code>
 is a vector of size <i>n</i>
and the input values of the elements of 
<code><i><font color="black"><span style='white-space: nowrap'>f_t</span></font></i></code>
 do not matter.
On output, the <i>i</i>-th element of

<code><i><font color="black"><span style='white-space: nowrap'>f_t</span></font></i></code>
 is set equal to 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mo stretchy="false">&#x02202;</mo>
<mi mathvariant='italic'>t</mi>
</msub>
<msub><mi mathvariant='italic'>F</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
</mrow></math>

 
(see 
<code><i><font color="black"><span style='white-space: nowrap'>F(t,&#xA0;x)</span></font></i></code>
 in <a href="rosen34.xml#Description" target="_top"><span style='white-space: nowrap'>Description</span></a>
). 

<br/>
<br/>
<b><a name="Fun.f_x" id="Fun.f_x">f_x</a></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>f_x</span></font></i></code>
 to 
<code><i><font color="black"><span style='white-space: nowrap'>F</span></font></i><font color="blue"><span style='white-space: nowrap'>.Ode_dep</span></font></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'>Vector</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>f_x</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
On input and output, 
<code><i><font color="black"><span style='white-space: nowrap'>f_x</span></font></i></code>
 is a vector of size 
<code><i><font color="black"><span style='white-space: nowrap'>n</span></font></i><font color="blue"><span style='white-space: nowrap'>*</span></font><i><font color="black"><span style='white-space: nowrap'>n</span></font></i></code>

and the input values of the elements of 
<code><i><font color="black"><span style='white-space: nowrap'>f_x</span></font></i></code>
 do not matter.
On output, the [
<code><i><font color="black"><span style='white-space: nowrap'>i</span></font></i><font color="blue"><span style='white-space: nowrap'>*</span></font><i><font color="black"><span style='white-space: nowrap'>n</span></font></i><font color="blue"><span style='white-space: nowrap'>+</span></font><i><font color="black"><span style='white-space: nowrap'>j</span></font></i></code>
] element of

<code><i><font color="black"><span style='white-space: nowrap'>f_x</span></font></i></code>
 is set equal to 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mo stretchy="false">&#x02202;</mo>
<mrow><mi mathvariant='italic'>x</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">)</mo>
</mrow>
</msub>
<msub><mi mathvariant='italic'>F</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>x</mi>
<mo stretchy="false">)</mo>
</mrow></math>

 
(see 
<code><i><font color="black"><span style='white-space: nowrap'>F(t,&#xA0;x)</span></font></i></code>
 in <a href="rosen34.xml#Description" target="_top"><span style='white-space: nowrap'>Description</span></a>
). 

<br/>
<br/>
<b><a name="Fun.Nan" id="Fun.Nan">Nan</a></b>
<br/>
If any of the elements of 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
, <i>f_t</i>, or <i>f_x</i>
have the value not a number <code><font color="blue">nan</font></code>,
the routine <code><font color="blue">Rosen34</font></code> returns with all the
elements of 
<code><i><font color="black"><span style='white-space: nowrap'>xf</span></font></i></code>
 and <i>e</i> equal to <code><font color="blue">nan</font></code>.

<br/>
<br/>
<b><a name="Fun.Warning" id="Fun.Warning">Warning</a></b>
<br/>
The arguments 
<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
, <i>f_t</i>, and <i>f_x</i>
must have a call by reference in their prototypes; i.e.,
do not forget the <code><font color="blue">&amp;</font></code> in the prototype for 

<code><i><font color="black"><span style='white-space: nowrap'>f</span></font></i></code>
, <i>f_t</i> and <i>f_x</i>.

<br/>
<br/>
<b><a name="Fun.Optimization" id="Fun.Optimization">Optimization</a></b>
<br/>
Every call of the form 

<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'>F</span></font></i><font color="blue"><span style='white-space: nowrap'>.Ode_ind(</span></font><i><font color="black"><span style='white-space: nowrap'>t</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</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'>f_t</span></font></i><font color="blue"><span style='white-space: nowrap'>)<br/>
</span></font></code>
is directly followed by a call of the form 

<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'>F</span></font></i><font color="blue"><span style='white-space: nowrap'>.Ode_dep(</span></font><i><font color="black"><span style='white-space: nowrap'>t</span></font></i><font color="blue"><span style='white-space: nowrap'>,&#xA0;</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'>f_x</span></font></i><font color="blue"><span style='white-space: nowrap'>)<br/>
</span></font></code>
where the arguments 
<code><i><font color="black"><span style='white-space: nowrap'>t</span></font></i></code>
 and <i>x</i> have not changed between calls.
In many cases it is faster to compute the values of 
<code><i><font color="black"><span style='white-space: nowrap'>f_t</span></font></i></code>

and 
<code><i><font color="black"><span style='white-space: nowrap'>f_x</span></font></i></code>
 together and then pass them back one at a time.

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

<code><font color="blue"><span style='white-space: nowrap'><br/>
&#xA0;&#xA0;&#xA0;&#xA0;&#xA0;size_t&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>M</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
It specifies the number of steps
to use when solving the differential equation.
This must be greater than or equal one.
The step size is given by 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>h</mi>
<mo stretchy="false">=</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>tf</mi>
<mo stretchy="false">-</mo>
<mi mathvariant='italic'>ti</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">/</mo>
<mi mathvariant='italic'>M</mi>
</mrow></math>

, thus
the larger 
<code><i><font color="black"><span style='white-space: nowrap'>M</span></font></i></code>
, the more accurate the
return value 
<code><i><font color="black"><span style='white-space: nowrap'>xf</span></font></i></code>
 is as an approximation
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'>tf</mi>
<mo stretchy="false">)</mo>
</mrow></math>

.

<br/>
<br/>
<b><big><a name="ti" id="ti">ti</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>ti</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'>Scalar</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>ti</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
(see description of <a href="rosen34.xml#Scalar" target="_top"><span style='white-space: nowrap'>Scalar</span></a>
 below). 
It specifies the initial time for 
<code><i><font color="black"><span style='white-space: nowrap'>t</span></font></i></code>
 in the 
differential equation; i.e., 
the time corresponding to the value 
<code><i><font color="black"><span style='white-space: nowrap'>xi</span></font></i></code>
.

<br/>
<br/>
<b><big><a name="tf" id="tf">tf</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>tf</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'>Scalar</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>tf</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
It specifies the final time for 
<code><i><font color="black"><span style='white-space: nowrap'>t</span></font></i></code>
 in the 
differential equation; i.e., 
the time corresponding to the value 
<code><i><font color="black"><span style='white-space: nowrap'>xf</span></font></i></code>
.

<br/>
<br/>
<b><big><a name="xi" id="xi">xi</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>xi</span></font></i></code>
 has the 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'>Vector</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>xi</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
and the size of 
<code><i><font color="black"><span style='white-space: nowrap'>xi</span></font></i></code>
 is equal to <i>n</i>.
It specifies the value 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'>ti</mi>
<mo stretchy="false">)</mo>
</mrow></math>



<br/>
<br/>
<b><big><a name="e" id="e">e</a></big></b>
<br/>
The argument 
<code><i><font color="black"><span style='white-space: nowrap'>e</span></font></i></code>
 is optional and has the 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'>Vector</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&amp;</span></font><i><font color="black"><span style='white-space: nowrap'>e</span></font></i><font color="blue"><span style='white-space: nowrap'><br/>
</span></font></code>
If 
<code><i><font color="black"><span style='white-space: nowrap'>e</span></font></i></code>
 is present,
the size of 
<code><i><font color="black"><span style='white-space: nowrap'>e</span></font></i></code>
 must be equal to <i>n</i>.
The input value of the elements of 
<code><i><font color="black"><span style='white-space: nowrap'>e</span></font></i></code>
 does not matter.
On output
it contains an element by element
estimated bound for the absolute value of the error in 
<code><i><font color="black"><span style='white-space: nowrap'>xf</span></font></i></code>


<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mi mathvariant='italic'>e</mi>
<mo stretchy="false">=</mo>
<mi mathvariant='italic'>O</mi>
<mo stretchy="false">(</mo>
<msup><mi mathvariant='italic'>h</mi>
<mn>4</mn>
</msup>
<mo stretchy="false">)</mo>
</mrow></math>

where 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>h</mi>
<mo stretchy="false">=</mo>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>tf</mi>
<mo stretchy="false">-</mo>
<mi mathvariant='italic'>ti</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">/</mo>
<mi mathvariant='italic'>M</mi>
</mrow></math>

 is the step size.

<br/>
<br/>
<b><big><a name="Scalar" id="Scalar">Scalar</a></big></b>
<br/>
The type 
<code><i><font color="black"><span style='white-space: nowrap'>Scalar</span></font></i></code>
 must satisfy the conditions
for a <a href="numerictype.xml" target="_top"><span style='white-space: nowrap'>NumericType</span></a>
 type.
The routine <a href="checknumerictype.xml" target="_top"><span style='white-space: nowrap'>CheckNumericType</span></a>
 will generate an error message
if this is not the case.
In addition, the following operations must be defined for 

<code><i><font color="black"><span style='white-space: nowrap'>Scalar</span></font></i></code>
 objects <i>a</i> and <i>b</i>:

<table><tr><td align='left'  valign='top'>

<b>Operation</b> </td><td align='left'  valign='top'>
 <b>Description</b>  </td></tr><tr><td align='left'  valign='top'>


<code><i><font color="black"><span style='white-space: nowrap'>a</span></font></i><font color="blue"><span style='white-space: nowrap'>&#xA0;&lt;&#xA0;</span></font><i><font color="black"><span style='white-space: nowrap'>b</span></font></i></code>
 </td><td align='left'  valign='top'>

	less than operator (returns a <code><font color="blue">bool</font></code> object)
</td></tr>
</table>
<br/>
<b><big><a name="Vector" id="Vector">Vector</a></big></b>
<br/>
The type 
<code><i><font color="black"><span style='white-space: nowrap'>Vector</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;Scalar</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="Parallel Mode" id="Parallel Mode">Parallel Mode</a></big></b>


<br/>
For each set of types
<a href="rosen34.xml#Scalar" target="_top"><span style='white-space: nowrap'>Scalar</span></a>
, 
<a href="rosen34.xml#Vector" target="_top"><span style='white-space: nowrap'>Vector</span></a>
, and
<a href="rosen34.xml#Fun" target="_top"><span style='white-space: nowrap'>Fun</span></a>
, 
the first call to <code><font color="blue">Rosen34</font></code>
must not be <a href="ta_in_parallel.xml" target="_top"><span style='white-space: nowrap'>parallel</span></a>
 execution mode.

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

<br/>
The file
<a href="rosen34.cpp.xml" target="_top"><span style='white-space: nowrap'>Rosen34.cpp</span></a>

contains an example and test a test of using this routine.
It returns true if it succeeds and false otherwise.

<br/>
<br/>
<b><big><a name="Source Code" id="Source Code">Source Code</a></big></b>
<br/>
The source code for this routine is in the file
<code><font color="blue">cppad/rosen_34.hpp</font></code>.


<hr/>Input File: cppad/rosen_34.hpp

</body>
</html>

