<?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>D02PDF : 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/d02pdf.pdf">D02PDF (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/>D02PDF</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">D02PDF is a one-step routine for solving an initial value problem for a first-order system of ordinary differential equations using Runge&#8211;Kutta methods.</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;D02PDF&#160;(</td><td class="tdfspec2"><a class="arg" href="#F">F</a>, <a class="arg" href="#TNOW">TNOW</a>, <a class="arg" href="#YNOW">YNOW</a>, <a class="arg" href="#YPNOW">YPNOW</a>, <a class="arg" href="#WORK">WORK</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">TNOW, YNOW(*), YPNOW(*), WORK(*)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">F</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D02PDF and its associated routines 
(<a class="rout" href="../D02/d02pvf.xml">D02PVF</a>, <a class="rout" href="../D02/d02pwf.xml">D02PWF</a>, <a class="rout" href="../D02/d02pxf.xml">D02PXF</a>, <a class="rout" href="../D02/d02pyf.xml">D02PYF</a> and <a class="rout" href="../D02/d02pzf.xml">D02PZF</a>)
 
solve an initial value problem for a first-order system of ordinary differential equations.  The routines, based on Runge&#8211;Kutta methods and derived from RKSUITE (see <a class="ref" href="#ref477">Brankin <span class="italic">et al.</span> (1991)</a>), integrate

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<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>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mtext>&#8195; given &#8195;</m:mtext><m:mi>y</m:mi><m:mfenced separators=""><m:msub><m:mi>t</m:mi><m:mn>0</m:mn></m:msub></m:mfenced><m:mo>=</m:mo><m:msub><m:mi>y</m:mi><m:mn>0</m:mn></m:msub>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:mi>y</m:mi></m:math>&#160;is the vector of 
<m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;solution components and <m:math><m:mi>t</m:mi></m:math>&#160;is the independent variable.</div><div class="paramtext">D02PDF is designed to be used in complicated tasks when solving systems of ordinary differential equations.  You must first call <a class="rout" href="../D02/d02pvf.xml">D02PVF</a> to specify the problem and how it is to be solved.  Thereafter you (repeatedly) call D02PDF to take one integration step at a time from <a class="arg" href="../D02/d02pvf.xml#TSTART">TSTART</a> in the direction of <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a>  (as specified in <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>).  In this manner D02PDF returns an approximation to the solution <a class="arg" href="#YNOW">YNOW</a> and its derivative <a class="arg" href="#YPNOW">YPNOW</a> at successive points <a class="arg" href="#TNOW">TNOW</a>.  If D02PDF encounters some difficulty in taking a step, the integration is not advanced and the routine returns with the same values of <a class="arg" href="#TNOW">TNOW</a>, <a class="arg" href="#YNOW">YNOW</a> and <a class="arg" href="#YPNOW">YPNOW</a> as returned on the previous successful step.  D02PDF tries to advance the integration as far as possible subject to passing the test on the local error and not going past <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a>.</div><div class="paramtext">In the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a> you can specify either the first step size for D02PDF to attempt or that it compute automatically an appropriate value.  Thereafter D02PDF estimates an appropriate step size for its next step.  This value and other details of the integration can be obtained after any call to D02PDF by a call to <a class="rout" href="../D02/d02pyf.xml">D02PYF</a>.  The local error is controlled at every step as specified in <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.  If you wish to assess the true error, you must set 
<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#ERRASS"><m:mi mathcolor="#EE0000" mathvariant="bold">ERRASS</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>&#160;in the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.  This assessment can be obtained after any call to D02PDF by a call to <a class="rout" href="../D02/d02pzf.xml">D02PZF</a>.</div><div class="paramtext">If you want answers at specific points there are two ways to proceed:
<table class="standard-100"><tr>
<td style="width:2.1em;" valign="baseline">(i)</td>
<td valign="top">The more efficient way is to step past the point where a solution is desired,  and then call <a class="rout" href="../D02/d02pxf.xml">D02PXF</a> to get an answer there.  Within the span of the current step, you can get all the answers you want at very little cost by repeated calls to <a class="rout" href="../D02/d02pxf.xml">D02PXF</a>.  This is very valuable when you want to find where something happens, e.g., where a particular solution component vanishes.  You cannot proceed in this way with 
<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>.

