<?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>D02EJF : 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/d02ejf.pdf">D02EJF (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/>D02EJF</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">D02EJF integrates a stiff system of first-order ordinary differential equations over an interval with suitable initial conditions, using a variable-order, variable-step method implementing the Backward Differentiation Formulae (BDF), until a user-specified function, if supplied, of the solution is zero, and returns the solution at points specified by you, if desired.</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;D02EJF&#160;(</td><td class="tdfspec2"><a class="arg" href="#X">X</a>, <a class="arg" href="#XEND">XEND</a>, <a class="arg" href="#N">N</a>, <a class="arg" href="#Y">Y</a>, <a class="arg" href="#FCN">FCN</a>, <a class="arg" href="#PEDERV">PEDERV</a>, <a class="arg" href="#TOL">TOL</a>, <a class="arg" href="#RELABS">RELABS</a>, <a class="arg" href="#OUTPUT">OUTPUT</a>, <a class="arg" href="#G">G</a>, <a class="arg" href="#W">W</a>, <a class="arg" href="#IW">IW</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N, IW, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X, XEND, Y(N), TOL, G, W(IW)</td></tr><tr><td class="tdfspec1">CHARACTER*1</td><td class="tdfspec2">RELABS</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">FCN, PEDERV, OUTPUT, G</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D02EJF advances the solution of a system of ordinary differential equations

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:msubsup><m:mi>y</m:mi><m:mi>i</m:mi><m:mo>&#8242;</m:mo></m:msubsup>
 <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>

from <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction></m:math>&#160;to <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#XEND"><m:mi mathcolor="#EE0000" mathvariant="bold">XEND</m:mi></m:maction></m:math>&#160;using a variable-order, variable-step method implementing the BDF.  The system is defined by <a class="arg" href="#FCN">FCN</a>, which evaluates <m:math><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;in terms of <m:math><m:mi>x</m:mi></m:math>&#160;and <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;(see <a class="sec" href="#parameters">Section 5</a>).  The initial values of <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;must be given at <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction></m:math>.</div><div class="paramtext">The solution is returned via the <a class="arg" href="#OUTPUT">OUTPUT</a> at points specified by you, if desired: this solution is obtained by <m:math><m:msup><m:mi>C</m:mi><m:mn>1</m:mn></m:msup></m:math>&#160;interpolation on solution values produced by the method.  As the integration proceeds a check can be made on the user-specified function <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;to determine an interval where it changes sign.  The position of this sign change is then determined accurately by <m:math><m:msup><m:mi>C</m:mi><m:mn>1</m:mn></m:msup></m:math>&#160;interpolation to the solution.  It is assumed that <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;is a continuous function of the variables, so that a solution of <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>&#160;can be determined by searching for a change in sign in <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>.  The accuracy of the integration, the interpolation and, indirectly, of the determination of the position where <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>, is controlled by the parameters <a class="arg" href="#TOL">TOL</a> and <a class="arg" href="#RELABS">RELABS</a>.  The Jacobian of the system <m:math><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mo>=</m:mo><m:mi>f</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;may be supplied in <a class="arg" href="#PEDERV">PEDERV</a>, if it is available.</div><div class="paramtext">For a description of BDF and their practical implementation see <a class="ref" href="#ref024">Hall and Watt (1976)</a>.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref024" id="ref024"/>Hall G and Watt J M (ed.) (1976)  <i>Modern Numerical Methods for Ordinary Differential Equations</i> Clarendon Press, Oxford </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="X" id="X"/>1: &#160;&#160;&#8194; X &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the initial value of the independent variable <m:math><m:mi>x</m:mi></m:math>.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mo>&#8800;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#XEND"><m:mi mathcolor="#EE0000" mathvariant="bold">XEND</m:mi></m:maction></m:math>.
</div>
<div class="paramtext"><i>On exit</i>: if <a class="arg" href="#G">G</a> is supplied by you, <a class="arg" href="#X">X</a> contains the point where <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>, unless <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mo>&#8800;</m:mo><m:mn>0.0</m:mn></m:math>&#160;anywhere on the range <a class="arg" href="#X">X</a> to <a class="arg" href="#XEND">XEND</a>, in which case, <a class="arg" href="#X">X</a> will contain <a class="arg" href="#XEND">XEND</a>. If <a class="arg" href="#G">G</a> is not supplied <a class="arg" href="#X">X</a> contains <a class="arg" href="#XEND">XEND</a>, unless an error has occurred, when it contains the value of <m:math><m:mi>x</m:mi></m:math>&#160;at the error.</div></dd><dt class="paramhead"><a name="XEND" id="XEND"/>2: &#160;&#160;&#8194; XEND &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the final value of the independent variable. If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#XEND"><m:mi mathcolor="#EE0000" mathvariant="bold">XEND</m:mi></m:maction><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction></m:math>, integration will proceed in the negative direction.</div>
<div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#XEND"><m:mi mathcolor="#EE0000" mathvariant="bold">XEND</m:mi></m:maction><m:mo>&#8800;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="N" id="N"/>3: &#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 number of differential equations.</div>
<div class="paramtext"><i>Constraint</i>:
  <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>&#8805;</m:mo><m:mn>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="Y" id="Y"/>4: &#160;&#160;&#8194; Y(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the initial values of 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;at <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction></m:math>.</div><div class="paramtext"><i>On exit</i>: the computed values of the solution at the final point <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction></m:math>.</div></dd><dt class="paramhead"><a name="FCN" id="FCN"/>5: &#160;&#160;&#8194; FCN &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#FCN">FCN</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>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#FCN">FCN</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;FCN&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02ejf.xml#FCN_X">X</a>, <a class="arg" href="../D02/d02ejf.xml#FCN_Y">Y</a>, <a class="arg" href="../D02/d02ejf.xml#FCN_F">F</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X, Y(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>), F(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>)</td></tr></table>
