<?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>D01ANF : 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/D01/d01anf.pdf">D01ANF (PDF version)</a></div><div><a class="chap" href="d01conts.xml">D01 Chapter Contents</a></div><div><a class="chapint" href="d01intro.xml">D01 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/>D01ANF</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">D01ANF calculates an approximation to the sine or the cosine transform of a function <m:math><m:mi>g</m:mi></m:math>&#160;over <m:math><m:mfenced separators="" open="[" close="]"><m:mi>a</m:mi><m:mo>,</m:mo><m:mi>b</m:mi></m:mfenced></m:math>:

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>I</m:mi><m:mo>=</m:mo><m:munderover><m:mo>&#8747;</m:mo><m:mi>a</m:mi><m:mi>b</m:mi></m:munderover><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mrow><m:mi>sin</m:mi><m:mfenced separators=""><m:mi>&#969;</m:mi>  <m:mi>x</m:mi></m:mfenced></m:mrow><m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow><m:mtext>&#8195; or &#8195;</m:mtext><m:mi>I</m:mi><m:mo>=</m:mo><m:munderover><m:mo>&#8747;</m:mo><m:mi>a</m:mi><m:mi>b</m:mi></m:munderover><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mrow><m:mi>cos</m:mi><m:mfenced separators=""><m:mi>&#969;</m:mi>  <m:mi>x</m:mi></m:mfenced></m:mrow><m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow></m:math></td><td class="formula2"/></tr></table></div>

