<?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>D02GAF : 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/d02gaf.pdf">D02GAF (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/>D02GAF</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">D02GAF solves a two-point boundary value problem with assigned boundary values for a system of ordinary differential equations, using a deferred correction technique and a Newton iteration.</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;D02GAF&#160;(</td><td class="tdfspec2"><a class="arg" href="#U">U</a>, <a class="arg" href="#V">V</a>, <a class="arg" href="#N">N</a>, <a class="arg" href="#A">A</a>, <a class="arg" href="#B">B</a>, <a class="arg" href="#TOL">TOL</a>, <a class="arg" href="#FCN">FCN</a>, <a class="arg" href="#MNP">MNP</a>, <a class="arg" href="#X">X</a>, <a class="arg" href="#Y">Y</a>, <a class="arg" href="#NP">NP</a>, <a class="arg" href="#W">W</a>, <a class="arg" href="#LW">LW</a>, <a class="arg" href="#IW">IW</a>, <a class="arg" href="#LIW">LIW</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N, MNP, NP, LW, IW(LIW), LIW, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">U(N,2), V(N,2), A, B, TOL, X(MNP), Y(N,MNP), W(LW)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">FCN</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D02GAF solves a two-point boundary value problem for a system of <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;differential equations in the interval  [<m:math><m:mi>a</m:mi><m:mo>,</m:mo><m:mi>b</m:mi></m:math>].  The system is written in the form:

<div class="formula-eqn"><a name="eqn1" id="eqn1"/><table class="formula-eqn"><tr><td class="formula-eqn"><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:math></td><td class="formula-eqn2">
      (1)
     </td></tr></table></div>

and the derivatives <m:math><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;are evaluated by <a class="arg" href="#FCN">FCN</a>.  Initially, <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;boundary values of the variables <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;must be specified, some at <m:math><m:mi>a</m:mi></m:math>&#160;and some at <m:math><m:mi>b</m:mi></m:math>.  You must supply estimates of the remaining <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;boundary values and all the boundary values are used in constructing an initial approximation to the solution.  This approximate solution is corrected by a finite-difference technique with deferred correction allied with a Newton iteration to solve the finite-difference equations.  The technique used is described fully in <a class="ref" href="#ref189">Pereyra (1979)</a>.  The Newton iteration requires a Jacobian matrix <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>&#160;and this is calculated by numerical differentiation using an algorithm described in <a class="ref" href="#ref190">Curtis <span class="italic">et al.</span> (1974)</a>.</div><div class="paramtext">You supply an absolute error tolerance and may also supply an initial mesh for the construction of the finite-difference equations (alternatively a default mesh is used).  The algorithm constructs a solution on a mesh defined by adding points to the initial mesh.  This solution is chosen so that the error is everywhere less than your tolerance and so that the error is approximately equidistributed on the final mesh.  The solution is returned on this final mesh.</div><div class="paramtext">If the solution is required at a few specific points then these should be included in the initial mesh.  If on the other hand the solution is required at several specific points then you should use the interpolation routines provided in <a class="chap" href="../E01/e01conts.xml">Chapter E01</a> if these points do not themselves form a convenient mesh.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref190" id="ref190"/>Curtis A R, Powell M J D and Reid J K (1974)  On the estimation of sparse Jacobian matrices <i>J. Inst. Maths. Applics.</i> <b>13</b> 117&#8211;119 </div>
<div class="paramtext"><a name="ref189" id="ref189"/>Pereyra V (1979)  PASVA3: An adaptive finite-difference Fortran program for first order nonlinear, ordinary boundary problems <i>Codes for Boundary Value Problems in Ordinary Differential Equations. Lecture Notes in Computer Science</i> (eds B Childs, M Scott, J W Daniel, E Denman and P Nelson) <b>76</b> Springer&#8211;Verlag </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="U" id="U"/>1: &#160;&#160;&#8194; U(<a class="arg" href="#N">N</a>,<m:math><m:mn>2</m:mn></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#U"><m:mi mathcolor="#EE0000" mathvariant="bold">U</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>&#160;must be set to the known or estimated value of <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;at <m:math><m:mi>a</m:mi></m:math>&#160;and <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#U"><m:mi mathcolor="#EE0000" mathvariant="bold">U</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mn>2</m:mn></m:mfenced></m:mrow></m:math>&#160;must be set to the known or estimated value of <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;at <m:math><m:mi>b</m:mi></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="V" id="V"/>2: &#160;&#160;&#8194; V(<a class="arg" href="#N">N</a>,<m:math><m:mn>2</m:mn></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#V"><m:mi mathcolor="#EE0000" mathvariant="bold">V</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mi>j</m:mi></m:mfenced></m:mrow></m:math>&#160;must be set to <m:math><m:mn>0.0</m:mn></m:math>&#160;if <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#U"><m:mi mathcolor="#EE0000" mathvariant="bold">U</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mi>j</m:mi></m:mfenced></m:mrow></m:math>&#160;is a known value and to <m:math><m:mn>1.0</m:mn></m:math>&#160;if <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#U"><m:mi mathcolor="#EE0000" mathvariant="bold">U</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mi>j</m:mi></m:mfenced></m:mrow></m:math>&#160;is an estimated value, 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>&#160;and <m:math><m:mi>j</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn></m:math>.</div><div class="paramtext"><i>Constraint</i>:
  

