<?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>D02JAF : 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/d02jaf.pdf">D02JAF (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/>D02JAF</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">D02JAF solves a regular linear two-point boundary value problem for a single <m:math><m:mi>n</m:mi></m:math>th-order ordinary differential equation by Chebyshev series using collocation and least-squares.</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;D02JAF&#160;(</td><td class="tdfspec2"><a class="arg" href="#N">N</a>, <a class="arg" href="#CF">CF</a>, <a class="arg" href="#BC">BC</a>, <a class="arg" href="#X0">X0</a>, <a class="arg" href="#X1">X1</a>, <a class="arg" href="#K1">K1</a>, <a class="arg" href="#KP">KP</a>, <a class="arg" href="#C">C</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="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N, K1, KP, LW, IW(K1), IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">CF, X0, X1, C(K1), W(LW)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">CF, BC</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D02JAF calculates the solution of a regular two-point boundary value problem for a single <m:math><m:mi>n</m:mi></m:math>th-order linear ordinary differential equation as a Chebyshev series in the interval <m:math><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:mfenced></m:math>.  The differential equation

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:msub><m:mi>f</m:mi><m:mrow><m:mi>n</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:msup><m:mi>y</m:mi>
<m:mfenced separators=""><m:mi>n</m:mi></m:mfenced>
</m:msup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>+</m:mo><m:msub><m:mi>f</m:mi><m:mi>n</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:msup><m:mi>y</m:mi>
<m:mfenced separators=""><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced>
</m:msup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>+</m:mo><m:mo>&#8943;</m:mo><m:mo>+</m:mo><m:msub><m:mi>f</m:mi><m:mn>1</m:mn></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mi>y</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>=</m:mo><m:msub><m:mi>f</m:mi><m:mn>0</m:mn></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced>
</m:math></td><td class="formula2"/></tr></table></div>

