<?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>D02JBF : 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/d02jbf.pdf">D02JBF (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/>D02JBF</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">D02JBF solves a regular linear two-point boundary value problem for a system of ordinary differential equations 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;D02JBF&#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="#LDC">LDC</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, K1, KP, LDC, LW, IW(LIW), LIW, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">CF, X0, X1, C(LDC,N), 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">D02JBF calculates the solution of a regular two-point boundary value problem for a regular linear <m:math><m:mi>n</m:mi></m:math>th-order system of first-order ordinary differential equations 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:msup><m:mi>y</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mo>=</m:mo><m:mi>A</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mi>y</m:mi><m:mo>+</m:mo><m:mi>r</m:mi><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, <m:math><m:mi>n</m:mi></m:math>&#160;equations 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 for each component of the solution of the system of differential equations 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 components of 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 their 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 system of differential equations.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="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 system of differential equations (see <a class="sec" href="#description">Section 3</a>). It must return the value of a coefficient function <m:math><m:msub><m:mi>a</m:mi><m:mrow><m:mi>i</m:mi><m:mo>,</m:mo><m:mi>j</m:mi></m:mrow></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>, of <m:math><m:mi>A</m:mi></m:math>, at a given point <m:math><m:mi>x</m:mi></m:math>, or of a right-hand side function <m:math><m:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#CF_J"><m:mi mathcolor="#EE0000" mathvariant="bold">J</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>.</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/d02jbf.xml#CF_I">I</a>, <a class="arg" href="../D02/d02jbf.xml#CF_J">J</a>, <a class="arg" href="../D02/d02jbf.xml#CF_X">X</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">X</td></tr></table>
<dl><dt class="paramhead"><a name="CF_I" id="CF_I"/>1: &#160;&#160;&#8194; I &#8211; INTEGER<span class="pclass">Input</span></dt><dt class="multi-paramhead"><a name="CF_J" id="CF_J"/>2: &#160;&#160;&#8194; J &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: indicate the function to be evaluated, namely <m:math><m:msub><m:mi>a</m:mi><m:mrow><m:mi>i</m:mi><m:mo>,</m:mo><m:mi>j</m:mi></m:mrow></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;if <m:math><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#CF_J"><m:mi mathcolor="#EE0000" mathvariant="bold">J</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mi>n</m:mi></m:math>, or <m:math><m:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#CF_J"><m:mi mathcolor="#EE0000" mathvariant="bold">J</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>. <br/> <m:math><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#CF_I"><m:mi mathcolor="#EE0000" mathvariant="bold">I</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mi>n</m:mi></m:math>, <m:math><m:mn>0</m:mn><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#CF_J"><m:mi mathcolor="#EE0000" mathvariant="bold">J</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mi>n</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="CF_X" id="CF_X"/>3: &#160;&#160;&#8194; X &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the point at which the function 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 D02JBF 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 <m:math><m:mi>n</m:mi></m:math>&#160;boundary conditions, which have the form <m:math><m:msub><m:mi>y</m:mi><m:mi>k</m:mi></m:msub><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:mfenced><m:mo>=</m:mo><m:mi>s</m:mi></m:math>&#160;or <m:math><m:msub><m:mi>y</m:mi><m:mi>k</m:mi></m:msub><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:mfenced><m:mo>=</m:mo><m:mi>s</m:mi></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/d02jbf.xml#BC_I">I</a>, <a class="arg" href="../D02/d02jbf.xml#BC_J">J</a>, <a class="arg" href="../D02/d02jbf.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 <m:math><m:mi>i</m:mi></m:math>th boundary condition is <m:math><m:msub><m:mi>y</m:mi><m:mi>k</m:mi></m:msub><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:mfenced><m:mo>=</m:mo><m:mi>s</m:mi></m:math>, or 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:msub><m:mi>y</m:mi><m:mi>k</m:mi></m:msub><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:mfenced><m:mo>=</m:mo><m:mi>s</m:mi></m:math>.
<div class="paramtext"><a class="arg" href="../D02/d02jbf.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/d02jbf.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>: the value <m:math><m:mi>s</m:mi></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 D02JBF 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 components 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:mn>2</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:mn>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="C" id="C"/>8: &#160;&#160;&#8194; C(<a class="arg" href="#LDC">LDC</a>,<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the computed Chebyshev coefficients of the <m:math><m:mi>k</m:mi></m:math>th component of the solution, <m:math><m:msub><m:mi>y</m:mi><m:mi>k</m:mi></m:msub></m:math>; that is, the computed solution is: 
<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block"> <m:msub><m:mi>y</m:mi><m:mi>k</m:mi></m:msub><m:mo>=</m:mo><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:mi>k</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:mtext>, &#8195;</m:mtext><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:mi>k</m:mi><m:mo>&#8804;</m:mo><m:mi>n</m:mi> </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:mi>k</m:mi></m:mfenced></m:mrow></m:math>, is halved.</div></dd><dt class="paramhead"><a name="LDC" id="LDC"/>9: &#160;&#160;&#8194; LDC &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the first dimension of the array <a class="arg" href="#C">C</a> as declared in the (sub)program from which D02JBF is called.</div>
<div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LDC"><m:mi mathcolor="#EE0000" mathvariant="bold">LDC</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:math>.
</div></dd><dt class="paramhead"><a name="W" id="W"/>10: &#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"/>11: &#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 D02JBF 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:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><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:mn>1</m:mn></m:mfenced><m:mo>&#215;</m:mo><m:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><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: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="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><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"/>12: &#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"/>13: &#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 D02JBF 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="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><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>2</m:mn></m:mfenced></m:math>.
</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>14: &#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:mn>2</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: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="#LDC"><m:mi mathcolor="#EE0000" mathvariant="bold">LDC</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: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:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><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:mn>1</m:mn></m:mfenced><m:mo>&#215;</m:mo><m:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><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: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="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><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>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><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>&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>&#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>2</m:mn></m:mfenced></m:math>&#160;(i.e., 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/d02jbf.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/d02jbf.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 polynomials 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 D02JBF depends on the size and complexity of the differential system, 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:mn>1</m:mn></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:mn>1</m:mn></m:math>.  If the Chebyshev coefficients decrease rapidly for each component (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">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>