precisely <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;of the <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#V"><m:mi mathcolor="#EE0000" mathvariant="bold">V</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mi>j</m:mi></m:mfenced></m:mrow></m:math>&#160;must be set to <m:math><m:mn>0.0</m:mn></m:math>, i.e., precisely <m:math><m:mi mathvariant="italic">n</m:mi></m:math>&#160;of the <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#U"><m:mi mathcolor="#EE0000" mathvariant="bold">U</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mi>j</m:mi></m:mfenced></m:mrow></m:math>&#160;must be known values, and these must not be all at <m:math><m:mi>a</m:mi></m:math>&#160;or all at <m:math><m:mi>b</m:mi></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 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>2</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="A" id="A"/>4: &#160;&#160;&#8194; A &#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>a</m:mi></m:math>, the left-hand boundary point.</div></dd><dt class="paramhead"><a name="B" id="B"/>5: &#160;&#160;&#8194; B &#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>b</m:mi></m:math>, the right-hand boundary point.</div>
<div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#B"><m:mi mathcolor="#EE0000" mathvariant="bold">B</m:mi></m:maction><m:mo>&gt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#A"><m:mi mathcolor="#EE0000" mathvariant="bold">A</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="TOL" id="TOL"/>6: &#160;&#160;&#8194; TOL &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: a positive absolute error tolerance. If 
<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block"> <m:mi>a</m:mi><m:mo>=</m:mo><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub><m:mo>&lt;</m:mo><m:msub><m:mi>x</m:mi><m:mn>2</m:mn></m:msub><m:mo>&lt;</m:mo><m:mo>&#8943;</m:mo><m:mo>&lt;</m:mo><m:msub><m:mi>x</m:mi><m:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction></m:msub><m:mo>=</m:mo><m:mi>b</m:mi> </m:math></td><td class="formula2"/></tr></table></div>
 is the final mesh, <m:math><m:msub><m:mi>z</m:mi><m:mi>j</m:mi></m:msub><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:mfenced></m:math>&#160;is the <m:math><m:mi>j</m:mi></m:math>th component of the approximate solution at <m:math><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:math>, and <m:math><m:msub><m:mi>y</m:mi><m:mi>j</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;is the <m:math><m:mi>j</m:mi></m:math>th component of the true solution of equation <a class="eqn" href="#eqn1">(1)</a> (see <a class="sec" href="#description">Section 3</a>) and the boundary conditions, then, except in extreme cases, it is expected that 
<div class="formula-eqn"><a name="eqn2" id="eqn2"/><table class="formula-eqn"><tr><td class="formula-eqn"><m:math display="block"> <m:mfenced open="|" close="|" separators=""><m:msub><m:mi>z</m:mi><m:mi>j</m:mi></m:msub><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:mfenced><m:mo>-</m:mo><m:msub><m:mi>y</m:mi><m:mi>j</m:mi></m:msub><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:mfenced></m:mfenced><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><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:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction><m:mtext>&#8203; and &#8203;</m:mtext><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:mtext>.</m:mtext> </m:math></td><td class="formula-eqn2">
      (2)
     </td></tr></table></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></dd><dt class="paramhead"><a name="FCN" id="FCN"/>7: &#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 <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi mathvariant="italic">n</m:mi></m:math>, at a general point <m:math><m:mi>x</m:mi></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/d02gaf.xml#FCN_X">X</a>, <a class="arg" href="../D02/d02gaf.xml#FCN_Y">Y</a>, <a class="arg" href="../D02/d02gaf.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 actual value of <a class="arg" href="#N">N</a> in the call of D02GAF.</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 argument.</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"><i>On entry</i>: <m:math><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:math>, the value of the argument, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi mathvariant="italic">n</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="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"><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="#FCN">FCN</a> must be declared as EXTERNAL in the (sub)program from which D02GAF 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="MNP" id="MNP"/>8: &#160;&#160;&#8194; MNP &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 

