<?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>D02TGF : 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/d02tgf.pdf">D02TGF (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/>D02TGF</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">D02TGF solves a system of linear ordinary differential equations by least-squares fitting of a series of Chebyshev polynomials using collocation.</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;D02TGF&#160;(</td><td class="tdfspec2"><a class="arg" href="#N">N</a>, <a class="arg" href="#M">M</a>, <a class="arg" href="#L">L</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="#COEFF">COEFF</a>, <a class="arg" href="#BDYC">BDYC</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, M(N), L(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">X0, X1, C(LDC,N), W(LW)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">COEFF, BDYC</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D02TGF calculates an approximate solution of a linear or linearized system of ordinary differential equations as a Chebyshev series.  Suppose there are <m:math><m:mi>n</m:mi></m:math>&#160;differential equations for <m:math><m:mi>n</m:mi></m:math>&#160;variables <m:math><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mi>n</m:mi></m:msub></m:math>, over the range <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>.  Let the <m:math><m:mi>i</m:mi></m:math>th equation be

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:munderover>
  <m:mo>&#8721;</m:mo>
  <m:mrow><m:mi>j</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow>
  <m:mrow><m:msub><m:mi>m</m:mi><m:mi>i</m:mi></m:msub><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow>
 </m:munderover>
 <m:munderover>
  <m:mo>&#8721;</m:mo>
  <m:mrow><m:mi>k</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow>
  <m:mi>n</m:mi>
 </m:munderover>
 <m:msubsup><m:mi>f</m:mi><m:mrow><m:mi>k</m:mi><m:mi>j</m:mi></m:mrow><m:mi>i</m:mi></m:msubsup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced>
 <m:msubsup>
  <m:mi>y</m:mi>
  <m:mi>k</m:mi><m:mfenced separators=""><m:mi>j</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced>
 </m:msubsup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>=</m:mo> 
 <m:msup><m:mi>r</m:mi><m:mi>i</m:mi></m:msup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:msubsup><m:mi>y</m:mi><m:mi>k</m:mi>
<m:mfenced separators=""><m:mi>j</m:mi></m:mfenced>
</m:msubsup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>=</m:mo><m:mfrac><m:mrow><m:msup><m:mi>d</m:mi><m:mi>j</m:mi></m:msup><m:msub><m:mi>y</m:mi><m:mi>k</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:msup><m:mi>x</m:mi><m:mi>j</m:mi></m:msup></m:mrow>
 </m:mfrac>