<div class="paramtext">where <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;is the value of <a class="arg" href="#N">N</a> in the call of D02EJF.</div>
<dl><dt class="paramhead"><a name="FCN_X" id="FCN_X"/>1: &#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 independent variable.</div></dd><dt class="paramhead"><a name="FCN_Y" id="FCN_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"><b>Note:</b> the dimension of the array <a class="arg" href="../D02/d02ejf.xml#FCN_Y">Y</a>
is
<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>.</div><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 variable, 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="FCN_F" id="FCN_F"/>3: &#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"><b>Note:</b> the dimension of the array <a class="arg" href="../D02/d02ejf.xml#FCN_F">F</a>
is
<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>.</div>
<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></dl>
</div>
<div class="paramtext"><a class="arg" href="#FCN">FCN</a> must be declared as EXTERNAL in the (sub)program from which D02EJF 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="PEDERV" id="PEDERV"/>6: &#160;&#160;&#8194; PEDERV &#8211; SUBROUTINE, supplied by the NAG Library or the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#PEDERV">PEDERV</a> must evaluate the Jacobian of the system (that is, the partial derivatives <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:mrow>
  <m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>y</m:mi><m:mi>j</m:mi></m:msub></m:mrow>
 </m:mfrac>
</m:math>) for given values of the variables <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: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>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#PEDERV">PEDERV</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;PEDERV&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02ejf.xml#PEDERV_X">X</a>, <a class="arg" href="../D02/d02ejf.xml#PEDERV_Y">Y</a>, <a class="arg" href="../D02/d02ejf.xml#PEDERV_PW">PW</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X, Y(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>), PW(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>,<m:math><m:mi mathvariant="italic">n</m:mi></m:math>)</td></tr></table>
<div class="paramtext">where <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;is the value of <a class="arg" href="#N">N</a> in the call of D02EJF.</div>
<dl><dt class="paramhead"><a name="PEDERV_X" id="PEDERV_X"/>1: &#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 independent variable.</div></dd><dt class="paramhead"><a name="PEDERV_Y" id="PEDERV_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"><b>Note:</b> the dimension of the array <a class="arg" href="../D02/d02ejf.xml#PEDERV_Y">Y</a>
is
<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>.</div><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 variable, 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="PEDERV_PW" id="PEDERV_PW"/>3: &#160;&#160;&#8194; PW(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>,<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:mfrac other="display">
  <m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:mrow>
  <m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>y</m:mi><m:mi>j</m:mi></m:msub></m:mrow>
 </m:mfrac>