the maximum permitted number of mesh points.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MNP"><m:mi mathcolor="#EE0000" mathvariant="bold">MNP</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>32</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="X" id="X"/>9: &#160;&#160;&#8194; X(<a class="arg" href="#MNP">MNP</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>4</m:mn></m:math>&#160;(see <a class="arg" href="#NP">NP</a>), the first <a class="arg" href="#NP">NP</a> elements must define an initial mesh. Otherwise the elements of <a class="arg" href="#X">X</a> need not be set.</div><div class="paramtext"><i>Constraint</i>:
  
<div class="formula-eqn"><a name="eqn3" id="eqn3"/><table class="formula-eqn"><tr><td class="formula-eqn"><m:math display="block"> <m:maction actiontype="link" dsi:type="simple" dsi:href="#A"><m:mi mathcolor="#EE0000" mathvariant="bold">A</m:mi></m:maction><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>&lt;</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>&lt;</m:mo><m:mo>&#8943;</m:mo><m:mo>&lt;</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction></m:mfenced></m:mrow><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#B"><m:mi mathcolor="#EE0000" mathvariant="bold">B</m:mi></m:maction><m:mtext>, &#8195;</m:mtext> <m:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>4</m:mn><m:mtext>.</m:mtext></m:math></td><td class="formula-eqn2">
      (3)
     </td></tr></table></div>
</div>
<div class="paramtext"><i>On exit</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</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="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</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="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction></m:mfenced></m:mrow></m:math>&#160;define the final mesh (with the returned value of <a class="arg" href="#NP">NP</a>) satisfying the relation <a class="eqn" href="#eqn3">(3)</a>.</div></dd><dt class="paramhead"><a name="Y" id="Y"/>10: &#8194; Y(<a class="arg" href="#N">N</a>,<a class="arg" href="#MNP">MNP</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the approximate solution <m:math><m:msub><m:mi>z</m:mi><m:mi>j</m:mi></m:msub><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:mfenced></m:math>&#160;satisfying <a class="eqn" href="#eqn2">(2)</a>, on the final mesh, that is 
<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block"> <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>j</m:mi><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>=</m:mo><m:msub><m:mi>z</m:mi><m:mi>j</m:mi></m:msub><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mi>i</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:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction><m:mtext>&#8203; and &#8203;</m:mtext><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:mtext>,</m:mtext> </m:math></td><td class="formula2"/></tr></table></div>
 where <a class="arg" href="#NP">NP</a> is the number of points in the final mesh.