</m:math>.  <a class="arg" href="#COEFF">COEFF</a> evaluates the coefficients <m:math><m:msubsup><m:mi>f</m:mi><m:mrow><m:mi>k</m:mi><m:mi>j</m:mi></m:mrow><m:mi>i</m:mi></m:msubsup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;and the right-hand side <m:math><m:msup><m:mi>r</m:mi><m:mi>i</m:mi></m:msup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;for each <m:math><m:mi>i</m:mi></m:math>, <m:math><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:mi>i</m:mi><m:mo>&#8804;</m:mo><m:mi>n</m:mi></m:math>, at any point <m:math><m:mi>x</m:mi></m:math>.  The boundary conditions may be applied either at the end points or at intermediate points; they are written in the same form as the differential equations, and specified by <a class="arg" href="#BDYC">BDYC</a>.  For example the <m:math><m:mi>j</m:mi></m:math>th boundary condition out of those associated with the <m:math><m:mi>i</m:mi></m:math>th differential equation takes the form

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:munderover>
  <m:mo>&#8721;</m:mo>
  <m:mrow><m:mi>j</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow>
  <m:mrow><m:msub><m:mi>l</m:mi><m:mi>i</m:mi></m:msub><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow>
 </m:munderover>
 <m:munderover>
  <m:mo>&#8721;</m:mo>
  <m:mrow><m:mi>k</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow>
  <m:mi>n</m:mi>
 </m:munderover>
 <m:msubsup>
  <m:mi>f</m:mi>
  <m:mrow><m:mi>k</m:mi><m:mi>j</m:mi></m:mrow>
  <m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow>
 </m:msubsup>
 <m:mfenced separators=""><m:msup><m:mi>x</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msup></m:mfenced>
 <m:msubsup>
  <m:mi>y</m:mi><m:mi>k</m:mi><m:mfenced separators=""><m:mi>j</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced>
 </m:msubsup>
 <m:mfenced separators=""><m:msup><m:mi>x</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msup></m:mfenced><m:mo>=</m:mo><m:msup><m:mi>r</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msup>
 <m:mfenced separators=""><m:msup><m:mi>x</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msup></m:mfenced>
 <m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:msup><m:mi>x</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msup></m:math>&#160;lies between <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>.  It is assumed in this routine that certain of the boundary conditions are associated with each differential equation.  This is for your convenience; the grouping does not affect the results.</div><div class="paramtext">The degree of the polynomial solution must be the same for all variables.  You specify the degree required, <m:math><m:msub><m:mi>k</m:mi><m:mn>1</m:mn></m:msub><m:mo>-</m:mo><m:mn>1</m:mn></m:math>, and the number of collocation points, <m:math><m:msub><m:mi>k</m:mi><m:mi>p</m:mi></m:msub></m:math>, in the range.  The routine sets up a system of linear equations for the Chebyshev coefficients,  with <m:math><m:mi>n</m:mi></m:math>&#160;equations for each collocation point and one for each boundary condition.  The collocation points are chosen at the extrema of a shifted Chebyshev polynomial of degree <m:math><m:msub><m:mi>k</m:mi><m:mi>p</m:mi></m:msub><m:mo>-</m:mo><m:mn>1</m:mn></m:math>.  The boundary conditions are satisfied exactly, and the remaining equations are solved by a least-squares method.  The result produced is a set of Chebyshev coefficients for the <m:math><m:mi>n</m:mi></m:math>&#160;functions <m:math><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>y</m:mi><m:mi>n</m:mi></m:msub></m:math>, with the range normalized to <m:math><m:mfenced separators="" open="[" close="]"><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 range <m:math><m:mfenced separators="" open="[" close="]"><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;(see <a class="sec" href="#example">Section 9</a> for an example).  <a class="rout" href="../E02/e02ahf.xml">E02AHF</a> and <a class="rout" href="../E02/e02ajf.xml">E02AJF</a> may be used to obtain Chebyshev series representations of derivatives and integrals (respectively) of the components of the solution.</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 number of differential equations in the system.</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="M" id="M"/>2: &#160;&#160;&#8194; M(<a class="arg" href="#N">N</a>) &#8211; INTEGER 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="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;must be set to the highest order derivative occurring in the <m:math><m:mi>i</m:mi></m:math>th equation, 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>n</m:mi></m:math>.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi mathvariant="italic">i</m:mi></m:mfenced></m:mrow><m:mo>&#8805;</m:mo><m:mn>1</m:mn></m:math>,  for <m:math><m:mi mathvariant="italic">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>n</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="L" id="L"/>3: &#160;&#160;&#8194; L(<a class="arg" href="#N">N</a>) &#8211; INTEGER 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="#L"><m:mi mathcolor="#EE0000" mathvariant="bold">L</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;must be set to the number of boundary conditions associated with the <m:math><m:mi>i</m:mi></m:math>th equation, 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>n</m:mi></m:math>.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#L"><m:mi mathcolor="#EE0000" mathvariant="bold">L</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi mathvariant="italic">i</m:mi></m:mfenced></m:mrow><m:mo>&#8805;</m:mo><m:mn>0</m:mn></m:math>,  for <m:math><m:mi mathvariant="italic">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>n</m:mi></m:math>.</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><dd>