</m:math>, for <m:math><m:mi>i</m:mi><m:mo>,</m:mo><m:mi>j</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="#PEDERV">PEDERV</a> must be declared as EXTERNAL in the (sub)program from which D02EJF is called. Parameters denoted as <span class="italic">Input</span>  must <b>not</b>  be changed by this procedure.</div>
<div class="paramtext">If you do not wish to supply the Jacobian, the actual parameter <a class="arg" href="#PEDERV">PEDERV</a> <b>must</b> be the 
dummy routine D02EJY.  (D02EJY is included in the NAG Library.)

</div>
</dd><dt class="paramhead"><a name="TOL" id="TOL"/>7: &#160;&#160;&#8194; TOL &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: must be set to a <b>positive</b> tolerance for controlling the error in the integration. Hence <a class="arg" href="#TOL">TOL</a> affects the determination of the position where <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>, if <a class="arg" href="#G">G</a> is supplied.
<div class="paramtext">D02EJF has been designed so that, for most problems, a reduction in <a class="arg" href="#TOL">TOL</a> leads to an approximately proportional reduction in the error in the solution. However, the actual relation between <a class="arg" href="#TOL">TOL</a> and the accuracy achieved cannot be guaranteed. You are strongly recommended to call D02EJF with more than one value for <a class="arg" href="#TOL">TOL</a> and to compare the results obtained to estimate their accuracy. In the absence of any prior knowledge, you might compare the results obtained by calling D02EJF with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>=</m:mo><m:msup><m:mn>10</m:mn><m:mrow><m:mo>-</m:mo><m:mi>p</m:mi></m:mrow></m:msup></m:math>&#160;and <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>=</m:mo><m:msup><m:mn>10</m:mn><m:mrow><m:mo>-</m:mo><m:mi>p</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msup></m:math>&#160;if <m:math><m:mi>p</m:mi></m:math>&#160;correct decimal digits are required in the solution.</div>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>0.0</m:mn></m:math>.
</div>
<div class="paramtext"><i>On exit</i>: normally unchanged. However if the range <a class="arg" href="#X">X</a> to <a class="arg" href="#XEND">XEND</a> is so short that a small change in <a class="arg" href="#TOL">TOL</a> is unlikely to make any change in the computed solution, then, on return, <a class="arg" href="#TOL">TOL</a> has its sign changed.</div></dd><dt class="paramhead"><a name="RELABS" id="RELABS"/>8: &#160;&#160;&#8194; RELABS &#8211; CHARACTER*1<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the type of error control. At each step in the numerical solution an estimate of the local error, <m:math><m:mi mathvariant="italic">est</m:mi></m:math>, is made. For the current step to be accepted the following condition must be satisfied: 

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block"> 
 <m:mi mathvariant="italic">est</m:mi>
 <m:mo>=</m:mo>
 <m:msqrt>
  <m:mfrac other="small"><m:mn>1</m:mn><m:mi mathvariant="italic">n</m:mi></m:mfrac>
  <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:mi mathvariant="italic">n</m:mi>
  </m:munderover>
  <m:msup>
   <m:mfenced separators="">
     <m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub>
     <m:mo>/</m:mo>
     <m:mfenced separators="">
      <m:msub><m:mi>&#964;</m:mi><m:mi>r</m:mi></m:msub>
      <m:mo>&#215;</m:mo>
      <m:mfenced open="|" close="|" separators=""><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:mfenced>
      <m:mo>+</m:mo>
      <m:msub><m:mi>&#964;</m:mi><m:mi>a</m:mi></m:msub>
     </m:mfenced>
    </m:mfenced>
   <m:mn>2</m:mn>
  </m:msup>
 </m:msqrt>
 <m:mo>&#8804;</m:mo>
 <m:mn>1.0</m:mn> 