is defined by <a class="arg" href="#CF">CF</a>, and the boundary conditions at the points <m:math><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;are defined by <a class="arg" href="#BC">BC</a>.</div><div class="paramtext">You specify the degree of Chebyshev series required, <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:math>, and the number of collocation points, <a class="arg" href="#KP">KP</a>.  The routine sets up a system of linear equations for the Chebyshev coefficients, one equation for each collocation point and one for each boundary condition.  The boundary conditions are solved exactly, and the remaining equations are then solved by a least-squares method.  The result produced is a set of coefficients for a Chebyshev series solution of the differential equation on an interval normalized to <m:math><m:mfenced separators=""><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mo>,</m:mo><m:mn>1</m:mn></m:mfenced></m:math>.</div><div class="paramtext"><a class="rout" href="../E02/e02akf.xml">E02AKF</a> can be used to evaluate the solution at any point on the interval <m:math><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:mfenced></m:math>&#160;&#8211; see <a class="sec" href="#example">Section 9</a> for an example.  <a class="rout" href="../E02/e02ahf.xml">E02AHF</a> followed by <a class="rout" href="../E02/e02akf.xml">E02AKF</a> can be used to evaluate its derivatives.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref287" id="ref287"/>Picken S M (1970)  Algorithms for the solution of differential equations in Chebyshev-series by the selected points method <i>Report Math. 94</i> National Physical Laboratory </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="N" id="N"/>1: &#160;&#160;&#8194; N &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <m:math><m:mi>n</m:mi></m:math>, the order of the differential equation.</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="CF" id="CF"/>2: &#160;&#160;&#8194; CF &#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="#CF">CF</a> defines the differential equation (see <a class="sec" href="#description">Section 3</a>). It must return the value of a function <m:math><m:msub><m:mi>f</m:mi><m:mi>j</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;at a given point <m:math><m:mi>x</m:mi></m:math>, where, for <m:math><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:mi>j</m:mi><m:mo>&#8804;</m:mo><m:mi>n</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:math>, <m:math><m:msub><m:mi>f</m:mi><m:mi>j</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;is the coefficient of <m:math><m:msup><m:mi>y</m:mi> <m:mfenced separators=""><m:mi>j</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced> </m:msup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;in the equation, and <m:math><m:msub><m:mi>f</m:mi><m:mn>0</m:mn></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;is the right-hand side.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#CF">CF</a> is:</div><table class="fspec"><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b>&#160;FUNCTION&#160;CF&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02jaf.xml#CF_J">J</a>, <a class="arg" href="../D02/d02jaf.xml#CF_X">X</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">J</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X</td></tr></table>
<dl><dt class="paramhead"><a name="CF_J" id="CF_J"/>1: &#160;&#160;&#8194; J &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the index of the function <m:math><m:msub><m:mi>f</m:mi><m:mi>j</m:mi></m:msub></m:math>&#160;to be evaluated.</div></dd><dt class="paramhead"><a name="CF_X" id="CF_X"/>2: &#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>: the point at which <m:math><m:msub><m:mi>f</m:mi><m:mi>j</m:mi></m:msub></m:math>&#160;is to be evaluated.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#CF">CF</a> must be declared as EXTERNAL in the (sub)program from which D02JAF 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="BC" id="BC"/>3: &#160;&#160;&#8194; BC &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#BC">BC</a> defines the boundary conditions, each of which has the form <m:math><m:msup><m:mi>y</m:mi> <m:mfenced separators=""><m:mi>k</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced></m:msup><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:mfenced><m:mo>=</m:mo><m:msub><m:mi>s</m:mi><m:mi>k</m:mi></m:msub></m:math>&#160;or <m:math><m:msup><m:mi>y</m:mi><m:mfenced separators=""><m:mi>k</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced></m:msup><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:mfenced><m:mo>=</m:mo><m:msub><m:mi>s</m:mi><m:mi>k</m:mi></m:msub></m:math>. The boundary conditions may be specified in any order.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#BC">BC</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;BC&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02jaf.xml#BC_I">I</a>, <a class="arg" href="../D02/d02jaf.xml#BC_J">J</a>, <a class="arg" href="../D02/d02jaf.xml#BC_RHS">RHS</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">I, J</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">RHS</td></tr></table>
<dl><dt class="paramhead"><a name="BC_I" id="BC_I"/>1: &#160;&#160;&#8194; I &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the index of the boundary condition to be defined.</div></dd><dt class="paramhead"><a name="BC_J" id="BC_J"/>2: &#160;&#160;&#8194; J &#8211; INTEGER<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: must be set to <m:math><m:mrow><m:mo>-</m:mo><m:mi>k</m:mi></m:mrow></m:math>&#160;if the boundary condition is <m:math><m:msup><m:mi>y</m:mi> <m:mfenced separators=""><m:mi>k</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced> </m:msup><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:mfenced><m:mo>=</m:mo><m:msub><m:mi>s</m:mi><m:mi>k</m:mi></m:msub></m:math>, and to <m:math><m:mrow><m:mo>+</m:mo><m:mi>k</m:mi></m:mrow></m:math>&#160;if it is <m:math><m:msup><m:mi>y</m:mi> <m:mfenced separators=""><m:mi>k</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced> </m:msup><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:mfenced><m:mo>=</m:mo><m:msub><m:mi>s</m:mi><m:mi>k</m:mi></m:msub></m:math>.
<div class="paramtext"><a class="arg" href="../D02/d02jaf.xml#BC_J">J</a> must not be set to the same value <m:math><m:mi>k</m:mi></m:math>&#160;for two different values of <a class="arg" href="../D02/d02jaf.xml#BC_I">I</a>.</div>
</div></dd><dt class="paramhead"><a name="BC_RHS" id="BC_RHS"/>3: &#160;&#160;&#8194; RHS &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: must be set to the value <m:math><m:msub><m:mi>s</m:mi><m:mi>k</m:mi></m:msub></m:math>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#BC">BC</a> must be declared as EXTERNAL in the (sub)program from which D02JAF 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="X0" id="X0"/>4: &#160;&#160;&#8194; X0 &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dt class="multi-paramhead"><a name="X1" id="X1"/>5: &#160;&#160;&#8194; X1 &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the left- and right-hand boundaries, <m:math><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>, respectively.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#X1"><m:mi mathcolor="#EE0000" mathvariant="bold">X1</m:mi></m:maction><m:mo>&gt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X0"><m:mi mathcolor="#EE0000" mathvariant="bold">X0</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="K1" id="K1"/>6: &#160;&#160;&#8194; K1 &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: 