<div class="paramtext"><i>On entry</i>: the left-hand boundary, <m:math><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:math>.</div></dd><dt class="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 right-hand boundary, <m:math><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:math>.</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, <m:math><m:msub><m:mi>k</m:mi><m:mn>1</m:mn></m:msub></m:math>, 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:mn>1</m:mn><m:mo>+</m:mo>
  <m:mstyle displaystyle="true"><m:munder>
   <m:mi mathvariant="normal">max</m:mi>
   <m:mrow><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:mi>i</m:mi><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction></m:mrow>
  </m:munder></m:mstyle><m:mspace width="0.25em"/>
  <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></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, <m:math><m:msub><m:mi>k</m:mi><m:mi>p</m:mi></m:msub></m:math>.</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>&#215;</m:mo><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="#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:mstyle displaystyle="true"><m:munderover> <m:mo>&#8721;</m:mo> <m:mrow><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow> <m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction> </m:munderover></m:mstyle> <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#L"><m:mi mathcolor="#EE0000" mathvariant="bold">L</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow> </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 <m:math><m:mi>k</m:mi></m:math>th column of <a class="arg" href="#C">C</a> contains 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:msub><m:mi>k</m:mi><m:mn>1</m:mn></m:msub></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:mtext>,</m:mtext> </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 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 D02TGF 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="COEFF" id="COEFF"/>10: &#8194; COEFF &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#COEFF">COEFF</a> defines the system of differential equations (see <a class="sec" href="#description">Section 3</a>). It must evaluate the coefficient functions <m:math><m:msubsup><m:mi>f</m:mi><m:mrow><m:mi>k</m:mi><m:mi>j</m:mi></m:mrow><m:mi>i</m:mi></m:msubsup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;and the right-hand side function <m:math><m:msup><m:mi>r</m:mi><m:mi>i</m:mi></m:msup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;of the <m:math><m:mi>i</m:mi></m:math>th equation at a given point. Only nonzero entries of the array <a class="arg" href="../D02/d02tgf.xml#COEFF_A">A</a> and <a class="arg" href="../D02/d02tgf.xml#COEFF_RHS">RHS</a> need be specifically assigned, since all elements are set to zero by D02TGF before calling <a class="arg" href="#COEFF">COEFF</a>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#COEFF">COEFF</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;COEFF&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02tgf.xml#COEFF_X">X</a>, <a class="arg" href="../D02/d02tgf.xml#COEFF_I">I</a>, <a class="arg" href="../D02/d02tgf.xml#COEFF_A">A</a>, <a class="arg" href="../D02/d02tgf.xml#COEFF_IA">IA</a>, <a class="arg" href="../D02/d02tgf.xml#COEFF_IA1">IA1</a>, <a class="arg" href="../D02/d02tgf.xml#COEFF_RHS">RHS</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">I, IA, IA1</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X, A(IA,IA1), RHS</td></tr></table>