</m:math></td><td class="formula2"/></tr></table></div>
 where <m:math><m:msub><m:mi>&#964;</m:mi><m:mi>r</m:mi></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>&#964;</m:mi><m:mi>a</m:mi></m:msub></m:math>&#160;are defined by 
<div class="tablediv"><table class="frame-none"> 
   
   
   
  <tbody> 
   <tr> 
    <td class="libdoc" valign="top" align="center"><a class="arg" href="#RELABS">RELABS</a></td>
    <td class="libdoc" valign="top" align="center"><m:math><m:msub><m:mi>&#964;</m:mi><m:mi>r</m:mi></m:msub></m:math></td>
    <td class="libdoc" valign="top" align="center"><m:math><m:msub><m:mi>&#964;</m:mi><m:mi>a</m:mi></m:msub></m:math></td>
   </tr><tr>
    <td class="libdoc" valign="top" align="left">'M'</td>
    <td class="libdoc" valign="top" align="center"><a class="arg" href="#TOL">TOL</a></td>
    <td class="libdoc" valign="top" align="center"><a class="arg" href="#TOL">TOL</a></td>
   </tr><tr>
    <td class="libdoc" valign="top" align="left">'A'</td>
    <td class="libdoc" valign="top" align="center">0.0</td>
    <td class="libdoc" valign="top" align="center"><a class="arg" href="#TOL">TOL</a></td>
   </tr><tr> <td class="libdoc" valign="top" align="left">'R'</td>
    <td class="libdoc" valign="top" align="center"><a class="arg" href="#TOL">TOL</a></td>
    <td class="libdoc" valign="top" align="center"><m:math><m:mi>&#949;</m:mi></m:math></td>
   </tr><tr>
    <td class="libdoc" valign="top" align="left">'D'</td>
    <td class="libdoc" valign="top" align="center"><a class="arg" href="#TOL">TOL</a></td>
    <td class="libdoc" valign="top" align="center"><m:math><m:mi>&#949;</m:mi></m:math></td>
   </tr>
  </tbody>
 </table></div> 