(for a user-specified value of <m:math><m:mi>&#969;</m:mi></m:math>).</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;D01ANF&#160;(</td><td class="tdfspec2"><a class="arg" href="#G">G</a>, <a class="arg" href="#A">A</a>, <a class="arg" href="#B">B</a>, <a class="arg" href="#OMEGA">OMEGA</a>, <a class="arg" href="#KEY">KEY</a>, <a class="arg" href="#EPSABS">EPSABS</a>, <a class="arg" href="#EPSREL">EPSREL</a>, <a class="arg" href="#RESULT">RESULT</a>, <a class="arg" href="#ABSERR">ABSERR</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">KEY, LW, IW(LIW), LIW, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">G, A, B, OMEGA, EPSABS, EPSREL, RESULT, ABSERR, W(LW)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">G</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D01ANF is based on the QUADPACK routine QFOUR (see <a class="ref" href="#ref010">Piessens <span class="italic">et al.</span> (1983)</a>).  It is an adaptive routine, designed to integrate a function of the form <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mi>w</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>, where  <m:math><m:mi>w</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;is either <m:math><m:mrow><m:mi>sin</m:mi><m:mfenced separators=""><m:mi>&#969;</m:mi><m:mi>x</m:mi></m:mfenced></m:mrow></m:math>&#160;or <m:math><m:mrow><m:mi>cos</m:mi><m:mfenced separators=""><m:mi>&#969;</m:mi><m:mi>x</m:mi></m:mfenced></m:mrow></m:math>.  If a sub-interval has length

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>L</m:mi><m:mo>=</m:mo><m:mfenced open="|" close="|" separators=""><m:mi>b</m:mi><m:mo>-</m:mo><m:mi>a</m:mi></m:mfenced><m:msup><m:mn>2</m:mn><m:mrow><m:mo>-</m:mo><m:mi>l</m:mi></m:mrow></m:msup>
</m:math></td><td class="formula2"/></tr></table></div>

then the integration over this sub-interval is performed by means of a modified Clenshaw&#8211;Curtis procedure (see <a class="ref" href="#ref013">Piessens and Branders (1975)</a>)  if <m:math><m:mi>L</m:mi><m:mi>&#969;</m:mi><m:mo>&gt;</m:mo><m:mn>4</m:mn></m:math>&#160;and <m:math><m:mi>l</m:mi><m:mo>&#8804;</m:mo><m:mn>20</m:mn><m:mtext>.</m:mtext></m:math>&#160;In this case a Chebyshev series approximation of degree <m:math><m:mn>24</m:mn></m:math>&#160;is used to approximate  <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>, while an error estimate is computed from this approximation together with that obtained using Chebyshev series of degree <m:math><m:mn>12</m:mn></m:math>.  If the above conditions do not hold then Gauss <m:math><m:mn>7</m:mn></m:math>-point and  Kronrod <m:math><m:mn>15</m:mn></m:math>-point rules are used.  The algorithm, described in  <a class="ref" href="#ref010">Piessens <span class="italic">et al.</span> (1983)</a>, incorporates a global acceptance criterion (as defined in <a class="ref" href="#ref009">Malcolm and Simpson (1976)</a>) together with the  <br/>
<m:math><m:mi>&#949;</m:mi></m:math>-algorithm (see <a class="ref" href="#ref011">Wynn (1956)</a>) to perform extrapolation.  The local error estimation is described in <br/>
<a class="ref" href="#ref010">Piessens <span class="italic">et al.</span> (1983)</a>.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref009" id="ref009"/>Malcolm M A and Simpson R B (1976)  Local versus global strategies for adaptive quadrature <i>ACM Trans. Math. Software</i> <b>1</b> 129&#8211;146 </div>
<div class="paramtext"><a name="ref013" id="ref013"/>Piessens R and Branders M (1975)  Algorithm 002. Computation of oscillating integrals <i>J. Comput. Appl. Math.</i> <b>1</b> 153&#8211;164 </div>
<div class="paramtext"><a name="ref010" id="ref010"/>Piessens R, de Doncker&#8211;Kapenga E, &#220;berhuber C and Kahaner D (1983)  <i>QUADPACK, A Subroutine Package for Automatic Integration</i> Springer&#8211;Verlag </div>
<div class="paramtext"><a name="ref011" id="ref011"/>Wynn P (1956)  On a device for computing the <m:math><m:msub><m:mi>e</m:mi><m:mi>m</m:mi></m:msub><m:mfenced separators=""><m:msub><m:mi mathvariant="normal">S</m:mi><m:mi>n</m:mi></m:msub></m:mfenced></m:math>&#160;transformation <i>Math. Tables Aids Comput.</i> <b>10</b> 91&#8211;96 </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="G" id="G"/>1: &#160;&#160;&#8194; G &#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="#G">G</a> must return the value of the function <m:math><m:mi>g</m:mi></m:math>&#160;at a given point <a class="arg" href="../D01/d01anf.xml#G_X">X</a>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#G">G</a> is:</div><table class="fspec"><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b>&#160;FUNCTION&#160;G&#160;(</td><td class="tdfspec2"><a class="arg" href="../D01/d01anf.xml#G_X">X</a>)</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="G_X" id="G_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>: the point at which the function <m:math><m:mi>g</m:mi></m:math>&#160;must be evaluated.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#G">G</a> must be declared as EXTERNAL in the (sub)program from which D01ANF 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="A" id="A"/>2: &#160;&#160;&#8194; A &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: <m:math><m:mi>a</m:mi></m:math>, the lower limit of integration.</div></dd><dt class="paramhead"><a name="B" id="B"/>3: &#160;&#160;&#8194; B &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: <m:math><m:mi>b</m:mi></m:math>, the upper limit of integration. It is not necessary that <m:math><m:mi>a</m:mi><m:mo>&lt;</m:mo><m:mi>b</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="OMEGA" id="OMEGA"/>4: &#160;&#160;&#8194; OMEGA &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the parameter <m:math><m:mi>&#969;</m:mi></m:math>&#160;in the weight function of the transform.</div></dd><dt class="paramhead"><a name="KEY" id="KEY"/>5: &#160;&#160;&#8194; KEY &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: indicates which integral is to be computed.

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#KEY"><m:mi mathcolor="#EE0000" mathvariant="bold">KEY</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd><m:math><m:mi>w</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>=</m:mo><m:mrow><m:mi>cos</m:mi><m:mfenced separators=""><m:mi>&#969;</m:mi><m:mi>x</m:mi></m:mfenced></m:mrow></m:math>.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#KEY"><m:mi mathcolor="#EE0000" mathvariant="bold">KEY</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math></dt>
<dd><m:math><m:mi>w</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>=</m:mo><m:mrow><m:mi>sin</m:mi><m:mfenced separators=""><m:mi>&#969;</m:mi><m:mi>x</m:mi></m:mfenced></m:mrow></m:math>.</dd></dl>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#KEY"><m:mi mathcolor="#EE0000" mathvariant="bold">KEY</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math>&#160;or <m:math><m:mn>2</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="EPSABS" id="EPSABS"/>6: &#160;&#160;&#8194; EPSABS &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the absolute accuracy required. If <a class="arg" href="#EPSABS">EPSABS</a> is negative, the absolute value is used. See <a class="sec" href="#accuracy">Section 7</a>.</div></dd><dt class="paramhead"><a name="EPSREL" id="EPSREL"/>7: &#160;&#160;&#8194; EPSREL &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the relative accuracy required. If <a class="arg" href="#EPSREL">EPSREL</a> is negative, the absolute value is used. See <a class="sec" href="#accuracy">Section 7</a>.</div></dd><dt class="paramhead"><a name="RESULT" id="RESULT"/>8: &#160;&#160;&#8194; RESULT &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: the approximation to the integral <m:math><m:mi>I</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="ABSERR" id="ABSERR"/>9: &#160;&#160;&#8194; ABSERR &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: an estimate of the modulus of the absolute error, which should be an upper bound for <m:math><m:mfenced open="|" close="|" separators=""><m:mi>I</m:mi><m:mo>-</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESULT"><m:mi mathcolor="#EE0000" mathvariant="bold">RESULT</m:mi></m:maction></m:mfenced></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">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: details of the computation, as described in <a class="sec" href="#fcomments">Section 8</a>.</div></dd><dt class="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 D01ANF is called. The value of <a class="arg" href="#LW">LW</a> (together with that of <a class="arg" href="#LIW">LIW</a>) imposes a bound on the number of sub-intervals into which the interval of integration may be divided by the routine. The number of sub-intervals cannot exceed <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>/</m:mo><m:mn>4</m:mn></m:math>. The more difficult the integrand, the larger <a class="arg" href="#LW">LW</a> should be.</div>
<div class="paramtext"><i>Suggested value</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>=</m:mo><m:mn>800</m:mn></m:math>&#160;to <m:math><m:mn>2000</m:mn></m:math>&#160;is adequate for most problems.

</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>4</m:mn></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">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#IW"><m:mi mathcolor="#EE0000" mathvariant="bold">IW</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>&#160;contains the actual number of sub-intervals used. The rest of the array is used as workspace.</div></dd><dt class="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 D01ANF is called. The number of sub-intervals into which the interval of integration may be divided cannot exceed <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>/</m:mo><m:mn>2</m:mn></m:math>.</div>
<div class="paramtext"><i>Suggested value</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>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#LW"><m:mi mathcolor="#EE0000" mathvariant="bold">LW</m:mi></m:maction><m:mo>/</m:mo><m:mn>2</m:mn></m:math>.
</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:mn>2</m:mn></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, because for this routine the values of the output parameters may be useful even if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>&#8800;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;on exit, the recommended value is <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>.  <b>When the value <m:math><m:mrow><m:mo>-</m:mo><m:mn mathvariant="bold">1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>&#160;is used it is essential to test the value of <a class="arg" href="#IFAIL">IFAIL</a> on exit.</b></div>
</div></dd></dl><h2 class="standard"><a class="sec" name="errors" id="errors"/>6&#160;&#160;Error Indicators and Warnings</h2>
<div class="paramtext">If on entry <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">-1</m:mn></m:maction></m:math>, explanatory error messages are output on the current error message unit (as defined by <a class="rout" href="../X04/x04aaf.xml">X04AAF</a>).</div><div class="paramtext"><b>Note:</b> D01ANF may return useful information for one or more of the following detected errors or warnings.</div><div class="paramtext">Errors or warnings detected by the routine:</div>
<dl class="ifail">
<dt class="errorhead"><a name="IFeq1" id="IFeq1"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd><div class="paramtext">The maximum number of subdivisions allowed with the given workspace has been reached without the accuracy requirements being achieved.  Look at the integrand in order to determine the integration difficulties.  If the position of a local difficulty within the interval can be determined (e.g., a singularity of the integrand or its derivative, a peak, a discontinuity, etc.) you will probably gain from splitting up the interval at this point and calling the integrator on the subranges.  If necessary, another integrator, which is designed for handling the type of difficulty involved, must be used.  Alternatively, consider relaxing the accuracy requirements specified by <a class="arg" href="#EPSABS">EPSABS</a> and <a class="arg" href="#EPSREL">EPSREL</a>, or increasing the amount of workspace.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq2" id="IFeq2"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math></dt>
<dd><div class="paramtext">Round-off error prevents the requested tolerance from being achieved.  Consider requesting less accuracy.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq3" id="IFeq3"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math></dt>
<dd><div class="paramtext">Extremely bad local behaviour of <m:math><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;causes a very strong subdivision around one (or more) points of the interval.  The same advice applies as in the case of <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq1"><m:mn mathcolor="#003399" mathvariant="bold">1</m:mn></m:maction></m:math>.</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 requested tolerance cannot be achieved because the extrapolation does not increase the accuracy satisfactorily; the returned result is the best which can be obtained.  The same advice applies as in the case of <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq1"><m:mn mathcolor="#003399" mathvariant="bold">1</m:mn></m:maction></m:math>.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq5" id="IFeq5"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>5</m:mn></m:math></dt>
<dd><div class="paramtext">The integral is probably divergent, or slowly convergent.  Please note that divergence can occur with any nonzero value of <a class="arg" href="#IFAIL">IFAIL</a>.</div></dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq6" id="IFeq6"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>6</m:mn></m:math></dt>
<dd>
<div class="paramtext">On entry, <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#KEY"><m:mi mathcolor="#EE0000" mathvariant="bold">KEY</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mn>1</m:mn></m:math>&#160;or <m:math><m:mn>2</m:mn></m:math>.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq7" id="IFeq7"/><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>7</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>4</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="#LIW"><m:mi mathcolor="#EE0000" mathvariant="bold">LIW</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>2</m:mn></m:math>.</td></tr></table></dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">D01ANF cannot guarantee, but in practice usually achieves, the following accuracy:

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mfenced open="|" close="|" separators=""><m:mi>I</m:mi><m:mo>-</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESULT"><m:mi mathcolor="#EE0000" mathvariant="bold">RESULT</m:mi></m:maction></m:mfenced><m:mo>&#8804;</m:mo><m:mi mathvariant="italic">tol</m:mi><m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

where

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi mathvariant="italic">tol</m:mi><m:mo>=</m:mo><m:mrow><m:mi>max</m:mi><m:mspace width="0.125em"/><m:mfenced open="{" close="}" separators=""><m:mfenced open="|" close="|" separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#EPSABS"><m:mi mathcolor="#EE0000" mathvariant="bold">EPSABS</m:mi></m:maction></m:mfenced><m:mo>,</m:mo><m:mfenced open="|" close="|" separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#EPSREL"><m:mi mathcolor="#EE0000" mathvariant="bold">EPSREL</m:mi></m:maction></m:mfenced><m:mo>&#215;</m:mo><m:mfenced open="|" close="|" separators=""><m:mi>I</m:mi></m:mfenced></m:mfenced></m:mrow> <m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

and <a class="arg" href="#EPSABS">EPSABS</a> and <a class="arg" href="#EPSREL">EPSREL</a> are user-specified absolute and relative tolerances.  Moreover, it returns the quantity <a class="arg" href="#ABSERR">ABSERR</a> which in normal circumstances, satisfies

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mfenced open="|" close="|" separators=""><m:mi>I</m:mi><m:mo>-</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESULT"><m:mi mathcolor="#EE0000" mathvariant="bold">RESULT</m:mi></m:maction></m:mfenced><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#ABSERR"><m:mi mathcolor="#EE0000" mathvariant="bold">ABSERR</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mi mathvariant="italic">tol</m:mi><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div></div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The time taken by D01ANF depends on the integrand and the accuracy required.</div><div class="paramtext">If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>&#8800;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;on exit, then you may wish to examine the contents of the array <a class="arg" href="#W">W</a>, which contains the end points of the sub-intervals used by D01ANF along with the integral contributions and error estimates over these sub-intervals.</div><div class="paramtext">Specifically, 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>, let <m:math><m:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;denote the approximation to the value of the integral over the sub-interval <m:math><m:mfenced separators="" open="[" close="]"><m:msub><m:mi>a</m:mi><m:mi>i</m:mi></m:msub><m:mo>,</m:mo><m:msub><m:mi>b</m:mi><m:mi>i</m:mi></m:msub></m:mfenced></m:math>&#160;in the partition of <m:math><m:mfenced separators="" open="[" close="]"><m:mi>a</m:mi><m:mo>,</m:mo><m:mi>b</m:mi></m:mfenced></m:math>&#160;and <m:math><m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;be the corresponding absolute error estimate.  Then, <m:math><m:mstyle displaystyle="true"><m:munderover><m:mo>&#8747;</m:mo><m:msub><m:mi>a</m:mi><m:mi>i</m:mi></m:msub><m:msub><m:mi>b</m:mi><m:mi>i</m:mi></m:msub></m:munderover></m:mstyle><m:mi>g</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mi>w</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow><m:mo>&#8771;</m:mo><m:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;and <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESULT"><m:mi mathcolor="#EE0000" mathvariant="bold">RESULT</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:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;unless D01ANF  terminates while testing for divergence of the integral (see Section 3.4.3 of <a class="ref" href="#ref010">Piessens <span class="italic">et al.</span> (1983)</a>).  In this case, <a class="arg" href="#RESULT">RESULT</a> (and <a class="arg" href="#ABSERR">ABSERR</a>) are taken to be the values returned from the extrapolation process.  The value of <m:math><m:mi>n</m:mi></m:math>&#160;is returned in 
<m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#IW"><m:mi mathcolor="#EE0000" mathvariant="bold">IW</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>,
 
and the values <m:math><m:msub><m:mi>a</m:mi><m:mi>i</m:mi></m:msub></m:math>, <m:math><m:msub><m:mi>b</m:mi><m:mi>i</m:mi></m:msub></m:math>, <m:math><m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;are stored consecutively in the 
array <a class="arg" href="#W">W</a>,

that is:
<ul class="listind"><li class="listind"><m:math><m:msub><m:mi>a</m:mi><m:mi>i</m:mi></m:msub><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#W"><m:mi mathcolor="#EE0000" mathvariant="bold">W</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>,</li><li class="listind"><m:math><m:msub><m:mi>b</m:mi><m:mi>i</m:mi></m:msub><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#W"><m:mi mathcolor="#EE0000" mathvariant="bold">W</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mrow><m:mi>n</m:mi><m:mo>+</m:mo><m:mi>i</m:mi></m:mrow></m:mfenced></m:mrow></m:math>,</li><li class="listind"><m:math><m:msub><m:mi>e</m:mi><m:mi>i</m:mi></m:msub><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#W"><m:mi mathcolor="#EE0000" mathvariant="bold">W</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mrow><m:mn>2</m:mn><m:mi>n</m:mi><m:mo>+</m:mo><m:mi>i</m:mi></m:mrow></m:mfenced></m:mrow></m:math>&#160;and</li><li class="listind"><m:math><m:msub><m:mi>r</m:mi><m:mi>i</m:mi></m:msub><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#W"><m:mi mathcolor="#EE0000" mathvariant="bold">W</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mrow><m:mn>3</m:mn><m:mi>n</m:mi><m:mo>+</m:mo><m:mi>i</m:mi></m:mrow></m:mfenced></m:mrow></m:math>.</li></ul></div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example computes

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:munderover><m:mo>&#8747;</m:mo><m:mn>0</m:mn><m:mn>1</m:mn></m:munderover><m:mrow><m:mi>ln</m:mi><m:mo>&#8289;</m:mo><m:mi>x</m:mi></m:mrow>  <m:mrow><m:mi>sin</m:mi><m:mfenced separators=""><m:mn>10</m:mn><m:mi>&#960;</m:mi><m:mi>x</m:mi></m:mfenced></m:mrow><m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div></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/d01anfe.f">Program Text (d01anfe.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/d01anfe.r">Program Results (d01anfe.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/D01/d01anf.pdf">D01ANF (PDF version)</a></div><div><a class="chap" href="d01conts.xml">D01 Chapter Contents</a></div><div><a class="chapint" href="d01intro.xml">D01 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>