<div class="paramtext">Important: the dimension declaration for <a class="arg" href="../D02/d02tgf.xml#COEFF_A">A</a> must contain the variable <a class="arg" href="../D02/d02tgf.xml#COEFF_IA">IA</a>, not an integer constant.</div>
<dl><dt class="paramhead"><a name="COEFF_X" id="COEFF_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 point at which the functions must be evaluated.</div></dd><dt class="paramhead"><a name="COEFF_I" id="COEFF_I"/>2: &#160;&#160;&#8194; I &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the equation for which the coefficients and right-hand side are to be evaluated.</div></dd><dt class="paramhead"><a name="COEFF_A" id="COEFF_A"/>3: &#160;&#160;&#8194; A(<a class="arg" href="../D02/d02tgf.xml#COEFF_IA">IA</a>,<a class="arg" href="../D02/d02tgf.xml#COEFF_IA1">IA1</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: all elements of <a class="arg" href="../D02/d02tgf.xml#COEFF_A">A</a> are set to zero.</div>
<div class="paramtext"><i>On exit</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#COEFF_A"><m:mi mathcolor="#EE0000" mathvariant="bold">A</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>k</m:mi><m:mi>j</m:mi></m:mfenced></m:mrow></m:math>&#160;must contain the value <m:math><m:msubsup><m:mi>f</m:mi><m:mrow><m:mi>k</m:mi><m:mi>j</m:mi></m:mrow><m:mi>i</m:mi></m:msubsup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>, for <m:math><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>, <m:math><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:mi>j</m:mi><m:mo>&#8804;</m:mo><m:msub><m:mi>m</m:mi><m:mi>i</m:mi></m:msub><m:mo>+</m:mo><m:mn>1</m:mn></m:math>.</div></dd><dt class="paramhead"><a name="COEFF_IA" id="COEFF_IA"/>4: &#160;&#160;&#8194; IA &#8211; INTEGER<span class="pclass">Input</span></dt><dt class="multi-paramhead"><a name="COEFF_IA1" id="COEFF_IA1"/>5: &#160;&#160;&#8194; IA1 &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the first and second dimensions of <a class="arg" href="../D02/d02tgf.xml#COEFF_A">A</a>, respectively.</div></dd><dt class="paramhead"><a name="COEFF_RHS" id="COEFF_RHS"/>6: &#160;&#160;&#8194; RHS &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: is set to zero.</div>
<div class="paramtext"><i>On exit</i>: it must contain the value <m:math><m:msup><m:mi>r</m:mi><m:mi>i</m:mi></m:msup><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#COEFF">COEFF</a> must be declared as EXTERNAL in the (sub)program from which D02TGF 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="BDYC" id="BDYC"/>11: &#8194; BDYC &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd>
<div class="paramtext"><a class="arg" href="#BDYC">BDYC</a> defines the boundary conditions (see <a class="sec" href="#description">Section 3</a>). It must evaluate the coefficient functions <m:math><m:msubsup><m:mi>f</m:mi><m:mrow><m:mi>k</m:mi><m:mi>j</m:mi></m:mrow>
  <m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msubsup></m:math>&#160;and right-hand side function <m:math><m:msup><m:mi>r</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msup></m:math>&#160;in the <m:math><m:mi>j</m:mi></m:math>th boundary condition associated with the <m:math><m:mi>i</m:mi></m:math>th equation, at the point <m:math><m:msup><m:mi>x</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msup></m:math>&#160;at which the boundary condition is applied. Only nonzero entries of the array <a class="arg" href="../D02/d02tgf.xml#BDYC_A">A</a> and <a class="arg" href="../D02/d02tgf.xml#BDYC_RHS">RHS</a> need be specifically assigned, since all elements are set to zero by D02TGF before calling <a class="arg" href="#BDYC">BDYC</a>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#BDYC">BDYC</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;BDYC&#160;(</td><td class="tdfspec2"><a class="arg" href="../D02/d02tgf.xml#BDYC_X">X</a>, <a class="arg" href="../D02/d02tgf.xml#BDYC_I">I</a>, <a class="arg" href="../D02/d02tgf.xml#BDYC_J">J</a>, <a class="arg" href="../D02/d02tgf.xml#BDYC_A">A</a>, <a class="arg" href="../D02/d02tgf.xml#BDYC_IA">IA</a>, <a class="arg" href="../D02/d02tgf.xml#BDYC_IA1">IA1</a>, <a class="arg" href="../D02/d02tgf.xml#BDYC_RHS">RHS</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">I, J, IA, IA1</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X, A(IA,IA1), RHS</td></tr></table>
<div class="paramtext">Important: the dimension declaration for <a class="arg" href="../D02/d02tgf.xml#BDYC_A">A</a> must contain the variable <a class="arg" href="../D02/d02tgf.xml#BDYC_IA">IA</a>, not an integer constant.</div>
<dl><dt class="paramhead"><a name="BDYC_X" id="BDYC_X"/>1: &#160;&#160;&#8194; X &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: <m:math><m:msup><m:mi>x</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msup></m:math>, the value at which the boundary condition is applied.</div></dd><dt class="paramhead"><a name="BDYC_I" id="BDYC_I"/>2: &#160;&#160;&#8194; I &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the differential equation with which the condition is associated.</div></dd><dt class="paramhead"><a name="BDYC_J" id="BDYC_J"/>3: &#160;&#160;&#8194; J &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the boundary condition for which the coefficients and right-hand side are to be evaluated.</div></dd><dt class="paramhead"><a name="BDYC_A" id="BDYC_A"/>4: &#160;&#160;&#8194; A(<a class="arg" href="../D02/d02tgf.xml#BDYC_IA">IA</a>,<a class="arg" href="../D02/d02tgf.xml#BDYC_IA1">IA1</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: all elements of <a class="arg" href="../D02/d02tgf.xml#BDYC_A">A</a> are set to zero.</div>
<div class="paramtext"><i>On exit</i>: the value <m:math>
 <m:msubsup>
  <m:mi>f</m:mi>
  <m:mrow><m:mi>k</m:mi><m:mi>j</m:mi></m:mrow>
  <m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow>
 </m:msubsup> 
 <m:mfenced separators=""><m:msup><m:mi>x</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msup></m:mfenced> 
