<?xml version='1.0'?>
<html xmlns='http://www.w3.org/1999/xhtml'
      xmlns:math='http://www.w3.org/1998/Math/MathML'
>
<head>
<title>An ODE Inverse Problem Example</title>
<meta name="description" id="description" content="An ODE Inverse Problem Example"/>
<meta name="keywords" id="keywords" content=" ode inverse example "/>
<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='_ipopt_nlp_ode_problem_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="ipopt_nlp_ode.xml" target="_top">Prev</a>
</td><td><a href="ipopt_nlp_ode_problem.hpp.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>Appendix</option>
<option>deprecated</option>
<option>cppad_ipopt_nlp</option>
<option>ipopt_nlp_ode</option>
<option>ipopt_nlp_ode_problem</option>
</select>
</td>
<td>
<select onchange='choose_down3(this)'>
<option>deprecated-&gt;</option>
<option>include_deprecated</option>
<option>FunDeprecated</option>
<option>omp_max_thread</option>
<option>TrackNewDel</option>
<option>omp_alloc</option>
<option>memory_leak</option>
<option>epsilon</option>
<option>test_vector</option>
<option>cppad_ipopt_nlp</option>
<option>old_atomic</option>
</select>
</td>
<td>
<select onchange='choose_down2(this)'>
<option>cppad_ipopt_nlp-&gt;</option>
<option>ipopt_nlp_get_started.cpp</option>
<option>ipopt_nlp_ode</option>
<option>ipopt_ode_speed.cpp</option>
</select>
</td>
<td>
<select onchange='choose_down1(this)'>
<option>ipopt_nlp_ode-&gt;</option>
<option>ipopt_nlp_ode_problem</option>
<option>ipopt_nlp_ode_simple</option>
<option>ipopt_nlp_ode_fast</option>
<option>ipopt_nlp_ode_run.hpp</option>
<option>ipopt_nlp_ode_check.cpp</option>
</select>
</td>
<td>
<select onchange='choose_down0(this)'>
<option>ipopt_nlp_ode_problem-&gt;</option>
<option>ipopt_nlp_ode_problem.hpp</option>
</select>
</td>
<td>
<select onchange='choose_current0(this)'>
<option>Headings-&gt;</option>
<option>Notation</option>
<option>Forward Problem</option>
<option>Measurements</option>
<option>---..Simulation Analytic Solution</option>
<option>---..Simulation Parameter Values</option>
<option>---..Simulated Measurement Values</option>
<option>Inverse Problem</option>
<option>Trapezoidal Approximation</option>
<option>---..Trapezoidal Time Grid</option>
<option>Black Box Method</option>
<option>---..Two levels of Iteration</option>
<option>---..Derivatives</option>
<option>Simultaneous Method</option>
<option>Source</option>
</select>
</td>
</tr></table><br/>
<center><b><big><big>An ODE Inverse Problem Example</big></big></b></center>
<br/>
<b><big><a name="Notation" id="Notation">Notation</a></big></b>
<br/>
The table below contains
the name of a variable,
the meaning of the variable value,
and the value for this particular example.
If the value is not specified in the table below,
the corresponding value in <a href="ipopt_nlp_ode_problem.hpp.xml" target="_top"><span style='white-space: nowrap'>ipopt_nlp_ode_problem.hpp</span></a>

can be changed and the example should still run
(with no other changes).
<table><tr><td align='left'  valign='top'>

<b>Name</b>  </td><td align='left'  valign='top'>
 <b>Meaning</b> </td><td align='left'  valign='top'>
 <b>Value</b>
</td></tr><tr><td align='left'  valign='top'>


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

   </td><td align='left'  valign='top'>
 number of parameters to fit </td><td align='left'  valign='top'>
 3 
</td></tr><tr><td align='left'  valign='top'>


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

   </td><td align='left'  valign='top'>
 number components in ODE    </td><td align='left'  valign='top'>
 2