where <m:math><m:mi>&#949;</m:mi></m:math>&#160;is a small machine-dependent number and <m:math><m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;is an estimate of the local error at <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>, computed internally. If the appropriate condition is not satisfied, the step size is reduced and the solution is recomputed on the current step. If you wish to measure the error in the computed solution in terms of the number of correct decimal places, then <a class="arg" href="#RELABS">RELABS</a> should be set to 'A' on entry, whereas if the error requirement is in terms of the number of correct significant digits, then <a class="arg" href="#RELABS">RELABS</a> should be set to 'R'. If you prefer a mixed error test, then <a class="arg" href="#RELABS">RELABS</a> should be set to 'M', otherwise if you have no preference, <a class="arg" href="#RELABS">RELABS</a> should be set to the default 'D'. Note that in this case 'D' is taken to be 'R'.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RELABS"><m:mi mathcolor="#EE0000" mathvariant="bold">RELABS</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'A'</m:mtext></m:math>, <m:math><m:mtext>'M'</m:mtext></m:math>, <m:math><m:mtext>'R'</m:mtext></m:math>&#160;or <m:math><m:mtext>'D'</m:mtext></m:math>.
</div></dd><dt class="paramhead"><a name="OUTPUT" id="OUTPUT"/>9: &#160;&#160;&#8194; OUTPUT &#8211; SUBROUTINE, supplied by the NAG Library or the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#OUTPUT">OUTPUT</a> permits access to intermediate values of the computed solution (for example to print or plot them), at successive user-specified points. It is initially called by D02EJF with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#OUTPUT_XSOL"><m:mi mathcolor="#EE0000" mathvariant="bold">XSOL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction></m:math>&#160;(the initial value of <m:math><m:mi>x</m:mi></m:math>). You must reset <a class="arg" href="../D02/d02ejf.xml#OUTPUT_XSOL">XSOL</a> to the next point (between the current <a class="arg" href="../D02/d02ejf.xml#OUTPUT_XSOL">XSOL</a> and <a class="arg" href="#XEND">XEND</a>) where <a class="arg" href="#OUTPUT">OUTPUT</a> is to be called, and so on at each call to <a class="arg" href="#OUTPUT">OUTPUT</a>. If, after a call to <a class="arg" href="#OUTPUT">OUTPUT</a>, the reset point <a class="arg" href="../D02/d02ejf.xml#OUTPUT_XSOL">XSOL</a> is beyond <a class="arg" href="#XEND">XEND</a>, D02EJF will integrate to <a class="arg" href="#XEND">XEND</a> with no further calls to <a class="arg" href="#OUTPUT">OUTPUT</a>; if a call to <a class="arg" href="#OUTPUT">OUTPUT</a> is required at the point <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#OUTPUT_XSOL"><m:mi mathcolor="#EE0000" mathvariant="bold">XSOL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#XEND"><m:mi mathcolor="#EE0000" mathvariant="bold">XEND</m:mi></m:maction></m:math>, then <a class="arg" href="../D02/d02ejf.xml#OUTPUT_XSOL">XSOL</a> must be given precisely the value <a class="arg" href="#XEND">XEND</a>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#OUTPUT">OUTPUT</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;OUTPUT&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02ejf.xml#OUTPUT_XSOL">XSOL</a>, <a class="arg" href="../D02/d02ejf.xml#OUTPUT_Y">Y</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">XSOL, Y(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>)</td></tr></table>
<div class="paramtext">where <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;is the value of <a class="arg" href="#N">N</a> in the call of D02EJF.</div>
<dl><dt class="paramhead"><a name="OUTPUT_XSOL" id="OUTPUT_XSOL"/>1: &#160;&#160;&#8194; XSOL &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mi>x</m:mi></m:math>, the value of the independent variable.</div>
<div class="paramtext"><i>On exit</i>: you must set <a class="arg" href="../D02/d02ejf.xml#OUTPUT_XSOL">XSOL</a> to the next value of <m:math><m:mi>x</m:mi></m:math>&#160;at which <a class="arg" href="#OUTPUT">OUTPUT</a> is to be called.</div></dd><dt class="paramhead"><a name="OUTPUT_Y" id="OUTPUT_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"><b>Note:</b> the dimension of the array <a class="arg" href="../D02/d02ejf.xml#OUTPUT_Y">Y</a>
is
<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>.</div><div class="paramtext"><i>On entry</i>: the computed solution at the point <a class="arg" href="../D02/d02ejf.xml#OUTPUT_XSOL">XSOL</a>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#OUTPUT">OUTPUT</a> must be declared as EXTERNAL in the (sub)program from which D02EJF is called. Parameters denoted as <span class="italic">Input</span>  must <b>not</b>  be changed by this procedure.</div>
<div class="paramtext">If you do not wish to access intermediate output, the actual parameter <a class="arg" href="#OUTPUT">OUTPUT</a> <b>must</b> be the 
dummy routine D02EJX.  (D02EJX is included in the NAG Library.)