</m:math>, for <m:math><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>, <m:math><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:mi>j</m:mi><m:mo>&#8804;</m:mo><m:msub><m:mi>m</m:mi><m:mi>i</m:mi></m:msub><m:mo>+</m:mo><m:mn>1</m:mn></m:math>.</div></dd><dt class="paramhead"><a name="BDYC_IA" id="BDYC_IA"/>5: &#160;&#160;&#8194; IA &#8211; INTEGER<span class="pclass">Input</span></dt><dt class="multi-paramhead"><a name="BDYC_IA1" id="BDYC_IA1"/>6: &#160;&#160;&#8194; IA1 &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the first and second dimensions of <a class="arg" href="../D02/d02tgf.xml#BDYC_A">A</a>, respectively.</div></dd><dt class="paramhead"><a name="BDYC_RHS" id="BDYC_RHS"/>7: &#160;&#160;&#8194; RHS &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: is set to zero.</div>
<div class="paramtext"><i>On exit</i>: the value <m:math><m:msup><m:mi>r</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msup> <m:mfenced separators=""><m:msup><m:mi>x</m:mi><m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow></m:msup></m:mfenced> </m:math>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#BDYC">BDYC</a> must be declared as EXTERNAL in the (sub)program from which D02TGF 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="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 D02TGF 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="#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="#KP"><m:mi mathcolor="#EE0000" mathvariant="bold">KP</m:mi></m:maction><m:mo>+</m:mo><m:mi mathvariant="italic">NL</m:mi> </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>, where <m:math> <m:mi mathvariant="italic">NL</m:mi><m:mo>=</m:mo><m:mstyle displaystyle="true"><m:munderover> <m:mo>&#8721;</m:mo> <m:mrow><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow> <m:mi>n</m:mi> </m:munderover></m:mstyle> <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#L"><m:mi mathcolor="#EE0000" mathvariant="bold">L</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow> </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 D02TGF 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: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="IFAIL" id="IFAIL"/>16: &#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:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>&lt;</m:mo><m:mn>1</m:mn></m:math>&#160;for some <m:math><m:mi>i</m:mi></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#L"><m:mi mathcolor="#EE0000" mathvariant="bold">L</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>&lt;</m:mo><m:mn>0</m:mn></m:math>&#160;for some <m:math><m:mi>i</m:mi></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>1</m:mn><m:mo>+</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;for some <m:math><m:mi>i</m:mi></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90">
 <m:math>
  <m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>&#215;</m:mo><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="#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:mstyle displaystyle="true"><m:munderover>
   <m:mo>&#8721;</m:mo>
   <m:mrow><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow>
   <m:mi>n</m:mi>
  </m:munderover></m:mstyle><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#L"><m:mi mathcolor="#EE0000" mathvariant="bold">L</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow>
 </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"><a class="arg" href="#LW">LW</a> is too small (see <a class="sec" href="#parameters">Section 5</a>),</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: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="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, 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>).  Increasing <a class="arg" href="#KP">KP</a> may remove this difficulty.</div>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">Estimates of the accuracy of the solution may be obtained by using the checks described in <a class="sec" href="#fcomments">Section 8</a>.  The Chebyshev coefficients are calculated by a stable numerical method.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The time taken by D02TGF depends on the complexity of the system of differential equations, the degree of the polynomial solution and the number of matching points.</div><div class="paramtext">If the number of matching points <m:math><m:msub><m:mi>k</m:mi><m:mi>p</m:mi></m:msub></m:math>&#160;is equal to the number of coefficients <m:math><m:msub><m:mi>k</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;minus the average number of boundary conditions 
<m:math>
 <m:mfrac><m:mn>1</m:mn><m:mi>n</m:mi></m:mfrac>
 <m:mstyle displaystyle="true"><m:munderover>
  <m:mo>&#8721;</m:mo>
  <m:mrow><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow>
  <m:mi>n</m:mi>
 </m:munderover></m:mstyle>
 <m:msub><m:mi>l</m:mi><m:mi>i</m:mi></m:msub>