</td></tr><tr><td align='left'  valign='top'>


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

   </td><td align='left'  valign='top'>
 number of measurements      </td><td align='left'  valign='top'>
 4
</td></tr><tr><td align='left'  valign='top'>


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

 </td><td align='left'  valign='top'>
 
number of grid points between <i>i-1</i>-th and <i>i</i>-th measurement 
</td></tr><tr><td align='left'  valign='top'>


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

 </td><td align='left'  valign='top'>

number of grid points up to an including the <i>i</i>-th measurement
</td></tr>
</table>
<br/>
<b><big><a name="Forward Problem" id="Forward Problem">Forward Problem</a></big></b>
<br/>
We consider the following ordinary differential equation:

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

with the initial conditions

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msub><mi mathvariant='italic'>y</mi>
<mn>0</mn>
</msub>
<mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mi mathvariant='italic'>F</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mrow><mo stretchy="true">(</mo><mrow><mtable rowalign="center" ><mtr><mtd columnalign="center" >
<msub><mi mathvariant='italic'>a</mi>
<mn>0</mn>
</msub>
</mtd></mtr><mtr><mtd columnalign="center" >
<mn>0</mn>
</mtd></mtr></mtable>
</mrow><mo stretchy="true">)</mo></mrow>
</mrow></math>

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

 is the number of parameters,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">&#x02208;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Na</mi>
</mrow>
</msup>
</mrow></math>

 is an unknown parameter vector.
The function and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>F</mi>
<mo stretchy="false">:</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Na</mi>
</mrow>
</msup>
<mo stretchy="false">&#x02192;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Ny</mi>
</mrow>
</msup>
</mrow></math>

 
is defined by the equation above
where 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>Ny</mi>
</mrow></math>

 is the number of components in 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mrow></math>

.
Our forward problem is stated as follows: Given 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">&#x02208;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Na</mi>
</mrow>
</msup>
</mrow></math>


determine the value of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mrow></math>

, for 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">&#x02208;</mo>
<mi mathvariant='italic'>R</mi>
</mrow></math>

, that 
solves the initial value problem above. 

<br/>
<br/>
<b><big><a name="Measurements" id="Measurements">Measurements</a></big></b>
<br/>
We use 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>Nz</mi>
</mrow></math>

 to denote the number of measurements.
Suppose we are also given a measurement vector 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>z</mi>
<mo stretchy="false">&#x02208;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Nz</mi>
</mrow>
</msup>
</mrow></math>


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

, 
we model 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>z</mi>
<mi mathvariant='italic'>i</mi>
</msub>
</mrow></math>

 by

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msub><mi mathvariant='italic'>z</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">=</mo>
<msub><mi mathvariant='italic'>y</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">(</mo>
<msub><mi mathvariant='italic'>s</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">+</mo>
<msub><mi mathvariant='italic'>e</mi>
<mi mathvariant='italic'>i</mi>
</msub>
</mrow></math>

where 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>s</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">&#x02208;</mo>
<mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
</mrow></math>

 is the time for the <i>i</i>-th measurement,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>e</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">&#x0223C;</mo>
<mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>N</mi>
</mstyle></mrow>
<mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<msup><mi mathvariant='normal'>&#x003C3;</mi>
<mn>2</mn>
</msup>
<mo stretchy="false">)</mo>
</mrow></math>

 is the corresponding noise,
and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='normal'>&#x003C3;</mi>
<mo stretchy="false">&#x02208;</mo>
<msub><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mo stretchy="false">+</mo>
</msub>
</mrow></math>

 is the corresponding standard deviation.