The equation is written as the first-order system

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mfenced><m:mtable columnalign="left">
  <m:mtr>
   <m:mtd><m:msubsup><m:mi>y</m:mi><m:mn>1</m:mn><m:mo>&#8242;</m:mo></m:msubsup></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:msubsup><m:mi>y</m:mi><m:mn>2</m:mn><m:mo>&#8242;</m:mo></m:msubsup></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
<m:mo>=</m:mo>
 <m:mfenced><m:mtable columnalign="right">
  <m:mtr>
   <m:mtd><m:mn>0</m:mn></m:mtd>
   <m:mtd><m:mn>1</m:mn></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mtd>
   <m:mtd><m:mn>0</m:mn></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
 <m:mfenced><m:mtable columnalign="left">
  <m:mtr>
   <m:mtd><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
<m:mo>+</m:mo>
 <m:mfenced><m:mtable columnalign="left">
  <m:mtr>
   <m:mtd><m:mn>0</m:mn></m:mtd>
  </m:mtr><m:mtr>
   <m:mtd><m:mn>1</m:mn></m:mtd>
  </m:mtr>
 </m:mtable></m:mfenced>
</m:math></td><td class="formula2"/></tr></table></div>

for solution by D02JBF and the boundary conditions are written

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mfenced separators=""><m:mo>-</m:mo> <m:mn>1</m:mn></m:mfenced><m:mo>=</m:mo><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><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/d02jbfe.f">Program Text (d02jbfe.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/d02jbfe.r">Program Results (d02jbfe.r)</a></p><div class="figure"><a name="d02jbf-plot" id="d02jbf-plot"/><img src="../figures/d02jbf-plot.png" alt="Example Program Plot for d02jbf-plot"/></div>
<hr/><div><a class="rout" href="../../pdf/D02/d02jbf.pdf">D02JBF (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>