the number of coefficients to be returned in the Chebyshev series representation of the solution (hence the degree of the polynomial approximation is <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><m:mo>-</m:mo><m:mn>1</m:mn></m:math>).</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><m:mo>&#8805;</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:math>.
</div></dd><dt class="paramhead"><a name="KP" id="KP"/>7: &#160;&#160;&#8194; KP &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the number of collocation points to be used.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#KP"><m:mi mathcolor="#EE0000" mathvariant="bold">KP</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><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:math>.
</div></dd><dt class="paramhead"><a name="C" id="C"/>8: &#160;&#160;&#8194; C(<a class="arg" href="#K1">K1</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the computed Chebyshev coefficients; that is, the computed solution is: 
<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block"> <m:munderover><m:msup><m:mo>&#8721;</m:mo><m:mo>'</m:mo></m:msup><m:mrow><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction></m:munderover><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#C"><m:mi mathcolor="#EE0000" mathvariant="bold">C</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:msub><m:mi>T</m:mi><m:mrow><m:mi>i</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced> </m:math></td><td class="formula2"/></tr></table></div>
 where <m:math><m:msub><m:mi>T</m:mi><m:mi>i</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;is the <m:math><m:mi>i</m:mi></m:math>th Chebyshev polynomial of the first kind, and <m:math><m:msup><m:mo>&#8721;</m:mo><m:mo>'</m:mo></m:msup></m:math>&#160;denotes that the first coefficient, <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#C"><m:mi mathcolor="#EE0000" mathvariant="bold">C</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>, is halved.</div></dd><dt class="paramhead"><a name="W" id="W"/>9: &#160;&#160;&#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"/>10: &#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 D02JAF 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:mn>2</m:mn><m:mo>&#215;</m:mo><m:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#KP"><m:mi mathcolor="#EE0000" mathvariant="bold">KP</m:mi></m:maction><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:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><m:mo>+</m:mo><m:mn>1</m:mn></m:mfenced><m:mo>+</m:mo><m:mn>7</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="IW" id="IW"/>11: &#8194; IW(<a class="arg" href="#K1">K1</a>) &#8211; INTEGER array<span class="pclass">Workspace</span></dt><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>12: &#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="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>1</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="#X0"><m:mi mathcolor="#EE0000" mathvariant="bold">X0</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#X1"><m:mi mathcolor="#EE0000" mathvariant="bold">X1</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="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>+</m:mo><m:mn>1</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="#KP"><m:mi mathcolor="#EE0000" mathvariant="bold">KP</m:mi></m:maction><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><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: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>