</m:math>, then the least-squares solution reduces to simple solution of linear equations and true collocation results.  The accuracy of the solution may be checked by repeating the calculation with different values of <m:math><m:msub><m:mi>k</m:mi><m:mn>1</m:mn></m:msub></m:math>.  If the Chebyshev coefficients decrease rapidly, the size of the last two or three gives an indication of the error.  If they do not decrease rapidly, it may be desirable to use a different method.  Note that the Chebyshev coefficients are calculated for the range normalized to <m:math><m:mfenced separators="" open="[" close="]"><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">Generally the number of boundary conditions required is equal to the sum of the orders of the <m:math><m:mi>n</m:mi></m:math>&#160;differential equations.  However, in some cases fewer boundary conditions are needed, because the assumption of a polynomial solution is equivalent to one or more boundary conditions (since it excludes singular solutions).</div><div class="paramtext">A system of <b>nonlinear</b> differential equations must be linearized before using the routine.  The calculation is repeated iteratively.  On each iteration the linearized equation is used.  In the example in <a class="sec" href="#example">Section 9</a>, the <m:math><m:mi>y</m:mi></m:math>&#160;variables are to be determined at the current iteration whilst the <m:math><m:mi>z</m:mi></m:math>&#160;variables correspond to the solution determined at the previous iteration, (or the initial approximation on the first iteration).  For a starting approximation, we may take, say, a linear function, and set up the appropriate Chebyshev coefficients before starting the iteration.  For example, if <m:math><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mo>=</m:mo><m:mi>a</m:mi><m:mi>x</m:mi><m:mo>+</m:mo><m:mi>b</m:mi></m:math>&#160;in the range <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>, we set <m:math><m:mi mathvariant="normal">B</m:mi></m:math>, the array of coefficients,
<ul class="listind"><li class="listind"><m:math><m:mi mathvariant="normal">B</m:mi><m:mfenced separators=""><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>1</m:mn></m:mfenced><m:mo>=</m:mo><m:mi>a</m:mi><m:mo>&#215;</m:mo><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:mo>+</m:mo><m:mn>2</m:mn><m:mo>&#215;</m:mo><m:mi>b</m:mi></m:math>,</li><li class="listind"><m:math><m:mi mathvariant="normal">B</m:mi><m:mfenced separators=""><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn></m:mfenced><m:mo>=</m:mo><m:mi>a</m:mi><m:mo>&#215;</m:mo><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub><m:mo>-</m:mo><m:msub><m:mi>x</m:mi><m:mn>0</m:mn></m:msub></m:mfenced><m:mo>/</m:mo><m:mn>2</m:mn></m:math>,</li><li class="listind">and the remainder of the entries to zero.</li></ul>
</div><div class="paramtext">In some cases a better initial approximation may be needed and can be obtained by using <a class="rout" href="../E02/e02adf.xml">E02ADF</a> or <a class="rout" href="../E02/e02aff.xml">E02AFF</a> to obtain a Chebyshev series for an approximate solution.  The coefficients of the current iterate must be communicated to <a class="arg" href="#COEFF">COEFF</a> and <a class="arg" href="#BDYC">BDYC</a>, e.g., in COMMON.  (See <a class="sec" href="#example">Section 9</a>.)  The convergence of the (Newton) iteration cannot be guaranteed in general, though it is usually satisfactory from a good starting approximation.</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example solves the nonlinear system

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mtable>
 <m:mtr>
  <m:mtd><m:mn>2</m:mn><m:msubsup><m:mi>y</m:mi><m:mn>1</m:mn><m:mo>&#8242;</m:mo></m:msubsup><m:mo>+</m:mo><m:mfenced separators=""><m:msubsup><m:mi>y</m:mi><m:mn>2</m:mn><m:mn>2</m:mn></m:msubsup><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced>