<br/>
<br/>
<b><a name="Measurements.Simulation Analytic Solution" id="Measurements.Simulation Analytic Solution">Simulation Analytic Solution</a></b>
<br/>
The following analytic solution to the forward problem is used
to simulate a data set:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<msub><mi mathvariant='italic'>y</mi>
<mn>0</mn>
</msub>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msub><mi mathvariant='italic'>a</mi>
<mn>0</mn>
</msub>
<mo stretchy="false">*</mo>
<mi>exp</mi>
<mo stretchy="false">(</mo>
<mo stretchy="false">-</mo>
<msub><mi mathvariant='italic'>a</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">*</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
</mtd></mtr><mtr><mtd columnalign="right" >
<msub><mi mathvariant='italic'>y</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msub><mi mathvariant='italic'>a</mi>
<mn>0</mn>
</msub>
<mo stretchy="false">*</mo>
<msub><mi mathvariant='italic'>a</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">*</mo>
<mfrac><mrow><mi>exp</mi>
<mo stretchy="false">(</mo>
<mo stretchy="false">-</mo>
<msub><mi mathvariant='italic'>a</mi>
<mn>2</mn>
</msub>
<mo stretchy="false">*</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">-</mo>
<mi>exp</mi>
<mo stretchy="false">(</mo>
<mo stretchy="false">-</mo>
<msub><mi mathvariant='italic'>a</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">*</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">)</mo>
</mrow>
<mrow><msub><mi mathvariant='italic'>a</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">-</mo>
<msub><mi mathvariant='italic'>a</mi>
<mn>2</mn>
</msub>
</mrow>
</mfrac>
</mtd></mtr></mtable>
</mrow></math>

<br/>
<b><a name="Measurements.Simulation Parameter Values" id="Measurements.Simulation Parameter Values">Simulation Parameter Values</a></b>

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


<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mover accent='false'><mrow><mi mathvariant='italic'>a</mi>
</mrow>
<mo stretchy='false'>&#x000AF;</mo></mover>
<mn>0</mn>
</msub>
<mo stretchy="false">=</mo>
<mn>1</mn>
</mrow></math>

 <code><span style='white-space: nowrap'>&#xA0;</span></code> </td><td align='left'  valign='top'>
 
	initial value of 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>y</mi>
<mn>0</mn>
</msub>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>t</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mrow></math>

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


<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mover accent='false'><mrow><mi mathvariant='italic'>a</mi>
</mrow>
<mo stretchy='false'>&#x000AF;</mo></mover>
<mn>1</mn>
</msub>
<mo stretchy="false">=</mo>
<mn>2</mn>
</mrow></math>

 <code><span style='white-space: nowrap'>&#xA0;</span></code> </td><td align='left'  valign='top'>
 
	transfer rate from compartment zero to compartment one
</td></tr><tr><td align='left'  valign='top'>


<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mover accent='false'><mrow><mi mathvariant='italic'>a</mi>
</mrow>
<mo stretchy='false'>&#x000AF;</mo></mover>
<mn>2</mn>
</msub>
<mo stretchy="false">=</mo>
<mn>1</mn>
</mrow></math>

 <code><span style='white-space: nowrap'>&#xA0;</span></code> </td><td align='left'  valign='top'>
 
	transfer rate from compartment one to outside world
</td></tr><tr><td align='left'  valign='top'>


<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='normal'>&#x003C3;</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
</mrow></math>

 <code><span style='white-space: nowrap'>&#xA0;</span></code> </td><td align='left'  valign='top'>
 
	standard deviation of measurement noise
</td></tr><tr><td align='left'  valign='top'>


<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>e</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">=</mo>
<mn>0</mn>
</mrow></math>

 <code><span style='white-space: nowrap'>&#xA0;</span></code> </td><td align='left'  valign='top'>

	simulated measurement noise, 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">=</mo>
<mn>1</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>Nz</mi>
</mrow></math>


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


<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>s</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">=</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">*</mo>
<mn>.5</mn>
</mrow></math>

 <code><span style='white-space: nowrap'>&#xA0;</span></code> </td><td align='left'  valign='top'>
 
	time corresponding to the <i>i</i>-th measurement,
	
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">=</mo>
<mn>1</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>Nz</mi>
</mrow></math>


</td></tr>
</table>
<br/>
<b><a name="Measurements.Simulated Measurement Values" id="Measurements.Simulated Measurement Values">Simulated Measurement Values</a></b>
<br/>
The simulated measurement values are given by the equation

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<msub><mi mathvariant='italic'>z</mi>
<mi mathvariant='italic'>i</mi>
</msub>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msub><mi mathvariant='italic'>e</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">+</mo>
<msub><mi mathvariant='italic'>y</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">(</mo>
<msub><mi mathvariant='italic'>s</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">,</mo>
<mover accent='false'><mrow><mi mathvariant='italic'>a</mi>
</mrow>
<mo stretchy='false'>&#x000AF;</mo></mover>
<mo stretchy="false">)</mo>
</mtd></mtr><mtr><mtd columnalign="right" >
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msub><mi mathvariant='italic'>e</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">+</mo>
<msub><mover accent='false'><mrow><mi mathvariant='italic'>a</mi>
</mrow>
<mo stretchy='false'>&#x000AF;</mo></mover>
<mn>0</mn>
</msub>
<mo stretchy="false">*</mo>
<msub><mover accent='false'><mrow><mi mathvariant='italic'>a</mi>
</mrow>
<mo stretchy='false'>&#x000AF;</mo></mover>
<mn>1</mn>
</msub>
<mo stretchy="false">*</mo>
<mfrac><mrow><mi>exp</mi>
<mo stretchy="false">(</mo>
<mo stretchy="false">-</mo>
<msub><mover accent='false'><mrow><mi mathvariant='italic'>a</mi>
</mrow>
<mo stretchy='false'>&#x000AF;</mo></mover>
<mn>2</mn>
</msub>
<mo stretchy="false">*</mo>
<msub><mi mathvariant='italic'>s</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">)</mo>
<mo stretchy="false">-</mo>
<mi>exp</mi>
<mo stretchy="false">(</mo>
<mo stretchy="false">-</mo>
<msub><mover accent='false'><mrow><mi mathvariant='italic'>a</mi>
</mrow>
<mo stretchy='false'>&#x000AF;</mo></mover>
<mn>1</mn>
</msub>
<mo stretchy="false">*</mo>
<msub><mi mathvariant='italic'>s</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">)</mo>
</mrow>
<mrow><msub><mover accent='false'><mrow><mi mathvariant='italic'>a</mi>
</mrow>
<mo stretchy='false'>&#x000AF;</mo></mover>
<mn>1</mn>
</msub>
<mo stretchy="false">-</mo>
<msub><mover accent='false'><mrow><mi mathvariant='italic'>a</mi>
</mrow>
<mo stretchy='false'>&#x000AF;</mo></mover>
<mn>2</mn>
</msub>
</mrow>
</mfrac>
</mtd></mtr></mtable>
</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>1</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>Nz</mi>
</mrow></math>

.


<br/>
<br/>
<b><big><a name="Inverse Problem" id="Inverse Problem">Inverse Problem</a></big></b>
<br/>
The maximum likelihood estimate for 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>a</mi>
</mrow></math>

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


solves the following inverse problem

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>minimize</mi>
</mstyle></mrow>
<mspace width='.3em'/>
</mtd><mtd columnalign="center" >
<munderover><mo displaystyle='true' largeop='true'>&#x02211;</mo>
<mrow><mi mathvariant='italic'>i</mi>
<mo stretchy="false">=</mo>
<mn>1</mn>
</mrow>
<mrow><mi mathvariant='italic'>Nz</mi>
</mrow>
</munderover>
<msub><mi mathvariant='italic'>H</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">[</mo>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">(</mo>
<msub><mi mathvariant='italic'>s</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">]</mo>
</mtd><mtd columnalign="left" >
<mspace width='.3em'/>
<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>w</mi>
<mo stretchy="false">.</mo>
<mi mathvariant='normal'>r</mi>
<mo stretchy="false">.</mo>
<mi mathvariant='normal'>t</mi>
</mstyle></mrow>
<mspace width='.3em'/>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">&#x02208;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Na</mi>
</mrow>
</msup>
</mtd></mtr></mtable>
</mrow></math>

where the functions

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>H</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">:</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Ny</mi>
</mrow>
</msup>
<mo stretchy="false">&#x000D7;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Na</mi>
</mrow>
</msup>
<mo stretchy="false">&#x02192;</mo>
<mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
</mrow></math>

 is
defined by

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msub><mi mathvariant='italic'>H</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mo stretchy="false">(</mo>
<msub><mi mathvariant='italic'>z</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">-</mo>
<msub><mi mathvariant='italic'>y</mi>
<mn>1</mn>
</msub>
<msup><mo stretchy="false">)</mo>
<mn>2</mn>
</msup>
</mrow></math>

<br/>
<b><big><a name="Trapezoidal Approximation" id="Trapezoidal Approximation">Trapezoidal Approximation</a></big></b>
<br/>
This example uses a trapezoidal approximation to solve the ODE.
This approximation procedures starts with

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msup><mi mathvariant='italic'>y</mi>
<mn>0</mn>
</msup>
<mo stretchy="false">=</mo>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">(</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mrow><mo stretchy="true">(</mo><mrow><mtable rowalign="center" ><mtr><mtd columnalign="center" >
<msub><mi mathvariant='italic'>a</mi>
<mn>0</mn>
</msub>
</mtd></mtr><mtr><mtd columnalign="center" >
<mn>0</mn>
</mtd></mtr></mtable>
</mrow><mo stretchy="true">)</mo></mrow>
</mrow></math>

Given a time grid 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">{</mo>
<msub><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">}</mo>
</mrow></math>

 and
an approximate value 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msup><mi mathvariant='italic'>y</mi>
<mrow><mi mathvariant='italic'>i</mi>
<mn>-1</mn>
</mrow>
</msup>
</mrow></math>

 for 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">(</mo>
<msub><mi mathvariant='italic'>t</mi>
<mrow><mi mathvariant='italic'>i</mi>
<mn>-1</mn>
</mrow>
</msub>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mrow></math>

,
the a trapezoidal method approximates 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">(</mo>
<msub><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mrow></math>


(denoted by 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
</msup>
</mrow></math>

 ) by solving the equation

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<msup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
</msup>
<mo stretchy="false">=</mo>
<msup><mi mathvariant='italic'>y</mi>
<mrow><mi mathvariant='italic'>i</mi>
<mn>-1</mn>
</mrow>
</msup>
<mo stretchy="false">+</mo>
<mrow><mo stretchy="true">[</mo><mrow><mi mathvariant='italic'>G</mi>
<mo stretchy="false">(</mo>
<msup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
</msup>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>G</mi>
<mo stretchy="false">(</mo>
<msup><mi mathvariant='italic'>y</mi>
<mrow><mi mathvariant='italic'>i</mi>
<mn>-1</mn>
</mrow>
</msup>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mrow><mo stretchy="true">]</mo></mrow>
<mo stretchy="false">*</mo>
<mfrac><mrow><msub><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">-</mo>
<msub><mi mathvariant='italic'>t</mi>
<mrow><mi mathvariant='italic'>i</mi>
<mn>-1</mn>
</mrow>
</msub>
</mrow>
<mrow><mn>2</mn>
</mrow>
</mfrac>
</mrow></math>

where 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>G</mi>
<mo stretchy="false">:</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Ny</mi>
</mrow>
</msup>
<mo stretchy="false">&#x000D7;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Na</mi>
</mrow>
</msup>
<mo stretchy="false">&#x02192;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Ny</mi>
</mrow>
</msup>
</mrow></math>

 is the
function representing this ODE; i.e.

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mi mathvariant='italic'>G</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mrow><mo stretchy="true">(</mo><mrow><mtable rowalign="center" ><mtr><mtd columnalign="center" >
<mo stretchy="false">-</mo>
<msub><mi mathvariant='italic'>a</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">*</mo>
<msub><mi mathvariant='italic'>y</mi>
<mn>0</mn>
</msub>
</mtd></mtr><mtr><mtd columnalign="center" >
<mo stretchy="false">+</mo>
<msub><mi mathvariant='italic'>a</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">*</mo>
<msub><mi mathvariant='italic'>y</mi>
<mn>0</mn>
</msub>
<mo stretchy="false">-</mo>
<msub><mi mathvariant='italic'>a</mi>
<mn>2</mn>
</msub>
<mo stretchy="false">*</mo>
<msub><mi mathvariant='italic'>y</mi>
<mn>1</mn>
</msub>
</mtd></mtr></mtable>
</mrow><mo stretchy="true">)</mo></mrow>
</mrow></math>

This 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>G</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mrow></math>

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

, hence
the implicit equation defining 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
</msup>
</mrow></math>

 can be solved
inverting the a set of linear equations.
In the general case, 
where 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>G</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mrow></math>

 is non-linear with respect to 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>y</mi>
</mrow></math>

,
an iterative procedure is used to calculate 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
</msup>
</mrow></math>


from 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msup><mi mathvariant='italic'>y</mi>
<mrow><mi mathvariant='italic'>i</mi>
<mn>-1</mn>
</mrow>
</msup>
</mrow></math>

.

<br/>
<br/>
<b><a name="Trapezoidal Approximation.Trapezoidal Time Grid" id="Trapezoidal Approximation.Trapezoidal Time Grid">Trapezoidal Time Grid</a></b>
<br/>
The discrete time grid, used for the trapezoidal approximation, is 
denoted by 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">{</mo>
<msub><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">}</mo>
</mrow></math>

 which is defined by:

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>t</mi>
<mn>0</mn>
</msub>
<mo stretchy="false">=</mo>
<mn>0</mn>
</mrow></math>

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

 and for 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">=</mo>
<mn>1</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>N</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">)</mo>
</mrow></math>

, 

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<mi mathvariant='normal'>&#x00394;</mi>
<msub><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>i</mi>
</msub>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<mo stretchy="false">(</mo>
<msub><mi mathvariant='italic'>s</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">-</mo>
<msub><mi mathvariant='italic'>s</mi>
<mrow><mi mathvariant='italic'>i</mi>
<mn>-1</mn>
</mrow>
</msub>
<mo stretchy="false">)</mo>
<mo stretchy="false">/</mo>
<mi mathvariant='italic'>N</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">)</mo>
</mtd></mtr><mtr><mtd columnalign="right" >
<msub><mi mathvariant='italic'>t</mi>
<mrow><mi mathvariant='italic'>S</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>i</mi>
<mn>-1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>j</mi>
</mrow>
</msub>
</mtd><mtd columnalign="center" >
<mo stretchy="false">=</mo>
</mtd><mtd columnalign="left" >
<msub><mi mathvariant='italic'>s</mi>
<mrow><mi mathvariant='italic'>i</mi>
<mn>-1</mn>
</mrow>
</msub>
<mo stretchy="false">+</mo>
<mi mathvariant='normal'>&#x00394;</mi>
<msub><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">*</mo>
<mi mathvariant='italic'>j</mi>
</mtd></mtr></mtable>
</mrow></math>

where 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>s</mi>
<mn>0</mn>
</msub>
<mo stretchy="false">=</mo>
<mn>0</mn>
</mrow></math>

,

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

 is the number of time grid points between

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

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

,

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

, and

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>S</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mi mathvariant='italic'>N</mi>
<mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">+</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>N</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">)</mo>
</mrow></math>

.
Note that for 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">=</mo>
<mn>0</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>S</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>Nz</mi>
<mo stretchy="false">)</mo>
</mrow></math>

,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>i</mi>
</msup>
</mrow></math>

 denotes our approximation for 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>y</mi>
<mo stretchy="false">(</mo>
<msub><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mrow></math>


and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>t</mi>
<mrow><mi mathvariant='italic'>S</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">)</mo>
</mrow>
</msub>
</mrow></math>

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

.

<br/>
<br/>
<b><big><a name="Black Box Method" id="Black Box Method">Black Box Method</a></big></b>
<br/>
A common approach to an inverse problem is to treat the forward problem
as a black box (that we do not look inside of or try to understand).
In this approach, for each value of the parameter vector 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>a</mi>
</mrow></math>


one uses the
<a href="ipopt_nlp_ode_problem.xml#Trapezoidal Approximation" target="_top"><span style='white-space: nowrap'>trapezoidal&#xA0;approximation</span></a>

(on a finer grid that 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mo stretchy="false">{</mo>
<msub><mi mathvariant='italic'>s</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">}</mo>
</mrow></math>

)
to solve for 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>y</mi>
<mn>1</mn>
</msub>
<mo stretchy="false">(</mo>
<msub><mi mathvariant='italic'>s</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mrow></math>

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

.

<br/>
<br/>
<b><a name="Black Box Method.Two levels of Iteration" id="Black Box Method.Two levels of Iteration">Two levels of Iteration</a></b>
<br/>
As noted above, the trapezoidal approximation
often requires an iterative procedure.
Thus, in this approach, there are two levels of iterations,
one with respect to the parameter values during the minimization
and the other for solving the trapezoidal approximation equation.

<br/>
<br/>
<b><a name="Black Box Method.Derivatives" id="Black Box Method.Derivatives">Derivatives</a></b>
<br/>
In addition, in the black box approach, differentiating the ODE solution
often involves differentiating an iterative procedure.
Direct application of AD to compute these derivatives 
requires a huge amount of memory and calculations to differentiate the 
iterative procedure.
(There are special techniques for applying AD to the solutions of iterative
procedures, but that is outside the scope of this presentation).

<br/>
<br/>
<b><big><a name="Simultaneous Method" id="Simultaneous Method">Simultaneous Method</a></big></b>
<br/>
The simultaneous forward and inverse method 
uses constraints to include the solution of 
the forward problem in the inverse problem.
To be specific for our example,

<math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><mrow>
<mtable rowalign="center" ><mtr><mtd columnalign="right" >
<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>minimize</mi>
</mstyle></mrow>
</mtd><mtd columnalign="center" >
<munderover><mo displaystyle='true' largeop='true'>&#x02211;</mo>
<mrow><mi mathvariant='italic'>i</mi>
<mo stretchy="false">=</mo>
<mn>1</mn>
</mrow>
<mrow><mi mathvariant='italic'>Nz</mi>
</mrow>
</munderover>
<msub><mi mathvariant='italic'>H</mi>
<mi mathvariant='italic'>i</mi>
</msub>
<mo stretchy="false">(</mo>
<msup><mi mathvariant='italic'>y</mi>
<mrow><mi mathvariant='italic'>N</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">)</mo>
</mrow>
</msup>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mtd><mtd columnalign="left" >
<mspace width='.3em'/>
<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>w</mi>
<mo stretchy="false">.</mo>
<mi mathvariant='normal'>r</mi>
<mo stretchy="false">.</mo>
<mi mathvariant='normal'>t</mi>
</mstyle></mrow>
<mspace width='.3em'/>
<msup><mi mathvariant='italic'>y</mi>
<mn>1</mn>
</msup>
<mo stretchy="false">&#x02208;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Ny</mi>
</mrow>
</msup>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<msup><mi mathvariant='italic'>y</mi>
<mrow><mi mathvariant='italic'>S</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>Nz</mi>
<mo stretchy="false">)</mo>
</mrow>
</msup>
<mo stretchy="false">&#x02208;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Ny</mi>
</mrow>
</msup>
<mo stretchy="false">,</mo>
<mspace width='.3em'/>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">&#x02208;</mo>
<msup><mrow><mstyle mathvariant='bold'><mi mathvariant='bold'>R</mi>
</mstyle></mrow>
<mrow><mi mathvariant='italic'>Na</mi>
</mrow>
</msup>
</mtd></mtr><mtr><mtd columnalign="right" >
<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>subject</mi>
<mspace width='.3em'/>
<mi mathvariant='normal'>to</mi>
</mstyle></mrow>
</mtd><mtd columnalign="center" >
<msup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>j</mi>
</msup>
<mo stretchy="false">=</mo>
<msup><mi mathvariant='italic'>y</mi>
<mrow><mi mathvariant='italic'>j</mi>
<mn>-1</mn>
</mrow>
</msup>
<mo stretchy="false">+</mo>
<mrow><mo stretchy="true">[</mo><mrow><mi mathvariant='italic'>G</mi>
<mo stretchy="false">(</mo>
<msup><mi mathvariant='italic'>y</mi>
<mrow><mi mathvariant='italic'>j</mi>
<mn>-1</mn>
</mrow>
</msup>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>G</mi>
<mo stretchy="false">(</mo>
<msup><mi mathvariant='italic'>y</mi>
<mi mathvariant='italic'>j</mi>
</msup>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mrow><mo stretchy="true">]</mo></mrow>
<mo stretchy="false">*</mo>
<mfrac><mrow><msub><mi mathvariant='italic'>t</mi>
<mi mathvariant='italic'>j</mi>
</msub>
<mo stretchy="false">-</mo>
<msub><mi mathvariant='italic'>t</mi>
<mrow><mi mathvariant='italic'>j</mi>
<mn>-1</mn>
</mrow>
</msub>
</mrow>
<mrow><mn>2</mn>
</mrow>
</mfrac>
</mtd><mtd columnalign="left" >
<mspace width='.3em'/>
<mrow><mstyle mathvariant='normal'><mi mathvariant='normal'>for</mi>
</mstyle></mrow>
<mspace width='.3em'/>
<mi mathvariant='italic'>j</mi>
<mo stretchy="false">=</mo>
<mn>1</mn>
<mo stretchy="false">,</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">,</mo>
<mi mathvariant='italic'>S</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>Nz</mi>
<mo stretchy="false">)</mo>
</mtd></mtr><mtr><mtd columnalign="right" >
</mtd><mtd columnalign="center" >
<msup><mi mathvariant='italic'>y</mi>
<mn>0</mn>
</msup>
<mo stretchy="false">=</mo>
<mi mathvariant='italic'>F</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>a</mi>
<mo stretchy="false">)</mo>
</mtd></mtr></mtable>
</mrow></math>

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

,

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

 is the number of time intervals between

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

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

 (with 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<msub><mi mathvariant='italic'>s</mi>
<mn>0</mn>
</msub>
<mo stretchy="false">=</mo>
<mn>0</mn>
</mrow></math>

)
and 
<math xmlns="http://www.w3.org/1998/Math/MathML" display="inline"><mrow>
<mi mathvariant='italic'>S</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">)</mo>
<mo stretchy="false">=</mo>
<mi mathvariant='italic'>N</mi>
<mo stretchy="false">(</mo>
<mn>1</mn>
<mo stretchy="false">)</mo>
<mo stretchy="false">+</mo>
<mo stretchy="false">&#x02026;</mo>
<mo stretchy="false">+</mo>
<mi mathvariant='italic'>N</mi>
<mo stretchy="false">(</mo>
<mi mathvariant='italic'>i</mi>
<mo stretchy="false">)</mo>
</mrow></math>

.
Note that, in this form, the iterations of the optimization procedure
also solve the forward problem equations.
In addition, the functions that need to be differentiated
do not involve an iterative procedure.


<br/>
<br/>
<b><big><a name="Source" id="Source">Source</a></big></b>
<br/>
The file <a href="ipopt_nlp_ode_problem.hpp.xml" target="_top"><span style='white-space: nowrap'>ipopt_nlp_ode_problem.hpp</span></a>
 contains 
source code that defines the example values and functions defined above.


<hr/>Input File: cppad_ipopt/example/ode2.omh

</body>
</html>