<div class="paramtext">The remaining columns of <a class="arg" href="#Y">Y</a> are not used.</div>
</div></dd><dt class="paramhead"><a name="NP" id="NP"/>11: &#8194; NP &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: determines whether a default or user-supplied mesh is used. 

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math></dt>
<dd>A default value of <m:math><m:mn>4</m:mn></m:math>&#160;for <a class="arg" href="#NP">NP</a> and a corresponding equispaced mesh <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</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="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</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="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction></m:mfenced></m:mrow></m:math>&#160;are used.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>4</m:mn></m:math></dt>
<dd>You must define an initial mesh using the array <a class="arg" href="#X">X</a> as described.</dd></dl>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>&#160;or <m:math><m:mn>4</m:mn><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NP"><m:mi mathcolor="#EE0000" mathvariant="bold">NP</m:mi></m:maction><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#MNP"><m:mi mathcolor="#EE0000" mathvariant="bold">MNP</m:mi></m:maction></m:math>.
</div>
<div class="paramtext"><i>On exit</i>: the number of points in the final (returned) mesh.</div></dd><dt class="paramhead"><a name="W" id="W"/>12: &#8194; W(<a class="arg" href="#LW">LW</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="multi-paramhead"><a name="LW" id="LW"/>13: &#8194; LW &#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 D02GAF is called.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LW"><m:mi mathcolor="#EE0000" mathvariant="bold">LW</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#MNP"><m:mi mathcolor="#EE0000" mathvariant="bold">MNP</m:mi></m:maction><m:mo>&#215;</m:mo><m:mfenced separators=""><m:mn>3</m:mn><m:mo>&#8290;</m:mo><m:msup><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mn>2</m:mn></m:msup><m:mo>+</m:mo><m:mn>6</m:mn><m:mo>&#8290;</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>2</m:mn></m:mfenced><m:mo>+</m:mo><m:mn>4</m:mn><m:mo>&#8290;</m:mo><m:msup><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mn>2</m:mn></m:msup><m:mo>+</m:mo><m:mn>4</m:mn><m:mo>&#8290;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="IW" id="IW"/>14: &#8194; IW(<a class="arg" href="#LIW">LIW</a>) &#8211; INTEGER array<span class="pclass">Workspace</span></dt><dt class="multi-paramhead"><a name="LIW" id="LIW"/>15: &#8194; LIW &#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="#IW">IW</a> as declared in the (sub)program from which D02GAF is called.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LIW"><m:mi mathcolor="#EE0000" mathvariant="bold">LIW</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#MNP"><m:mi mathcolor="#EE0000" mathvariant="bold">MNP</m:mi></m:maction><m:mo>&#215;</m:mo><m:mfenced separators=""><m:mn>2</m:mn><m:mo>&#8290;</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>1</m:mn></m:mfenced><m:mo>+</m:mo><m:msup><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mn>2</m:mn></m:msup><m:mo>+</m:mo><m:mn>4</m:mn><m:mo>&#8290;</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>2</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>16: &#8194; IFAIL &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext">For this routine, the normal use of <a class="arg" href="#IFAIL">IFAIL</a> is extended to control the printing of error and warning messages as well as specifying hard or soft failure (see <a class="sec" href="../GENINT/essint.xml#library3">Section 3.3</a> in  the Essential Introduction).</div>
<div class="paramtext"><i>On entry</i>: <a class="arg" href="#IFAIL">IFAIL</a> must be set to a value with the decimal expansion <m:math><m:mi mathvariant="italic">cba</m:mi></m:math>, where each of the decimal digits <m:math><m:mi>c</m:mi></m:math>, <m:math><m:mi>b</m:mi></m:math>&#160;and <m:math><m:mi>a</m:mi></m:math>&#160;must have a value of <m:math><m:mn>0</m:mn></m:math>&#160;or <m:math><m:mn>1</m:mn></m:math>.
<table class="standard-90"><tr>
<td style="width:3.0em;" valign="baseline"><m:math><m:mi>a</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:math></td>
<td valign="top">specifies hard failure, otherwise soft failure;</td>
</tr><tr>
<td style="width:3.0em;" valign="baseline"><m:math><m:mi>b</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:math></td>
<td valign="top">suppresses error messages, otherwise error messages will be printed (see <a class="sec" href="#errors">Section 6</a>);</td>
</tr><tr>
<td style="width:3.0em;" valign="baseline"><m:math><m:mi>c</m:mi><m:mo>=</m:mo><m:mn>0</m:mn></m:math></td>
<td valign="top">suppresses warning messages, otherwise warning messages will be printed (see <a class="sec" href="#errors">Section 6</a>).</td>
</tr></table>
<div class="paramtext">The recommended value for inexperienced users is <m:math><m:mn>110</m:mn></m:math>&#160;(i.e., hard failure with all messages printed).</div>
</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></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">One or more of the parameters <a class="arg" href="#N">N</a>, <a class="arg" href="#TOL">TOL</a>, <a class="arg" href="#NP">NP</a>, <a class="arg" href="#MNP">MNP</a>, <a class="arg" href="#LW">LW</a> or <a class="arg" href="#LIW">LIW</a> has been incorrectly set, or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#B"><m:mi mathcolor="#EE0000" mathvariant="bold">B</m:mi></m:maction><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#A"><m:mi mathcolor="#EE0000" mathvariant="bold">A</m:mi></m:maction></m:math>, or the condition <a class="eqn" href="#eqn3">(3)</a> on <a class="arg" href="#X">X</a> is not satisfied, or the number of known boundary values (specified by <a class="arg" href="#V">V</a>) is not <a class="arg" href="#N">N</a>.</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">The Newton iteration has failed to converge.  This could be due to there being too few points in the initial mesh or to the initial approximate solution being too inaccurate.  If this latter reason is suspected you should use <a class="rout" href="../D02/d02raf.xml">D02RAF</a> instead.  If the warning &#8216;Jacobian matrix is singular&#8217; is printed this could be due to specifying zero estimated boundary values and these should be varied.  This warning could also be printed in the unlikely event of the Jacobian matrix being calculated inaccurately.  If you cannot make changes to prevent the warning then <a class="rout" href="../D02/d02raf.xml">D02RAF</a> should be used.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq3" id="IFeq3"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math></dt>
<dd>
<div class="paramtext">The Newton iteration has reached round-off level.  It could be, however, that the answer returned is satisfactory.  This error might occur if too much accuracy is requested.</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 finer mesh is required for the accuracy requested; that is <a class="arg" href="#MNP">MNP</a> is not large enough.</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 serious error has occurred in a call to D02GAF.  Check all array subscripts and subroutine parameter lists in calls to D02GAF.  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 solution returned by the routine will be accurate to your tolerance as defined by the relation <a class="eqn" href="#eqn2">(2)</a> except in extreme circumstances.  If too many points are specified in the initial mesh, the solution may be more accurate than requested and the error may not be approximately equidistributed.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The time taken by D02GAF depends on the difficulty of the problem, the number of mesh points (and meshes) used, the number of Newton iterations and the number of deferred corrections.</div><div class="paramtext">You are strongly recommended to set <a class="arg" href="#IFAIL">IFAIL</a> to obtain self-explanatory error messages, and also monitoring information about the course of the computation.  You may select the channel numbers on which this output is to appear by calls of <a class="rout" href="../X04/x04aaf.xml">X04AAF</a> (for error messages) or <a class="rout" href="../X04/x04abf.xml">X04ABF</a> (for monitoring information) &#8211; see <a class="sec" href="#example">Section 9</a> for an example.  Otherwise the default channel numbers will be used, as specified in the <a class="url" href="http://www.nag.co.uk/doc/inun/fl22.html">Users' Note</a>.</div><div class="paramtext">A common cause of convergence problems in the Newton iteration is that you have specified too few points in the initial mesh.  Although the routine adds points to the mesh to improve accuracy it is unable to do so until the solution on the initial mesh has been calculated in the Newton iteration.</div><div class="paramtext">If you specify zero known <b>and</b> estimated boundary values, the routine constructs a zero initial approximation and in many cases the Jacobian is singular when evaluated for this approximation, leading to the breakdown of the Newton iteration.</div><div class="paramtext">You may be unable to provide a sufficiently good choice of initial mesh and estimated boundary values, and hence the Newton iteration may never converge.  In this case the continuation facility provided in <a class="rout" href="../D02/d02raf.xml">D02RAF</a> is recommended.</div><div class="paramtext">In the case where you wish to solve a sequence of similar problems, the final mesh from solving one case is strongly recommended as the initial mesh for the next.</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example solves the differential equation

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:msup><m:mi>y</m:mi><m:mrow><m:mo>&#8242;</m:mo><m:mo>&#8242;</m:mo><m:mo>&#8242;</m:mo></m:mrow></m:msup><m:mo>=</m:mo><m:mo>-</m:mo><m:mi>y</m:mi><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:mi>&#946;</m:mi><m:mfenced separators=""><m:mn>1</m:mn><m:mo>-</m:mo><m:msup><m:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mn>2</m:mn></m:msup></m:mfenced>
</m:math></td><td class="formula2"/></tr></table></div>

