<?xml-stylesheet type="text/xsl" href="../styles/pmathml.xsl"?>
<!-- saved from url=(0014)about:internet -->
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:dsi="http://www.w3.org/1999/xlink" xmlns:m="http://www.w3.org/1998/Math/MathML" xml:space="preserve"><head><meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"/><title>D02AGF : NAG Library, Mark 22</title><link rel="stylesheet" href="../styles/libdoc.css" type="text/css"/><script type="text/javascript">
   function showLevel(_levelId){
    var thisLevel = document.getElementById(_levelId);
    var thisplus = document.getElementById( _levelId.concat('plus'));
    var thisminus = document.getElementById( _levelId.concat('minus'));
    if(thisLevel.style.display != "block"){
     thisLevel.style.display = "block";
     thisplus.style.display = "none";
     thisminus.style.display = "inline";
     }
    else{
     thisLevel.style.display = "none";
     thisminus.style.display = "none";
     thisplus.style.display = "inline";
     }
    }
  </script></head><body><hr/><div><a class="rout" href="../../pdf/D02/d02agf.pdf">D02AGF (PDF version)</a></div><div><a class="chap" href="d02conts.xml">D02 Chapter Contents</a></div><div><a class="chapint" href="d02intro.xml">D02 Chapter Introduction</a></div>
<div><a class="htmltoc" href="../FRONTMATTER/manconts.xml">NAG Library Manual</a></div><hr/><h1 class="libdoc">NAG Library Routine Document<br/><br/>D02AGF</h1><div class="paramtext"><div class="header"><b>Note:</b>&#160; before using this routine, please read the Users' Note for your implementation to check the interpretation of <span class="bitalic">bold italicised</span> terms and other implementation-dependent details.</div></div> 
<div class="htmltoc">
<h2 class="htmltoc"><span class="htmltochead" onclick="showLevel('htmltoc');"><span class="htmltocplus" id="htmltocplus">+</span><span class="htmltocminus" id="htmltocminus">&#8722;</span></span>&#160;Contents</h2>
<div class="htmltocitem" id="htmltoc">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#purpose">1&#160;&#160;<b>Purpose</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#specification">2&#160;&#160;<b>Specification</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#description">3&#160;&#160;<b>Description</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#references">4&#160;&#160;<b>References</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#parameters">5&#160;&#160;<b>Parameters</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#errors">6&#160;&#160;<b>Error Indicators and Warnings</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#accuracy">7&#160;&#160;<b>Accuracy</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments">8&#160;&#160;<b>Further Comments</b></a>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('tocexample');"><span class="htmltocplus" id="tocexampleplus">+</span><span class="htmltocminus" id="tocexampleminus">&#8722;</span></span>
<a class="htmltoc" href="#example">9&#160;&#160;<b>Example</b></a>
<div class="htmltocitem" id="tocexample">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examtext">9.1&#160;&#160;<b>Program Text</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examdata">9.2&#160;&#160;<b>Program Data</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examresults">9.3&#160;&#160;<b>Program Results</b></a>
</div>
</div>
</div>
</div>
</div><h2 class="standard"><a class="sec" name="purpose" id="purpose"/>1&#160;&#160;Purpose</h2>
<div class="paramtext">D02AGF solves a two-point boundary value problem for a system of ordinary differential equations, using initial value techniques and Newton iteration; it generalizes <a class="rout" href="../D02/d02haf.xml">D02HAF</a> to include the case where parameters other than boundary values are to be determined.</div><h2 class="standard"><a class="sec" name="specification" id="specification"/>2&#160;&#160;Specification</h2>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;D02AGF&#160;(</td><td class="tdfspec2"><a class="arg" href="#H">H</a>, <a class="arg" href="#E">E</a>, <a class="arg" href="#PARERR">PARERR</a>, <a class="arg" href="#PARAM">PARAM</a>, <a class="arg" href="#C">C</a>, <a class="arg" href="#N">N</a>, <a class="arg" href="#N1">N1</a>, <a class="arg" href="#M1">M1</a>, <a class="arg" href="#AUX">AUX</a>, <a class="arg" href="#BCAUX">BCAUX</a>, <a class="arg" href="#RAAUX">RAAUX</a>, <a class="arg" href="#PRSOL">PRSOL</a>, <a class="arg" href="#MAT">MAT</a>, <a class="arg" href="#COPY">COPY</a>, <a class="arg" href="#WSPACE">WSPACE</a>, <a class="arg" href="#WSPAC1">WSPAC1</a>, <a class="arg" href="#WSPAC2">WSPAC2</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N, N1, M1, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">H, E(N), PARERR(N1), PARAM(N1), C(M1,N), MAT(N1,N1), COPY(1,1), WSPACE(N,9), WSPAC1(N), WSPAC2(N)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">AUX, BCAUX, RAAUX, PRSOL</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D02AGF solves a two-point boundary value problem by determining the unknown parameters <m:math><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>p</m:mi><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:msub></m:math>&#160;of the problem.  These parameters may be, but need not be, boundary values (as they are in <a class="rout" href="../D02/d02haf.xml">D02HAF</a>); they may include eigenvalue parameters in the coefficients of the differential equations, length of the range of integration, etc. The notation and methods used are similar to those of <a class="rout" href="../D02/d02haf.xml">D02HAF</a> and you are advised to study this first.  (There the parameters <m:math><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>p</m:mi><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:msub></m:math>&#160;correspond to the unknown boundary conditions.)  It is assumed that we have a system of <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;first-order ordinary differential equations of the form

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mfrac><m:mrow><m:mi>d</m:mi><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow>
 </m:mfrac><m:mo>=</m:mo><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mi mathvariant="italic">n</m:mi></m:msub></m:mfenced><m:mtext>, &#8195;</m:mtext><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi mathvariant="italic">n</m:mi><m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