</div>
</dd><dt class="paramhead"><a name="G" id="G"/>10: &#8194; G &#8211; <span class="bitalic">double precision</span> FUNCTION, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#G">G</a> must evaluate the function <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;for specified values <m:math><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:math>. It specifies the function <m:math><m:mi>g</m:mi></m:math>&#160;for which the first position <m:math><m:mi>x</m:mi></m:math>&#160;where <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mo>=</m:mo><m:mn>0</m:mn></m:math>&#160;is to be found.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#G">G</a> is:</div><table class="fspec"><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b>&#160;FUNCTION&#160;G&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02ejf.xml#G_X">X</a>, <a class="arg" href="../D02/d02ejf.xml#G_Y">Y</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X, Y(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>)</td></tr></table>
<div class="paramtext">where <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;is the value of <a class="arg" href="#N">N</a> in the call of D02EJF.</div>
<dl><dt class="paramhead"><a name="G_X" id="G_X"/>1: &#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 independent variable.</div></dd><dt class="paramhead"><a name="G_Y" id="G_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"><b>Note:</b> the dimension of the array <a class="arg" href="../D02/d02ejf.xml#G_Y">Y</a>
is
<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>.</div><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 variable, 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="#G">G</a> must be declared as EXTERNAL in the (sub)program from which D02EJF is called. Parameters denoted as <span class="italic">Input</span>  must <b>not</b>  be changed by this procedure.</div>
<div class="paramtext">If you do not require the root-finding option, the actual parameter <a class="arg" href="#G">G</a> <b>must</b> be the 
dummy routine D02EJW.  (D02EJW is included in the NAG Library.)

</div>
</dd><dt class="paramhead"><a name="W" id="W"/>11: &#8194; W(<a class="arg" href="#IW">IW</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="multi-paramhead"><a name="IW" id="IW"/>12: &#8194; IW &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the dimension of the array <a class="arg" href="#W">W</a> as declared in the (sub)program from which D02EJF is called.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IW"><m:mi mathcolor="#EE0000" mathvariant="bold">IW</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mfenced separators=""><m:mn>12</m:mn><m:mo>+</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:mfenced><m:mo>&#215;</m:mo><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:mn>50</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>13: &#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>
<table class="ifail"><tr><td class="ifail1">On&#160;entry,</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>0.0</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#XEND"><m:mi mathcolor="#EE0000" mathvariant="bold">XEND</m:mi></m:maction></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><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>&#8804;</m:mo><m:mn>0</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RELABS"><m:mi mathcolor="#EE0000" mathvariant="bold">RELABS</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mtext>'M'</m:mtext><m:mo>,</m:mo><m:mtext>'A'</m:mtext><m:mo>,</m:mo><m:mtext>'R'</m:mtext><m:mo>,</m:mo><m:mtext>'D'</m:mtext></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IW"><m:mi mathcolor="#EE0000" mathvariant="bold">IW</m:mi></m:maction><m:mo>&lt;</m:mo><m:mfenced separators=""><m:mn>12</m:mn><m:mo>+</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:mfenced><m:mo>&#215;</m:mo><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:mn>50</m:mn></m:math>.</td></tr></table>
</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">With the given value of <a class="arg" href="#TOL">TOL</a>, no further progress can be made across the integration range from the current point <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction></m:math>.  (See <a class="sec" href="#parameters">Section 5</a> for a discussion of this error test.)  The components <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#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:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#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:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi mathvariant="italic">n</m:mi></m:mfenced></m:mrow></m:math>&#160;contain the computed values of the solution at the current point <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction></m:math>.  If you have supplied <a class="arg" href="#G">G</a>, then no point at which <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;changes sign has been located up to the point <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction></m:math>.</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"><a class="arg" href="#TOL">TOL</a> is too small for D02EJF to take an initial step.  <a class="arg" href="#X">X</a> and <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#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:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#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:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Y"><m:mi mathcolor="#EE0000" mathvariant="bold">Y</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi mathvariant="italic">n</m:mi></m:mfenced></m:mrow></m:math>&#160;retain their initial values.</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"><a class="arg" href="../D02/d02ejf.xml#OUTPUT_XSOL">XSOL</a> lies behind <a class="arg" href="#X">X</a> in the direction of integration, after the initial call to <a class="arg" href="#OUTPUT">OUTPUT</a>, if the <a class="arg" href="#OUTPUT">OUTPUT</a> option was selected.</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">A value of <a class="arg" href="../D02/d02ejf.xml#OUTPUT_XSOL">XSOL</a> returned by the <a class="arg" href="#OUTPUT">OUTPUT</a> lies behind the last value of <a class="arg" href="../D02/d02ejf.xml#OUTPUT_XSOL">XSOL</a> in the direction of integration, if the <a class="arg" href="#OUTPUT">OUTPUT</a> option was selected.</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">At no point in the range <a class="arg" href="#X">X</a> to <a class="arg" href="#XEND">XEND</a> did the function <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;change sign, if <a class="arg" href="#G">G</a> was supplied.  It is assumed that <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mo>=</m:mo><m:mn>0</m:mn></m:math>&#160;has no solution.</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>&#160;(<a class="rout" href="../C05/c05azf.xml">C05AZF</a>)</dt>
<dd>
<div class="paramtext">A serious error has occurred in an internal call to the specified routine.  Check all subroutine calls and array dimensions.  Seek expert help.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq8" id="IFeq8"/><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>8</m:mn></m:math>&#160;(<a class="rout" href="../D02/d02xkf.xml">D02XKF</a>)</dt>
<dd>
<div class="paramtext">A serious error has occurred in an internal call to the specified routine.  Check all subroutine calls and array dimensions.  Seek expert help.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq9" id="IFeq9"/><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>9</m:mn></m:math></dt>
<dd>
<div class="paramtext">A serious error has occurred in an internal call to an interpolation routine. Check all (sub)program calls and array dimensions. Seek expert help.</div></dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">The accuracy of the computation of the solution vector <a class="arg" href="#Y">Y</a> may be controlled by varying the local error tolerance <a class="arg" href="#TOL">TOL</a>.  In general, a decrease in local error tolerance should lead to an increase in accuracy.  You are advised to choose <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RELABS"><m:mi mathcolor="#EE0000" mathvariant="bold">RELABS</m:mi></m:maction><m:mo>=</m:mo><m:mtext>'R'</m:mtext></m:math>&#160;unless you have a good reason for a different choice.  It is particularly appropriate if the solution decays.</div><div class="paramtext">If the problem is a root-finding one, then the accuracy of the root determined will depend strongly on <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mo>&#8706;</m:mo><m:mi>g</m:mi></m:mrow>
  <m:mrow><m:mo>&#8706;</m:mo><m:mi>x</m:mi></m:mrow>
 </m:mfrac>