<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:mn>0</m:mn><m:mtext>,</m:mtext></m:mtd>
 </m:mtr><m:mtr>
  <m:mtd/></m:mtr><m:mtr>
  <m:mtd><m:mn>2</m:mn><m:msubsup><m:mi>y</m:mi><m:mn>2</m:mn><m:mrow><m:mo>&#8242;</m:mo><m:mo>&#8242;</m:mo></m:mrow></m:msubsup><m:mo>-</m:mo><m:msubsup><m:mi>y</m:mi><m:mn>1</m:mn><m:mo>&#8242;</m:mo></m:msubsup><m:mo>=</m:mo><m:mn>0</m:mn><m:mtext>,</m:mtext></m:mtd>
 </m:mtr>
</m:mtable>
</m:math></td><td class="formula2"/></tr></table></div>

in the range <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>, with <m:math><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mo>=</m:mo><m:mn>0</m:mn></m:math>,  <m:math><m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub><m:mo>=</m:mo><m:mn>3</m:mn></m:math>, <m:math><m:msubsup><m:mi>y</m:mi><m:mn>2</m:mn><m:mo>&#8242;</m:mo></m:msubsup><m:mo>=</m:mo><m:mn>0</m:mn></m:math>&#160;at <m:math><m:mi>x</m:mi><m:mo>=</m:mo><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>.</div><div class="paramtext">Suppose an approximate solution is <m:math><m:msub><m:mi>z</m:mi><m:mn>1</m:mn></m:msub></m:math>, <m:math><m:msub><m:mi>z</m:mi><m:mn>2</m:mn></m:msub></m:math>&#160;such that <m:math><m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mo>&#8764;</m:mo><m:msub><m:mi>z</m:mi><m:mn>1</m:mn></m:msub></m:math>, <m:math><m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub><m:mo>&#8764;</m:mo><m:msub><m:mi>z</m:mi><m:mn>2</m:mn></m:msub></m:math>:  then the first equation gives, on linearizing,

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mn>2</m:mn><m:msubsup><m:mi>y</m:mi><m:mn>1</m:mn><m:mo>&#8242;</m:mo></m:msubsup><m:mo>+</m:mo><m:mfenced separators=""><m:msubsup><m:mi>z</m:mi><m:mn>2</m:mn><m:mn>2</m:mn></m:msubsup><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced>
<m:msub><m:mi>y</m:mi><m:mn>1</m:mn></m:msub><m:mo>+</m:mo><m:mfenced separators=""><m:mn>2</m:mn><m:msub><m:mi>z</m:mi><m:mn>1</m:mn></m:msub><m:msub><m:mi>z</m:mi><m:mn>2</m:mn></m:msub><m:mo>+</m:mo><m:mn>1</m:mn></m:mfenced>
<m:msub><m:mi>y</m:mi><m:mn>2</m:mn></m:msub><m:mo>=</m:mo><m:mn>2</m:mn><m:msub><m:mi>z</m:mi><m:mn>1</m:mn></m:msub><m:msubsup><m:mi>z</m:mi><m:mn>2</m:mn><m:mn>2</m:mn></m:msubsup><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

The starting approximation is taken to be <m:math><m:msub><m:mi>z</m:mi><m:mn>1</m:mn></m:msub><m:mo>=</m:mo><m:mn>0</m:mn></m:math>,  <m:math><m:msub><m:mi>z</m:mi><m:mn>2</m:mn></m:msub><m:mo>=</m:mo><m:mn>3</m:mn></m:math>.  In the program below, the array <m:math><m:mi mathvariant="normal">B</m:mi></m:math>&#160;is used to hold the coefficients of the previous iterate (or of the starting approximation).  We iterate until the Chebyshev coefficients converge to five figures.  <a class="rout" href="../E02/e02akf.xml">E02AKF</a> is used to calculate the solution from its Chebyshev coefficients.</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/d02tgfe.f">Program Text (d02tgfe.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/d02tgfe.r">Program Results (d02tgfe.r)</a></p><div class="figure"><a name="d02tgf-plot" id="d02tgf-plot"/><img src="../figures/d02tgf-plot.png" alt="Example Program Plot for d02tgf-plot"/></div>
<hr/><div><a class="rout" href="../../pdf/D02/d02tgf.pdf">D02TGF (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>