</td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(ii)</td>
<td valign="top">The other way to get an answer at a specific point is to set <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a> to this value and integrate to <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a>.  D02PDF will not step past <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a>, so when a step would carry it past, it will reduce the step size so as to produce an answer at <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a> exactly.  After getting an answer there (<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TNOW"><m:mi mathcolor="#EE0000" mathvariant="bold">TNOW</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#TEND"><m:mi mathcolor="#EE0000" mathvariant="bold">TEND</m:mi></m:maction></m:math>), you can reset <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a> to the next point where you want an answer, and repeat.  <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a> could be reset by a call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>, but you should not do this.  You should use <a class="rout" href="../D02/d02pwf.xml">D02PWF</a> instead because it is both easier to use and much more efficient.  This way of getting answers at specific points can be used with any of the available methods, but it is the only way with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>.

It can be inefficient.  Should this be the case, the code will bring the matter to your attention.</td>
</tr></table>
</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref477" id="ref477"/>Brankin R W, Gladwell I and Shampine L F (1991)  RKSUITE: A suite of Runge&#8211;Kutta codes for the initial value problems for ODEs <i>SoftReport 91-S1</i> Southern Methodist University </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="F" id="F"/>1: &#160;&#160;&#8194; F &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#F">F</a> must evaluate the functions <m:math><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;(that is the first 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 the arguments <m:math><m:mi>t</m:mi></m:math>, <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#F">F</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;F&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02pdf.xml#F_T">T</a>, <a class="arg" href="../D02/d02pdf.xml#F_Y">Y</a>, <a class="arg" href="../D02/d02pdf.xml#F_YP">YP</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">T, Y(<m:math><m:mi mathvariant="italic">n</m:mi></m:math>), YP(<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="../D02/d02pvf.xml#NEQ">NEQ</a> in the call of D02PDF.</div>
<dl><dt class="paramhead"><a name="F_T" id="F_T"/>1: &#160;&#160;&#8194; T &#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>t</m:mi></m:math>, the current value of the independent variable.</div></dd><dt class="paramhead"><a name="F_Y" id="F_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>: the current values of the dependent variables, <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>.</div></dd><dt class="paramhead"><a name="F_YP" id="F_YP"/>3: &#160;&#160;&#8194; YP(<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 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="#F">F</a> must be declared as EXTERNAL in the (sub)program from which D02PDF 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="TNOW" id="TNOW"/>2: &#160;&#160;&#8194; TNOW &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: <m:math><m:mi>t</m:mi></m:math>, the value of the independent variable at which a solution has been computed.</div></dd><dt class="paramhead"><a name="YNOW" id="YNOW"/>3: &#160;&#160;&#8194; YNOW(<m:math><m:mo>*</m:mo></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="#YNOW">YNOW</a>
must be at least
<m:math><m:mi mathvariant="italic">n</m:mi></m:math>.</div>
<div class="paramtext"><i>On exit</i>: an approximation to the solution at <a class="arg" href="#TNOW">TNOW</a>. The local error of the step to <a class="arg" href="#TNOW">TNOW</a> was no greater than permitted by the specified tolerances (see <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>).</div></dd><dt class="paramhead"><a name="YPNOW" id="YPNOW"/>4: &#160;&#160;&#8194; YPNOW(<m:math><m:mo>*</m:mo></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="#YPNOW">YPNOW</a>
must be at least
<m:math><m:mi mathvariant="italic">n</m:mi></m:math>.</div>
<div class="paramtext"><i>On exit</i>: an approximation to the derivative of the solution at <a class="arg" href="#TNOW">TNOW</a>.</div></dd><dt class="paramhead"><a name="WORK" id="WORK"/>5: &#160;&#160;&#8194; WORK(<m:math><m:mo>*</m:mo></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><b>Note:</b> the dimension of the array <a class="arg" href="#WORK">WORK</a>
must be at least
<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#LENWRK"><m:mi mathcolor="#EE0000" mathvariant="bold">LENWRK</m:mi></m:maction></m:math>&#160;(see <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>).</div>
<div class="paramtext"><i>On entry</i>: this <b>must</b> be the same array as supplied to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>. It <b>must</b> remain unchanged between calls.</div>
<div class="paramtext"><i>On exit</i>: information about the integration for use on subsequent calls to D02PDF or other associated routines.</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>6: &#160;&#160;&#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, because for this routine the values of the output parameters may be useful even 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>&#8800;</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;on exit, the recommended value is <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></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>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">On entry, an invalid call to D02PDF was made, for example without a previous call to the setup routine <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.  You cannot continue integrating the problem.</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">D02PDF is being used inefficiently because the step size has been reduced drastically many times to obtain answers at many points <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a>.  If you really need the solution at this many points, you should use <a class="rout" href="../D02/d02pxf.xml">D02PXF</a> to obtain the answers inexpensively.  If you need to change from <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>&#160;to do this, restart the integration from <a class="arg" href="#TNOW">TNOW</a>, <a class="arg" href="#YNOW">YNOW</a> by a call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.  If you wish to continue as before, call D02PDF again.  The monitor of this kind of inefficiency will be reset automatically so that the integration can proceed.</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 considerable amount of work has been expended in the (primary) integration.  This is measured by counting the number of calls to <a class="arg" href="#F">F</a>.  At least <m:math><m:mn>5000</m:mn></m:math>&#160;calls have been made since the last time this counter was reset.  Calls to <a class="arg" href="#F">F</a> in a secondary integration for global error assessment (when <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#ERRASS"><m:mi mathcolor="#EE0000" mathvariant="bold">ERRASS</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>&#160;in the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>) are not counted in this total.  The integration was interrupted.  If you wish to continue on towards <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a>, just call D02PDF again.  The counter measuring work will be reset to zero automatically.</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">It appears that this problem is stiff.  The methods implemented in D02PDF can solve such problems, but they are inefficient.  You should change to another code based on methods appropriate for stiff problems.  The integration was interrupted.  If you want to continue on towards <a class="arg" href="../D02/d02pvf.xml#TEND">TEND</a>, just call D02PDF again.  The stiffness monitor will be reset automatically.</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">It does not appear possible to achieve the accuracy specified by <a class="arg" href="../D02/d02pvf.xml#TOL">TOL</a> and <a class="arg" href="../D02/d02pvf.xml#THRES">THRES</a> in the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a> with the precision available on the computer being used and with this value of <a class="arg" href="../D02/d02pvf.xml#METHOD">METHOD</a>.  You cannot continue integrating this problem.  A larger value for <a class="arg" href="../D02/d02pvf.xml#METHOD">METHOD</a>, if possible, will permit greater accuracy with this precision.  To increase <a class="arg" href="../D02/d02pvf.xml#METHOD">METHOD</a> and/or continue with larger values of <a class="arg" href="../D02/d02pvf.xml#TOL">TOL</a> and/or <a class="arg" href="../D02/d02pvf.xml#THRES">THRES</a>, restart the integration from <a class="arg" href="#TNOW">TNOW</a>, <a class="arg" href="#YNOW">YNOW</a> by a call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</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">(This error exit can only occur if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#ERRASS"><m:mi mathcolor="#EE0000" mathvariant="bold">ERRASS</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>&#160;in the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.)  The global error assessment may not be reliable beyond the current integration point <a class="arg" href="#TNOW">TNOW</a>.  This may occur because either too little or too much accuracy has been requested or because <m:math><m:mi>f</m:mi><m:mfenced separators=""><m:mi>t</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;is not smooth enough for values of <m:math><m:mi>t</m:mi></m:math>&#160;just beyond <a class="arg" href="#TNOW">TNOW</a> and current values of the solution <m:math><m:mi>y</m:mi></m:math>.  The integration cannot be continued.  This return does not mean that you cannot integrate past <a class="arg" href="#TNOW">TNOW</a>, rather that you cannot do it with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#ERRASS"><m:mi mathcolor="#EE0000" mathvariant="bold">ERRASS</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>.  However, it may also indicate problems with the primary integration.</div>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">The accuracy of integration is determined by the parameters <a class="arg" href="../D02/d02pvf.xml#TOL">TOL</a> and <a class="arg" href="../D02/d02pvf.xml#THRES">THRES</a> in a prior call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.  Note that only the local error at each step is controlled by these parameters.  The error estimates obtained are not strict bounds but are usually reliable over one step.  Over a number of steps the overall error may accumulate in various ways, depending on the properties of the differential system.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">If D02PDF returns with <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>&#160;and the accuracy specified by <a class="arg" href="../D02/d02pvf.xml#TOL">TOL</a> and <a class="arg" href="../D02/d02pvf.xml#THRES">THRES</a> is really required then you should consider whether there is a more fundamental difficulty.  For example, the solution may contain a singularity.  In such a region the solution components will usually be large in magnitude.  Successive output values of <a class="arg" href="#YNOW">YNOW</a> should be monitored with the aim of trapping the solution before the singularity.  In any case numerical integration cannot be continued through a singularity, and analytical treatment may be necessary.</div><div class="paramtext">Performance statistics are available after any return from D02PDF  (except when <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="#IFeq1"><m:mn mathcolor="#003399" mathvariant="bold">1</m:mn></m:maction></m:math>) by a call to <a class="rout" href="../D02/d02pyf.xml">D02PYF</a>.  If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#ERRASS"><m:mi mathcolor="#EE0000" mathvariant="bold">ERRASS</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>&#160;in the call to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>, global error assessment is available after any return from D02PDF (except when <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="#IFeq1"><m:mn mathcolor="#003399" mathvariant="bold">1</m:mn></m:maction></m:math>) by a call to <a class="rout" href="../D02/d02pzf.xml">D02PZF</a>.</div><div class="paramtext">After a failure with <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>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq6"><m:mn mathcolor="#003399" mathvariant="bold">6</m:mn></m:maction></m:math>&#160;the diagnostic 
routines <a class="rout" href="../D02/d02pyf.xml">D02PYF</a> and <a class="rout" href="../D02/d02pzf.xml">D02PZF</a>

may be called only once.</div><div class="paramtext">If D02PDF returns with <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;then it is advisable to change to another code more suited to the solution of stiff problems.  D02PDF will not return with <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;if the problem is actually stiff but it is estimated that integration can be completed using less function evaluations than already computed.</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example solves the 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:mo>-</m:mo><m:mi>y</m:mi>
 <m:mtext>, &#8195;</m:mtext>
 <m:mi>y</m:mi><m:mfenced separators=""><m:mn>0</m:mn></m:mfenced>
 <m:mo>=</m:mo>
 <m:mn>0</m:mn>
 <m:mtext>, &#8195;</m:mtext>
 <m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mfenced separators=""><m:mn>0</m:mn></m:mfenced>
 <m:mo>=</m:mo>
 <m:mn>1</m:mn>
</m:math></td><td class="formula2"/></tr></table></div>

reposed as

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:msubsup><m:mi>y</m:mi><m:mn>1</m:mn><m:mo>&#8242;</m:mo></m:msubsup>
 <m:mo>=</m:mo>
 <m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub>
</m:math></td><td class="formula2"/></tr></table></div><div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:msubsup><m:mi>y</m:mi><m:mn>2</m:mn><m:mo>&#8242;</m:mo></m:msubsup>
 <m:mo>=</m:mo>
 <m:mo>-</m:mo><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub>
</m:math></td><td class="formula2"/></tr></table></div>

over the range <m:math>
 <m:mfenced separators="" open="[" close="]"><m:mn>0</m:mn><m:mo>,</m:mo><m:mrow><m:mn>2</m:mn><m:mi>&#960;</m:mi></m:mrow></m:mfenced>
</m:math>&#160;with initial conditions <m:math>
 <m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub>
 <m:mo>=</m:mo>
 <m:mn>0.0</m:mn>
</m:math>&#160;and <m:math>
 <m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub>
 <m:mo>=</m:mo>
 <m:mn>1.0</m:mn>
</m:math>.  We use relative error control with threshold values of <m:math>
 <m:mtext>1.0D&#8722;8</m:mtext>
</m:math>&#160;for each solution component and print the solution at each integration step across the range.  We use a medium order Runge&#8211;Kutta method 
(<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math>)

with tolerances <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>=</m:mo><m:mtext>1.0D&#8722;4</m:mtext></m:math>&#160;and <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="../D02/d02pvf.xml#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>=</m:mo><m:mtext>1.0D&#8722;5</m:mtext></m:math>&#160;in turn so that we may compare the solutions.  The value of <m:math><m:mi>&#960;</m:mi></m:math>&#160;is obtained by using <a class="rout" href="../X01/x01aaf.xml">X01AAF</a>.</div><div class="paramtext">Note that the length of <a class="arg" href="#WORK">WORK</a> is large enough for any valid combination of input arguments to <a class="rout" href="../D02/d02pvf.xml">D02PVF</a>.</div><div class="paramtext">See also the example programs for <a class="rout" href="../D02/d02pwf.xml">D02PWF</a> and <a class="rout" href="../D02/d02pxf.xml">D02PXF</a>.</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/d02pdfe.f">Program Text (d02pdfe.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/d02pdfe.r">Program Results (d02pdfe.r)</a></p><div class="figure"><a name="d02pdf-plot" id="d02pdf-plot"/><img src="../figures/d02pdf-plot.png" alt="Example Program Plot for d02pdf-plot"/></div><hr/><div><a class="rout" href="../../pdf/D02/d02pdf.pdf">D02PDF (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>