</m:math>&#160;and <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mo>&#8706;</m:mo><m:mi>g</m:mi></m:mrow>
  <m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:mrow>
 </m:mfrac>
</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>.  Large values for these quantities may imply large errors in the root.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">If more than one root is required, then to determine the second and later roots D02EJF may be called again starting a short distance past the previously determined roots.  Alternatively you may construct your own root-finding code using <a class="rout" href="../D02/d02nbf.xml">D02NBF</a> (and other routines in <a class="chap" href="../D02/d02conts.xml">sub-chapter D02M&#8211;N</a>), <a class="rout" href="../C05/c05azf.xml">C05AZF</a> and <a class="rout" href="../D02/d02xkf.xml">D02XKF</a>.
</div><div class="paramtext">If it is easy to code, you should supply <a class="arg" href="#PEDERV">PEDERV</a>.  However, it is important to be aware that if <a class="arg" href="#PEDERV">PEDERV</a> is coded incorrectly, a very inefficient integration may result and possibly even a failure to complete the integration (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="#IFeq2"><m:mn mathcolor="#003399" mathvariant="bold">2</m:mn></m:maction></m:math>).</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">We illustrate the solution of five different problems.  In each case the differential system is the well-known stiff Robertson problem.

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mtable columnalign="left center right left">
 <m:mtr>
  <m:mtd><m:msup><m:mi>a</m:mi><m:mo>&#8242;</m:mo></m:msup></m:mtd>
  <m:mtd><m:mo>=</m:mo></m:mtd>
  <m:mtd><m:mrow><m:mo>-</m:mo><m:mn>0.04</m:mn></m:mrow><m:mi>a</m:mi><m:mo>+</m:mo><m:msup><m:mn>10</m:mn><m:mn>4</m:mn></m:msup><m:mi>b</m:mi><m:mi>c</m:mi></m:mtd>
  <m:mtd/>
 </m:mtr><m:mtr>
  <m:mtd><m:msup><m:mi>b</m:mi><m:mo>&#8242;</m:mo></m:msup></m:mtd>
  <m:mtd><m:mo>=</m:mo></m:mtd>
  <m:mtd><m:mn>0.04</m:mn><m:mi>a</m:mi><m:mo>-</m:mo><m:msup><m:mn>10</m:mn><m:mn>4</m:mn></m:msup><m:mi>b</m:mi><m:mi>c</m:mi></m:mtd>
  <m:mtd><m:mrow><m:mo>-</m:mo><m:mn>3</m:mn></m:mrow><m:mo>&#215;</m:mo><m:msup><m:mn>10</m:mn><m:mn>7</m:mn></m:msup><m:msup><m:mi>b</m:mi><m:mn>2</m:mn></m:msup></m:mtd>
 </m:mtr><m:mtr>
  <m:mtd><m:msup><m:mi>c</m:mi><m:mo>&#8242;</m:mo></m:msup></m:mtd>
  <m:mtd><m:mo>=</m:mo></m:mtd>
  <m:mtd/>
  <m:mtd><m:mphantom><m:mo>-</m:mo></m:mphantom><m:mn>3</m:mn><m:mo>&#215;</m:mo><m:msup><m:mn>10</m:mn><m:mn>7</m:mn></m:msup><m:msup><m:mi>b</m:mi><m:mn>2</m:mn></m:msup></m:mtd>
 </m:mtr>