<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="#LW"><m:mi mathcolor="#EE0000" mathvariant="bold">LW</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>2</m:mn><m:mo>&#215;</m:mo><m:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#KP"><m:mi mathcolor="#EE0000" mathvariant="bold">KP</m:mi></m:maction><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:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><m:mo>+</m:mo><m:mn>1</m:mn></m:mfenced><m:mo>+</m:mo><m:mn>7</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction></m:math>&#160;(insufficient workspace).</td></tr></table>
</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">Either the boundary conditions are not linearly independent (that is, in <a class="arg" href="#BC">BC</a> the variable <a class="arg" href="../D02/d02jaf.xml#BC_J">J</a> is set to the same value <m:math><m:mi>k</m:mi></m:math>&#160;for two different values of <a class="arg" href="../D02/d02jaf.xml#BC_I">I</a>), or the rank of the matrix of equations for the coefficients is less than the number of unknowns.  Increasing <a class="arg" href="#KP">KP</a> may overcome this latter problem.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq4" id="IFeq4"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>4</m:mn></m:math></dt>
<dd>
<div class="paramtext">The least-squares routine <a class="rout" href="../F04/f04amf.xml">F04AMF</a> has failed to correct the first approximate solution (see <a class="rout" href="../F04/f04amf.xml">F04AMF</a>).</div></dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">The Chebyshev coefficients are determined by a stable numerical method.  The accuracy of the approximate solution may be checked by varying the degree of the polynomial and the number of collocation points (see <a class="sec" href="#fcomments">Section 8</a>).</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The time taken by D02JAF depends on the complexity of the differential equation, the degree of the polynomial solution, and the number of matching points.</div><div class="paramtext">The collocation points in the interval <m:math><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:mfenced></m:math>&#160;are chosen to be the extrema of the appropriate shifted Chebyshev polynomial.  If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#KP"><m:mi mathcolor="#EE0000" mathvariant="bold">KP</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><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:math>, then the least-squares solution reduces to the solution of a system of linear equations, and true collocation results.</div><div class="paramtext">The accuracy of the solution may be checked by repeating the calculation with different values of <a class="arg" href="#K1">K1</a> and with <a class="arg" href="#KP">KP</a> fixed but <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#KP"><m:mi mathcolor="#EE0000" mathvariant="bold">KP</m:mi></m:maction><m:mo>&#8811;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><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:math>.  If the Chebyshev coefficients decrease rapidly (and consistently for various <a class="arg" href="#K1">K1</a> and <a class="arg" href="#KP">KP</a>), the size of the last two or three gives an indication of the error.  If the Chebyshev coefficients do not decay rapidly, it is likely that the solution cannot be well-represented by Chebyshev series.  Note that the Chebyshev coefficients are calculated for the interval <m:math><m:mfenced separators=""><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mo>,</m:mo><m:mn>1</m:mn></m:mfenced></m:math>.</div><div class="paramtext">Systems of regular linear differential equations can be solved using <a class="rout" href="../D02/d02jbf.xml">D02JBF</a>.  It is necessary before using <a class="rout" href="../D02/d02jbf.xml">D02JBF</a> to write the differential equations as a first-order system.  Linear systems of high-order equations in their original form, singular problems, and, indirectly, nonlinear problems can be solved using <a class="rout" href="../D02/d02tgf.xml">D02TGF</a>.</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:mi>y</m:mi>
 <m:mo>=</m:mo>
 <m:mn>1</m:mn>
</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:mo>-</m:mo><m:mn>1</m:mn></m:mfenced>
 <m:mo>=</m:mo>
 <m:mi>y</m:mi><m:mfenced separators=""><m:mn>1</m:mn></m:mfenced>
 <m:mo>=</m:mo>
 <m:mn>0</m:mn>
 <m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div></div><div class="paramtext">We use <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><m:mo>=</m:mo><m:mn>4</m:mn></m:math>, <m:math><m:mn>6</m:mn></m:math>&#160;and <m:math><m:mn>8</m:mn></m:math>, and <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#KP"><m:mi mathcolor="#EE0000" mathvariant="bold">KP</m:mi></m:maction><m:mo>=</m:mo><m:mn>10</m:mn></m:math>&#160;and <m:math><m:mn>15</m:mn></m:math>, so that the different Chebyshev series may be compared.  The solution for <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#K1"><m:mi mathcolor="#EE0000" mathvariant="bold">K1</m:mi></m:maction><m:mo>=</m:mo><m:mn>8</m:mn></m:math>&#160;and <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#KP"><m:mi mathcolor="#EE0000" mathvariant="bold">KP</m:mi></m:maction><m:mo>=</m:mo><m:mn>15</m:mn></m:math>&#160;is evaluated by <a class="rout" href="../E02/e02akf.xml">E02AKF</a> at nine equally spaced points over the interval <m:math><m:mfenced separators=""><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mo>,</m:mo><m:mn>1</m:mn></m:mfenced></m:math>.</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/d02jafe.f">Program Text (d02jafe.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/d02jafe.r">Program Results (d02jafe.r)</a></p><div class="figure"><a name="d02jaf-plot" id="d02jaf-plot"/><img src="../figures/d02jaf-plot.png" alt="Example Program Plot for d02jaf-plot"/></div>
<hr/><div><a class="rout" href="../../pdf/D02/d02jaf.pdf">D02JAF (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>