and that derivatives <m:math><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;are evaluated by <a class="arg" href="#AUX">AUX</a>.  The system, including the boundary conditions given by <a class="arg" href="#BCAUX">BCAUX</a>, and the range of integration and matching point, <m:math><m:mi>r</m:mi></m:math>, given by <a class="arg" href="#RAAUX">RAAUX</a>, involves the <m:math><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;unknown parameters <m:math><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>p</m:mi><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:msub></m:math>&#160;which are to be determined, and for which initial estimates must be supplied.  The number of unknown parameters <m:math><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;must not exceed the number of equations <m:math><m:mi mathvariant="italic">n</m:mi></m:math>.  If <m:math><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub><m:mo>&lt;</m:mo><m:mi mathvariant="italic">n</m:mi></m:math>, we assume that <m:math><m:mfenced separators=""><m:mi mathvariant="italic">n</m:mi><m:mo>-</m:mo><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:mfenced></m:math>&#160;equations of the system are not involved in the matching process.  These are usually referred to as &#8216;driving equations&#8217;; they are independent of the parameters and of the solutions of the other <m:math><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;equations.  In numbering the equations for <a class="arg" href="#AUX">AUX</a>, the driving equations must be put last.</div><div class="paramtext">The estimated values of the parameters are corrected by a form of Newton iteration.  The Newton correction on each iteration is calculated using a matrix whose <m:math><m:mfenced separators=""><m:mi>i</m:mi><m:mo>,</m:mo><m:mi>j</m:mi></m:mfenced></m:math>th element depends on the derivative of the <m:math><m:mi>i</m:mi></m:math>th component of the solution, <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>, with respect to the <m:math><m:mi>j</m:mi></m:math>th parameter, <m:math><m:msub><m:mi>p</m:mi><m:mi>j</m:mi></m:msub></m:math>.  This matrix is calculated by a simple numerical differentiation technique which requires <m:math><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;evaluations of the differential system.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2>
<div class="paramtext">None.</div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<div class="paramtext">You are strongly recommended to read <a class="sec" href="#description">Sections 3</a> and <a class="sec" href="#fcomments">8</a> in conjunction with this section.</div><dl><dt class="paramhead"><a name="H" id="H"/>1: &#160;&#160;&#8194; H &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <a class="arg" href="#H">H</a> must be set to an estimate of the step size, <m:math><m:mi>h</m:mi></m:math>,  needed for integration.</div>
<div class="paramtext"><i>On exit</i>: the last step length used.</div></dd><dt class="paramhead"><a name="E" id="E"/>2: &#160;&#160;&#8194; E(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#E"><m:mi mathcolor="#EE0000" mathvariant="bold">E</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;must be set to a small quantity to control the <m:math><m:mi>i</m:mi></m:math>th solution component. The element <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#E"><m:mi mathcolor="#EE0000" mathvariant="bold">E</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;is used: <table class="standard-90"><tr>
<td style="width:2.1em;" valign="baseline">(i)</td>
<td valign="top">in the bound on the local error in the <m:math><m:mi>i</m:mi></m:math>th component of the solution <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;during integration,</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(ii)</td>
<td valign="top">in the convergence test on the <m:math><m:mi>i</m:mi></m:math>th component of the solution <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;at the matching point in the Newton iteration.</td>
</tr></table>
<div class="paramtext">The elements <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#E"><m:mi mathcolor="#EE0000" mathvariant="bold">E</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;should not be chosen too small. They should usually be several orders of magnitude larger than <span class="bitalic">machine precision</span>.</div>
</div></dd><dt class="paramhead"><a name="PARERR" id="PARERR"/>3: &#160;&#160;&#8194; PARERR(<a class="arg" href="#N1">N1</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARERR"><m:mi mathcolor="#EE0000" mathvariant="bold">PARERR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;must be set to a small quantity to control the <m:math><m:mi>i</m:mi></m:math>th parameter component. The element <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARERR"><m:mi mathcolor="#EE0000" mathvariant="bold">PARERR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;is used: <table class="standard-90"><tr>
<td style="width:2.1em;" valign="baseline">(i)</td>
<td valign="top">in the convergence test on the <m:math><m:mi>i</m:mi></m:math>th parameter in the Newton iteration,</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(ii)</td>
<td valign="top">in perturbing the <m:math><m:mi>i</m:mi></m:math>th parameter when approximating the derivatives of the components of the solution with respect to the <m:math><m:mi>i</m:mi></m:math>th parameter, for use in the Newton iteration.</td>
</tr></table>
<div class="paramtext">The elements <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARERR"><m:mi mathcolor="#EE0000" mathvariant="bold">PARERR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;should not be chosen too small. They should usually be several orders of magnitude larger than <span class="bitalic">machine precision</span>.</div>
</div></dd><dt class="paramhead"><a name="PARAM" id="PARAM"/>4: &#160;&#160;&#8194; PARAM(<a class="arg" href="#N1">N1</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARAM"><m:mi mathcolor="#EE0000" mathvariant="bold">PARAM</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;must be set to an estimate for the <m:math><m:mi>i</m:mi></m:math>th parameter, <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N1"><m:mi mathcolor="#EE0000" mathvariant="bold">N1</m:mi></m:maction></m:math>.</div>
<div class="paramtext"><i>On exit</i>: the corrected value for the <m:math><m:mi>i</m:mi></m:math>th parameter, unless an error has occurred, when it contains the last calculated value of the parameter (possibly perturbed by <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARERR"><m:mi mathcolor="#EE0000" mathvariant="bold">PARERR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>&#215;</m:mo><m:mfenced separators=""><m:mn>1</m:mn><m:mo>+</m:mo><m:mfenced open="|" close="|" separators=""><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARAM"><m:mi mathcolor="#EE0000" mathvariant="bold">PARAM</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:mfenced></m:mfenced></m:math>&#160;if the error occurred when calculating the approximate derivatives).</div></dd><dt class="paramhead"><a name="C" id="C"/>5: &#160;&#160;&#8194; C(<a class="arg" href="#M1">M1</a>,<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the solution when <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#M1"><m:mi mathcolor="#EE0000" mathvariant="bold">M1</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>1</m:mn></m:math>&#160;(see <a class="arg" href="#M1">M1</a>).
<div class="paramtext">If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#M1"><m:mi mathcolor="#EE0000" mathvariant="bold">M1</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math>, the elements of <a class="arg" href="#C">C</a> are not used.</div>
</div></dd><dt class="paramhead"><a name="N" id="N"/>6: &#160;&#160;&#8194; N &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 



<m:math><m:mi mathvariant="italic">n</m:mi></m:math>, the total number of differential equations.
</div></dd><dt class="paramhead"><a name="N1" id="N1"/>7: &#160;&#160;&#8194; N1 &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 



<m:math><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:math>, the number of parameters.
<div class="paramtext">If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N1"><m:mi mathcolor="#EE0000" mathvariant="bold">N1</m:mi></m:maction><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>, the last <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>-</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N1"><m:mi mathcolor="#EE0000" mathvariant="bold">N1</m:mi></m:maction></m:math>&#160;differential equations (in <a class="arg" href="#AUX">AUX</a>) are driving equations (see <a class="sec" href="#description">Section 3</a>).</div>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N1"><m:mi mathcolor="#EE0000" mathvariant="bold">N1</m:mi></m:maction><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="M1" id="M1"/>8: &#160;&#160;&#8194; M1 &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 

determines whether or not the final solution is computed as well as the parameter values. 
<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#M1"><m:mi mathcolor="#EE0000" mathvariant="bold">M1</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>The final solution is not calculated;</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#M1"><m:mi mathcolor="#EE0000" mathvariant="bold">M1</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>The final values of the solution at interval (length of range)/<m:math><m:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#M1"><m:mi mathcolor="#EE0000" mathvariant="bold">M1</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced></m:math>&#160;are calculated and stored sequentially in the array <a class="arg" href="#C">C</a> starting with the values of <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;evaluated at the first end point (see <a class="arg" href="#RAAUX">RAAUX</a>) stored in <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#C"><m:mi mathcolor="#EE0000" mathvariant="bold">C</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>.</dd></dl>
</div></dd><dt class="paramhead"><a name="AUX" id="AUX"/>9: &#160;&#160;&#8194; AUX &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#AUX">AUX</a> must evaluate the functions <m:math><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;(i.e., the derivatives <m:math><m:msubsup><m:mi>y</m:mi><m:mi>i</m:mi><m:mo>&#8242;</m:mo></m:msubsup></m:math>) for given values of its arguments, <m:math><m:mi>x</m:mi><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mi mathvariant="italic">n</m:mi></m:msub></m:math>, <m:math><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>p</m:mi><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:msub><m:mtext>.</m:mtext></m:math></div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#AUX">AUX</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;AUX&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02agf.xml#AUX_F">F</a>, <a class="arg" href="../D02/d02agf.xml#AUX_Y">Y</a>, <a class="arg" href="../D02/d02agf.xml#AUX_X">X</a>, <a class="arg" href="../D02/d02agf.xml#AUX_PARAM">PARAM</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">F(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>), Y(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>), X, PARAM(<m:math><m:mi mathvariant="italic">n1</m:mi></m:math>)</td></tr></table>
<div class="paramtext">where <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;and <m:math><m:mi mathvariant="italic">n1</m:mi></m:math>&#160;are the numerical values of <a class="arg" href="#N">N</a> and <a class="arg" href="#N1">N1</a> in the call of D02AGF.</div>
<dl><dt class="paramhead"><a name="AUX_F" id="AUX_F"/>1: &#160;&#160;&#8194; F(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: the value of <m:math><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi mathvariant="italic">n</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="AUX_Y" id="AUX_Y"/>2: &#160;&#160;&#8194; Y(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>, the value of the argument, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi mathvariant="italic">n</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="AUX_X" id="AUX_X"/>3: &#160;&#160;&#8194; X &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mi>x</m:mi></m:math>, the value of the argument.</div></dd><dt class="paramhead"><a name="AUX_PARAM" id="AUX_PARAM"/>4: &#160;&#160;&#8194; PARAM(<m:math><m:mi mathvariant="italic">n1</m:mi></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>, the value of the argument, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:math>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#AUX">AUX</a> must be declared as EXTERNAL in the (sub)program from which D02AGF is called. Parameters denoted as <span class="italic">Input</span>  must <b>not</b>  be changed by this procedure.</div></dd><dt class="paramhead"><a name="BCAUX" id="BCAUX"/>10: &#8194; BCAUX &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#BCAUX">BCAUX</a> must evaluate the values of <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;at the end points of the range given the values of <m:math><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>p</m:mi><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:msub></m:math>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#BCAUX">BCAUX</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;BCAUX&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02agf.xml#BCAUX_G0">G0</a>, <a class="arg" href="../D02/d02agf.xml#BCAUX_G1">G1</a>, <a class="arg" href="../D02/d02agf.xml#BCAUX_PARAM">PARAM</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">G0(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>), G1(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>), PARAM(<m:math><m:mi mathvariant="italic">n1</m:mi></m:math>)</td></tr></table>
<div class="paramtext">where <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;and <m:math><m:mi mathvariant="italic">n1</m:mi></m:math>&#160;are the numerical values of <a class="arg" href="#N">N</a> and <a class="arg" href="#N1">N1</a> in the call of D02AGF.</div>
<dl><dt class="paramhead"><a name="BCAUX_G0" id="BCAUX_G0"/>1: &#160;&#160;&#8194; G0(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the values <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi mathvariant="italic">n</m:mi></m:math>, at the boundary point <m:math><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;(see <a class="arg" href="#RAAUX">RAAUX</a>).</div></dd><dt class="paramhead"><a name="BCAUX_G1" id="BCAUX_G1"/>2: &#160;&#160;&#8194; G1(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the values <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi mathvariant="italic">n</m:mi></m:math>, at the boundary point <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;(see <a class="arg" href="#RAAUX">RAAUX</a>).</div></dd><dt class="paramhead"><a name="BCAUX_PARAM" id="BCAUX_PARAM"/>3: &#160;&#160;&#8194; PARAM(<m:math><m:mi mathvariant="italic">n1</m:mi></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>, the value of the argument, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi mathvariant="italic">n</m:mi></m:math>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#BCAUX">BCAUX</a> must be declared as EXTERNAL in the (sub)program from which D02AGF is called. Parameters denoted as <span class="italic">Input</span>  must <b>not</b>  be changed by this procedure.</div>
</dd><dt class="paramhead"><a name="RAAUX" id="RAAUX"/>11: &#8194; RAAUX &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#RAAUX">RAAUX</a> must evaluate the end points, <m:math><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>, of the range and the matching point, <m:math><m:mi>r</m:mi></m:math>, given the values <m:math><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>p</m:mi><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:msub></m:math>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#RAAUX">RAAUX</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;RAAUX&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02agf.xml#RAAUX_X0">X0</a>, <a class="arg" href="../D02/d02agf.xml#RAAUX_X1">X1</a>, <a class="arg" href="../D02/d02agf.xml#RAAUX_R">R</a>, <a class="arg" href="../D02/d02agf.xml#RAAUX_PARAM">PARAM</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X0, X1, R, PARAM(<m:math><m:mi mathvariant="italic">n1</m:mi></m:math>)</td></tr></table>
<div class="paramtext">where <m:math><m:mi mathvariant="italic">n1</m:mi></m:math>&#160;is the numerical value of <a class="arg" href="#N1">N1</a> in the call of D02AGF.
</div>
<dl><dt class="paramhead"><a name="RAAUX_X0" id="RAAUX_X0"/>1: &#160;&#160;&#8194; X0 &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: must contain the left-hand end of the range, <m:math><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>.</div></dd><dt class="paramhead"><a name="RAAUX_X1" id="RAAUX_X1"/>2: &#160;&#160;&#8194; X1 &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: must contain the right-hand end of the range <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>.</div></dd><dt class="paramhead"><a name="RAAUX_R" id="RAAUX_R"/>3: &#160;&#160;&#8194; R &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: must contain the matching point, <m:math><m:mi>r</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="RAAUX_PARAM" id="RAAUX_PARAM"/>4: &#160;&#160;&#8194; PARAM(<m:math><m:mi mathvariant="italic">n1</m:mi></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>, the value of the argument, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:math>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#RAAUX">RAAUX</a> must be declared as EXTERNAL in the (sub)program from which D02AGF is called. Parameters denoted as <span class="italic">Input</span>  must <b>not</b>  be changed by this procedure.</div>
</dd><dt class="paramhead"><a name="PRSOL" id="PRSOL"/>12: &#8194; PRSOL &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#PRSOL">PRSOL</a> is called at each iteration of the Newton method and can be used to print the current values of the parameters <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:math>, their errors, <m:math><m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub></m:math>, and the sum of squares of the errors at the matching point, <m:math><m:mi>r</m:mi></m:math>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#PRSOL">PRSOL</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;PRSOL&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02agf.xml#PRSOL_PARAM">PARAM</a>, <a class="arg" href="../D02/d02agf.xml#PRSOL_RES">RES</a>, <a class="arg" href="../D02/d02agf.xml#PRSOL_N1">N1</a>, <a class="arg" href="../D02/d02agf.xml#PRSOL_ERR">ERR</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N1</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">PARAM(N1), RES, ERR(N1)</td></tr></table>
<dl><dt class="paramhead"><a name="PRSOL_PARAM" id="PRSOL_PARAM"/>1: &#160;&#160;&#8194; PARAM(<a class="arg" href="../D02/d02agf.xml#PRSOL_N1">N1</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>, the current value of the parameters, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:math>.</div></dd><dt class="paramhead"><a name="PRSOL_RES" id="PRSOL_RES"/>2: &#160;&#160;&#8194; RES &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the sum of squares of the errors in the parameters, <m:math><m:mstyle displaystyle="true"><m:munderover><m:mo>&#8721;</m:mo><m:mrow><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:munderover></m:mstyle><m:msubsup><m:mi>e</m:mi><m:mi>i</m:mi><m:mn>2</m:mn></m:msubsup></m:math>.</div></dd><dt class="paramhead"><a name="PRSOL_N1" id="PRSOL_N1"/>3: &#160;&#160;&#8194; N1 &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:math>, the number of parameters.</div></dd><dt class="paramhead"><a name="PRSOL_ERR" id="PRSOL_ERR"/>4: &#160;&#160;&#8194; ERR(<a class="arg" href="../D02/d02agf.xml#PRSOL_N1">N1</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the errors in the parameters, <m:math><m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi mathvariant="italic">n</m:mi><m:mn>1</m:mn></m:msub></m:math>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#PRSOL">PRSOL</a> must be declared as EXTERNAL in the (sub)program from which D02AGF is called. Parameters denoted as <span class="italic">Input</span>  must <b>not</b>  be changed by this procedure.</div>
</dd><dt class="paramhead"><a name="MAT" id="MAT"/>13: &#8194; MAT(<a class="arg" href="#N1">N1</a>,<a class="arg" href="#N1">N1</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="multi-paramhead"><a name="COPY" id="COPY"/>14: &#8194; COPY(<m:math><m:mn>1</m:mn></m:math>,<m:math><m:mn>1</m:mn></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dt class="multi-paramhead"><a name="WSPACE" id="WSPACE"/>15: &#8194; WSPACE(<a class="arg" href="#N">N</a>,<m:math><m:mn>9</m:mn></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="multi-paramhead"><a name="WSPAC1" id="WSPAC1"/>16: &#8194; WSPAC1(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="multi-paramhead"><a name="WSPAC2" id="WSPAC2"/>17: &#8194; WSPAC2(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>18: &#8194; IFAIL &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <a class="arg" href="#IFAIL">IFAIL</a> must be set to <m:math><m:mn>0</m:mn></m:math>, <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>. If you are unfamiliar with this parameter you should refer to <a class="sec" href="../GENINT/essint.xml#library3">Section 3.3</a> in  the Essential Introduction for details.</div>
<div class="paramtext"><i>On exit</i>: <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;unless the routine detects an error (see <a class="sec" href="#errors">Section 6</a>). <div class="paramtext">For environments where it might be inappropriate to halt program execution when an error is detected, the value <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>&#160;is recommended.  If the output of error messages is undesirable, then the value <m:math><m:mn>1</m:mn></m:math>&#160;is recommended.  Otherwise, if you are not familiar with this parameter, the recommended value is <m:math><m:mn>0</m:mn></m:math>.  <b>When the value <m:math><m:mrow><m:mo>-</m:mo><m:mn mathvariant="bold">1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn mathvariant="bold">1</m:mn></m:math>&#160;is used it is essential to test the value of <a class="arg" href="#IFAIL">IFAIL</a> on exit.</b></div></div></dd></dl><h2 class="standard"><a class="sec" name="errors" id="errors"/>6&#160;&#160;Error Indicators and Warnings</h2>
<div class="paramtext">If on entry <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">-1</m:mn></m:maction></m:math>, explanatory error messages are output on the current error message unit (as defined by <a class="rout" href="../X04/x04aaf.xml">X04AAF</a>).</div><div class="paramtext">Errors or warnings detected by the routine:</div>
<dl class="ifail">
<dt class="errorhead"><a name="IFeq1" id="IFeq1"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>
<div class="paramtext">This indicates that <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N1"><m:mi mathcolor="#EE0000" mathvariant="bold">N1</m:mi></m:maction><m:mo>&gt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>&#160;on entry, that is the number of parameters is greater than the number of differential equations.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq2" id="IFeq2"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math></dt>
<dd>
<div class="paramtext">As for <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq4"><m:mn mathcolor="#003399" mathvariant="bold">4</m:mn></m:maction></m:math>&#160;except that the integration failed while calculating the matrix for use in the Newton iteration.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq3" id="IFeq3"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math></dt>
<dd>
<div class="paramtext">The current matching point <m:math><m:mi>r</m:mi></m:math>&#160;does not lie between the current end points <m:math><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>.  If the values <m:math><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>, <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;and <m:math><m:mi>r</m:mi></m:math>&#160;depend on the parameters <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>, this may occur at any time in the Newton iteration if care is not taken to avoid it when coding <a class="arg" href="#RAAUX">RAAUX</a>.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq4" id="IFeq4"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>4</m:mn></m:math></dt>
<dd>
<div class="paramtext">The step length for integration <a class="arg" href="#H">H</a> has halved more than <m:math><m:mn>13</m:mn></m:math>&#160;times (or too many steps were needed to reach the end of the range of integration) in attempting to control the local truncation error whilst integrating to obtain the solution corresponding to the current values <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>.  If, on failure, <a class="arg" href="#H">H</a> has the sign of <m:math><m:mi>r</m:mi><m:mo>-</m:mo><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;then failure has occurred whilst integrating from <m:math><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;to <m:math><m:mi>r</m:mi></m:math>, otherwise it has occurred whilst integrating from <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;to <m:math><m:mi>r</m:mi></m:math>.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq5" id="IFeq5"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>5</m:mn></m:math></dt>
<dd>
<div class="paramtext">The matrix of the equations to be solved for corrections to the variable parameters in the Newton method is singular (as determined by <a class="rout" href="../F03/f03aff.xml">F03AFF</a>).</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq6" id="IFeq6"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>6</m:mn></m:math></dt>
<dd>
<div class="paramtext">A satisfactory correction to the parameters was not obtained on the last Newton iteration employed.  A Newton iteration is deemed to be unsatisfactory if the sum of the squares of the residuals (which can be printed using <a class="arg" href="#PRSOL">PRSOL</a>) has not been reduced after three iterations using a new Newton correction.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq7" id="IFeq7"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>7</m:mn></m:math></dt>
<dd>
<div class="paramtext">Convergence has not been obtained after <m:math><m:mn>12</m:mn></m:math>&#160;satisfactory iterations of the Newton method.</div>
</dd>
</dl>
<div class="paramtext">A further discussion of these errors and the steps which might be taken to correct them is given in <a class="sec" href="#fcomments">Section 8</a>.</div><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">If the process converges, the accuracy to which the unknown parameters are determined is usually close to that specified by you; and the solution, if requested, is usually determined to the accuracy specified.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The time taken by D02AGF depends on the complexity of the system, and on the number of iterations required.  In practice, integration of the differential equations is by far the most costly process involved.</div><div class="paramtext">There may be particular difficulty in integrating the differential equations in one direction (indicated by <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq2"><m:mn mathcolor="#003399" mathvariant="bold">2</m:mn></m:maction></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq4"><m:mn mathcolor="#003399" mathvariant="bold">4</m:mn></m:maction></m:math>).  The value of <m:math><m:mi>r</m:mi></m:math>&#160;should be adjusted to avoid such difficulties.</div><div class="paramtext">If the matching point <m:math><m:mi>r</m:mi></m:math>&#160;is at one of the end points <m:math><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;or <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;and some of the parameters are used <b>only</b> to determine the boundary values at this point, then good initial estimates for these parameters are not required, since they are completely determined by the routine (for example, see <m:math><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub></m:math>&#160;in EX1 of <a class="sec" href="#example">Section 9</a>).</div><div class="paramtext">Wherever they occur in the procedure, the error parameters contained in the arrays <a class="arg" href="#E">E</a> and <a class="arg" href="#PARERR">PARERR</a> are used in &#8216;mixed&#8217; form; that is <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#E"><m:mi mathcolor="#EE0000" mathvariant="bold">E</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;always occurs in expressions of the form <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#E"><m:mi mathcolor="#EE0000" mathvariant="bold">E</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>&#215;</m:mo><m:mfenced separators=""><m:mn>1</m:mn><m:mo>+</m:mo><m:mfenced open="|" close="|" separators=""><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:mfenced></m:mfenced></m:math>, and <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARERR"><m:mi mathcolor="#EE0000" mathvariant="bold">PARERR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;always occurs in expressions of the form <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARERR"><m:mi mathcolor="#EE0000" mathvariant="bold">PARERR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>&#215;</m:mo><m:mfenced separators=""><m:mn>1</m:mn><m:mo>+</m:mo><m:mfenced open="|" close="|" separators=""><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:mfenced></m:mfenced></m:math>.  Though not ideal for every application, it is expected that this mixture of absolute and relative error testing will be adequate for most purposes.</div><div class="paramtext">Note that <b>convergence</b>
<b>is</b>
<b>not</b>
<b>guaranteed</b>.  You are strongly advised to provide an output <a class="arg" href="#PRSOL">PRSOL</a>, as shown in EX1 of <a class="sec" href="#example">Section 9</a>, in order to monitor the progress of the iteration.  Failure of the Newton iteration to converge (see <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq6"><m:mn mathcolor="#003399" mathvariant="bold">6</m:mn></m:maction></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq7"><m:mn mathcolor="#003399" mathvariant="bold">7</m:mn></m:maction></m:math>) usually results from poor starting approximations to the parameters, though occasionally such failures occur because the elements of one or both of the arrays <a class="arg" href="#PARERR">PARERR</a> or <a class="arg" href="#E">E</a> are too small.  (It should be possible to distinguish these cases by studying the output from <a class="arg" href="#PRSOL">PRSOL</a>.)  Poor starting approximations can also result in the failure described under <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq4"><m:mn mathcolor="#003399" mathvariant="bold">4</m:mn></m:maction></m:math>&#160;and <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq5"><m:mn mathcolor="#003399" mathvariant="bold">5</m:mn></m:maction></m:math>&#160;in <a class="sec" href="#errors">Section 6</a> (especially if these errors occur after some Newton iterations have been completed, that is, after two or more calls of <a class="arg" href="#PRSOL">PRSOL</a>).  More frequently, a singular matrix in the Newton method (monitored as <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq5"><m:mn mathcolor="#003399" mathvariant="bold">5</m:mn></m:maction></m:math>) occurs because the mathematical problem has been posed incorrectly.  The case <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq4"><m:mn mathcolor="#003399" mathvariant="bold">4</m:mn></m:maction></m:math>&#160;usually occurs because <m:math><m:mi>h</m:mi></m:math>&#160;or <m:math><m:mi>r</m:mi></m:math>&#160;has been poorly estimated, so these values should be checked first.  If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq2"><m:mn mathcolor="#003399" mathvariant="bold">2</m:mn></m:maction></m:math>&#160;is monitored, the solution <m:math><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mi mathvariant="italic">n</m:mi></m:msub></m:math>&#160;is sensitive to perturbations in the parameters <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>.  Reduce the size of one or more values <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARERR"><m:mi mathcolor="#EE0000" mathvariant="bold">PARERR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;to reduce the perturbations.  Since only one value <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;is perturbed at any time when forming the matrix, the perturbation which is too large can be located by studying the final output from <a class="arg" href="#PRSOL">PRSOL</a> and the values of the parameters returned by D02AGF.  If this change leads to other types of failure improve the initial values of <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;by other means.</div><div class="paramtext">The computing time for integrating the differential equations can sometimes depend critically on the quality of the initial estimates for the parameters <m:math><m:msub><m:mi>p</m:mi><m:mi>i</m:mi></m:msub></m:math>.  If it seems that too much computing time is required and, in particular, if the values <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PRSOL_ERR"><m:mi mathcolor="#EE0000" mathvariant="bold">ERR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;(available on each call of <a class="arg" href="#PRSOL">PRSOL</a>) are much larger than the expected values of the solution at the matching point <m:math><m:mi>r</m:mi></m:math>, then the coding of <a class="arg" href="#AUX">AUX</a>, <a class="arg" href="#BCAUX">BCAUX</a> and <a class="arg" href="#RAAUX">RAAUX</a> should be checked for errors.  If no errors can be found, an independent attempt should be made to improve the initial estimates for <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARAM"><m:mi mathcolor="#EE0000" mathvariant="bold">PARAM</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>.</div><div class="paramtext">The subroutine can be used to solve a very wide range of problems, for example:
<table class="standard-100"><tr>
<td style="width:2.1em;" valign="baseline">(a)</td>
<td valign="top">eigenvalue problems, including problems where the eigenvalue occurs in the boundary conditions;</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(b)</td>
<td valign="top">problems where the differential equations depend on some parameters which are to be determined so as to satisfy certain boundary conditions (see EX1 in <a class="sec" href="#example">Section 9</a>);</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(c)</td>
<td valign="top">problems where one of the end points of the range of integration is to be determined as the point where a variable <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;takes a particular value (see EX2 in <a class="sec" href="#example">Section 9</a>);</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(d)</td>
<td valign="top">singular problems and problems on infinite ranges of integration where the values of the solution at <m:math><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;or <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;or both are determined by a power series or an asymptotic expansion (or a more complicated expression) and where some of the coefficients in the expression are to be determined (see EX1 in <a class="sec" href="#example">Section 9</a>); and</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(e)</td>
<td valign="top">differential equations with certain terms defined by other independent (driving) differential equations.</td>
</tr></table>
</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">For this routine two examples are presented.  There is a single example program for D02AGF, with a main program and the code to solve the two example problems given in Example 1 (EX1) and Example 2 (EX2).</div><div class="paramtext"><b>Example 1 (EX1)</b></div><div class="paramtext">This example finds the solution of the differential equation

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:msup><m:mi>y</m:mi><m:mrow><m:mo>&#8242;</m:mo><m:mo>&#8242;</m:mo></m:mrow></m:msup><m:mo>=</m:mo><m:mfrac><m:mrow><m:msup><m:mi>y</m:mi><m:mn>3</m:mn></m:msup><m:mo>-</m:mo><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup></m:mrow>
  <m:mrow><m:mn>2</m:mn><m:mi>x</m:mi></m:mrow>
 </m:mfrac>
</m:math></td><td class="formula2"/></tr></table></div>

on the range <m:math><m:mn>0</m:mn><m:mo>&#8804;</m:mo><m:mi>x</m:mi><m:mo>&#8804;</m:mo><m:mn>16</m:mn></m:math>, with boundary conditions <m:math><m:mi>y</m:mi><m:mfenced separators=""><m:mn>0</m:mn></m:mfenced><m:mo>=</m:mo><m:mn>0.1</m:mn></m:math>&#160;and <m:math><m:mi>y</m:mi><m:mfenced separators=""><m:mn>16</m:mn></m:mfenced><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>/</m:mo><m:mn>6</m:mn></m:math>.</div><div class="paramtext">We cannot use the differential equation at <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:math>&#160;because it is singular, so we take the truncated series expansion

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>y</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>=</m:mo><m:mfrac other="small"><m:mn>1</m:mn><m:mn>10</m:mn></m:mfrac><m:mo>+</m:mo><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub><m:mfrac><m:msqrt><m:mi>x</m:mi></m:msqrt><m:mn>10</m:mn></m:mfrac><m:mo>+</m:mo><m:mfrac><m:mi>x</m:mi><m:mn>100</m:mn></m:mfrac>
</m:math></td><td class="formula2"/></tr></table></div>

near the origin (which is correct to the number of terms given in this case).  Here <m:math><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;is one of the parameters to be determined.  We choose the range as <m:math><m:mfenced separators="" open="[" close="]"><m:mn>0.1</m:mn><m:mo>,</m:mo><m:mn>16</m:mn></m:mfenced></m:math>&#160;and setting <m:math><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub><m:mo>=</m:mo><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mfenced separators=""><m:mn>16</m:mn></m:mfenced></m:math>, we can determine all the boundary conditions.  We take the matching point to be <m:math><m:mn>16</m:mn></m:math>, the end of the range, and so a good initial guess for <m:math><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub></m:math>&#160;is not necessary.  We write <m:math><m:mi>y</m:mi><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#AUX_Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>, <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#AUX_Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow></m:math>, and estimate <m:math><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARAM"><m:mi mathcolor="#EE0000" mathvariant="bold">PARAM</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mn>0.2</m:mn></m:math>, <m:math><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARAM"><m:mi mathcolor="#EE0000" mathvariant="bold">PARAM</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>.</div><div class="paramtext"><b>Example 2 (EX2)</b></div><div class="paramtext">This example finds the gravitational constant <m:math><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;and the range <m:math><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub></m:math>&#160;over which a projectile must be fired to hit the target with a given velocity.  The differential equations are

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mtable columnalign="left">
 <m:mtr>
  <m:mtd><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mo>=</m:mo><m:mrow><m:mi>tan</m:mi><m:mo>&#8289;</m:mo><m:mi>&#981;</m:mi></m:mrow></m:mtd>
 </m:mtr><m:mtr>
  <m:mtd/></m:mtr><m:mtr>
  <m:mtd><m:msup><m:mi>v</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mo>=</m:mo><m:mfrac other="display">
  <m:mrow><m:mo>-</m:mo><m:mfenced separators=""><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub><m:mrow><m:mi>sin</m:mi><m:mo>&#8289;</m:mo><m:mi>&#981;</m:mi></m:mrow><m:mo>+</m:mo><m:mn>0.00002</m:mn><m:mo>&#8290;</m:mo><m:msup><m:mi>v</m:mi><m:mn>2</m:mn></m:msup></m:mfenced></m:mrow>
  <m:mrow><m:mi>v</m:mi><m:mrow><m:mi>cos</m:mi><m:mo>&#8289;</m:mo><m:mi>&#981;</m:mi></m:mrow></m:mrow>
 </m:mfrac></m:mtd>
 </m:mtr><m:mtr>
  <m:mtd/></m:mtr><m:mtr>
  <m:mtd><m:msup><m:mi>&#981;</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mo>=</m:mo><m:mfrac><m:mrow><m:mo>-</m:mo><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub></m:mrow><m:msup><m:mi>v</m:mi><m:mn>2</m:mn></m:msup></m:mfrac><m:mi>k</m:mi></m:mtd>
 </m:mtr>
</m:mtable>
</m:math></td><td class="formula2"/></tr></table></div>

on the range <m:math><m:mn>0</m:mn><m:mo>&lt;</m:mo><m:mi>x</m:mi><m:mo>&lt;</m:mo><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub></m:math>&#160;with boundary conditions

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mtable columnalign="left">
 <m:mtr>
  <m:mtd><m:mi>y</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mtext>,</m:mtext></m:mtd>
  <m:mtd><m:mi>v</m:mi><m:mo>=</m:mo><m:mn>500</m:mn><m:mtext>,</m:mtext></m:mtd>
  <m:mtd><m:mi>&#981;</m:mi><m:mo>=</m:mo><m:mn>0.5</m:mn></m:mtd>
  <m:mtd><m:mtext>at</m:mtext></m:mtd>
  <m:mtd><m:mi>x</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:mtd>
 </m:mtr><m:mtr>
  <m:mtd><m:mi>y</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mtext>,</m:mtext></m:mtd>
  <m:mtd><m:mi>v</m:mi><m:mo>=</m:mo><m:mn>450</m:mn><m:mtext>,</m:mtext></m:mtd>
  <m:mtd><m:mi>&#981;</m:mi><m:mo>=</m:mo><m:msub><m:mi>p</m:mi><m:mn>3</m:mn></m:msub></m:mtd>
  <m:mtd><m:mtext>at</m:mtext></m:mtd>
  <m:mtd><m:mi>x</m:mi><m:mo>=</m:mo><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub><m:mtext>.</m:mtext></m:mtd>
 </m:mtr>
</m:mtable>
</m:math></td><td class="formula2"/></tr></table></div>

We write <m:math><m:mi>y</m:mi><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#AUX_Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>, <m:math><m:mi>v</m:mi><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#AUX_Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow></m:math>, <m:math><m:mi>&#981;</m:mi><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#AUX_Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>3</m:mn></m:mfenced></m:mrow></m:math>, and we take the matching point <m:math><m:mi>r</m:mi><m:mo>=</m:mo><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub></m:math>.  We estimate <m:math><m:msub><m:mi>p</m:mi><m:mn>1</m:mn></m:msub><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARAM"><m:mi mathcolor="#EE0000" mathvariant="bold">PARAM</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mn>32</m:mn></m:math>, <m:math><m:msub><m:mi>p</m:mi><m:mn>2</m:mn></m:msub><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARAM"><m:mi mathcolor="#EE0000" mathvariant="bold">PARAM</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mn>6000</m:mn></m:math>&#160;and <m:math><m:msub><m:mi>p</m:mi><m:mn>3</m:mn></m:msub><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#PARAM"><m:mi mathcolor="#EE0000" mathvariant="bold">PARAM</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>3</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mn>0.54</m:mn></m:math>&#160;(though this estimate is not important).</div><h3 class="standard"><a class="sec" name="examtext" id="examtext"/>9.1&#160;&#160;Program Text</h3>
<p><a class="verbatimref" href="../../examples/source/d02agfe.f">Program Text (d02agfe.f)</a></p><h3 class="standard"><a class="sec" name="examdata" id="examdata"/>9.2&#160;&#160;Program Data</h3>
<div class="paramtext">None.</div><h3 class="standard"><a class="sec" name="examresults" id="examresults"/>9.3&#160;&#160;Program Results</h3>
<p><a class="verbatimref" href="../../examples/baseresults/d02agfe.r">Program Results (d02agfe.r)</a></p><div class="figure"><a name="d02agf1-plot" id="d02agf1-plot"/><img src="../figures/d02agf1-plot.png" alt="Example Program Plot for d02agf1-plot"/></div><div class="figure"><a name="d02agf2-plot" id="d02agf2-plot"/><img src="../figures/d02agf2-plot.png" alt="Example Program Plot for d02agf2-plot"/></div>
<hr/><div><a class="rout" href="../../pdf/D02/d02agf.pdf">D02AGF (PDF version)</a></div><div><a class="chap" href="d02conts.xml">D02 Chapter Contents</a></div><div><a class="chapint" href="d02intro.xml">D02 Chapter Introduction</a></div>
<div><a class="htmltoc" href="../FRONTMATTER/manconts.xml">NAG Library Manual</a></div>
<div><hr/><a class="genint" href="../FRONTMATTER/copyright.xml">&#169; The Numerical Algorithms Group Ltd, Oxford, UK. 2009</a></div></body></html>