</m:mtable>
</m:math></td><td class="formula2"/></tr></table></div>

with initial conditions <m:math><m:mi>a</m:mi><m:mo>=</m:mo><m:mn>1.0</m:mn></m:math>, <m:math><m:mi>b</m:mi><m:mo>=</m:mo><m:mi>c</m:mi><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>&#160;at <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>.  We solve each of the following problems with local error tolerances <m:math><m:mtext>1.0D&#8722;3</m:mtext></m:math>&#160;and <m:math><m:mtext>1.0D&#8722;4</m:mtext></m:math>.
<table class="standard-100"><tr>
<td style="width:2.1em;" valign="baseline"><a name="item1" id="item1"/>(i)</td>
<td valign="top">To integrate to <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:mn>10.0</m:mn></m:math>&#160;producing output at intervals of <m:math><m:mn>2.0</m:mn></m:math>&#160;until a point is encountered where <m:math><m:mi>a</m:mi><m:mo>=</m:mo><m:mn>0.9</m:mn></m:math>.  The  Jacobian is calculated numerically.</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="item2" id="item2"/>(ii)</td>
<td valign="top">As <a class="item" href="#item1">(i)</a> but with the Jacobian calculated analytically.</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="item3" id="item3"/>(iii)</td>
<td valign="top">As <a class="item" href="#item1">(i)</a> but with no intermediate output.</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="item4" id="item4"/>(iv)</td>
<td valign="top">As <a class="item" href="#item1">(i)</a> but with no termination on a root-finding condition.</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline"><a name="item5" id="item5"/>(v)</td>
<td valign="top">Integrating the equations as in <a class="item" href="#item1">(i)</a> but with no intermediate output and no root-finding termination condition.</td>
</tr></table>
</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/d02ejfe.f">Program Text (d02ejfe.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/d02ejfe.r">Program Results (d02ejfe.r)</a></p><div class="figure"><a name="d02ejf-plot" id="d02ejf-plot"/><img src="../figures/d02ejf-plot.png" alt="Example Program Plot for d02ejf-plot"/></div><hr/><div><a class="rout" href="../../pdf/D02/d02ejf.pdf">D02EJF (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>