with boundary conditions

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>y</m:mi><m:mfenced separators=""><m:mn>0</m:mn></m:mfenced><m:mo>=</m:mo><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>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>10</m:mn></m:mfenced><m:mo>=</m:mo><m:mn>1</m:mn>
</m:math></td><td class="formula2"/></tr></table></div>

for <m:math><m:mi>&#946;</m:mi><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>&#160;and <m:math><m:mi>&#946;</m:mi><m:mo>=</m:mo><m:mn>0.2</m:mn></m:math>&#160;to an accuracy specified by <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:mtext>1.0D&#8722;3</m:mtext></m:math>.  We solve first the simpler problem with <m:math><m:mi>&#946;</m:mi><m:mo>=</m:mo><m:mn>0.0</m:mn></m:math>&#160;using an equispaced mesh of <m:math><m:mn>26</m:mn></m:math>&#160;points and then we solve the problem with <m:math><m:mi>&#946;</m:mi><m:mo>=</m:mo><m:mn>0.2</m:mn></m:math>&#160;using the final mesh from the first problem.</div><div class="paramtext">Note the call to <a class="rout" href="../X04/x04abf.xml">X04ABF</a> prior to the call to D02GAF.</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/d02gafe.f">Program Text (d02gafe.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/d02gafe.r">Program Results (d02gafe.r)</a></p><div class="figure"><a name="d02gaf1-plot" id="d02gaf1-plot"/><img src="../figures/d02gaf1-plot.png" alt="Example Program Plot for d02gaf1-plot"/></div><div class="figure"><a name="d02gaf2-plot" id="d02gaf2-plot"/><img src="../figures/d02gaf2-plot.png" alt="Example Program Plot for d02gaf2-plot"/></div>
<hr/><div><a class="rout" href="../../pdf/D02/d02gaf.pdf">D02GAF (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>
