<?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>D01BDF : 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/d01bdf.pdf">D01BDF (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/>D01BDF</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">D01BDF calculates an approximation to the integral of a function over a finite interval <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>f</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:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

It is non-adaptive and as such is recommended for the integration of &#8216;smooth&#8217; functions.  These <b>exclude</b> integrands with singularities, derivative singularities or high peaks on <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>,  or which oscillate too strongly on <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><h2 class="standard"><a class="sec" name="specification" id="specification"/>2&#160;&#160;Specification</h2>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;D01BDF&#160;(</td><td class="tdfspec2"><a class="arg" href="#F">F</a>, <a class="arg" href="#A">A</a>, <a class="arg" href="#B">B</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>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">F, A, B, EPSABS, EPSREL, RESULT, ABSERR</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">F</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D01BDF is based on the QUADPACK routine QNG (see <a class="ref" href="#ref010">Piessens <span class="italic">et al.</span> (1983)</a>).  It is a non-adaptive routine which uses as its basic rules, the Gauss <m:math><m:mn>10</m:mn></m:math>-point and <m:math><m:mn>21</m:mn></m:math>-point formulae.  If the accuracy criterion is not met, formulae using <m:math><m:mn>43</m:mn></m:math>&#160;and <m:math><m:mn>87</m:mn></m:math>&#160;points are used successively,  stopping whenever the accuracy criterion is satisfied.</div><div class="paramtext">This routine is designed for smooth integrands only.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref269" id="ref269"/>Patterson T N L (1968)  The Optimum addition of points to quadrature formulae <i>Math. Comput.</i> <b>22</b> 847&#8211;856 </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><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="F" id="F"/>1: &#160;&#160;&#8194; F &#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="#F">F</a> must return the value of the integrand <m:math><m:mi>f</m:mi></m:math>&#160;at a given point.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#F">F</a> is:</div><table class="fspec"><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b>&#160;FUNCTION&#160;F&#160;(</td><td class="tdfspec2"><a class="arg" href="../D01/d01bdf.xml#F_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="F_X" id="F_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 integrand <m:math><m:mi>f</m:mi></m:math>&#160;must be evaluated.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#F">F</a> must be declared as EXTERNAL in the (sub)program from which D01BDF 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="EPSABS" id="EPSABS"/>4: &#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"/>5: &#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"/>6: &#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"/>7: &#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></dl><h2 class="standard"><a class="sec" name="errors" id="errors"/>6&#160;&#160;Error Indicators and Warnings</h2>
<div class="paramtext">There are no specific errors detected by D01BDF.  However, if <a class="arg" href="#ABSERR">ABSERR</a> is greater than

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mrow><m:mi>max</m:mi><m:mspace width="0.125em"/><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:mo>,</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#EPSREL"><m:mi mathcolor="#EE0000" mathvariant="bold">EPSREL</m:mi></m:maction><m:mo>&#215;</m:mo><m:mfenced open="|" close="|" separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#RESULT"><m:mi mathcolor="#EE0000" mathvariant="bold">RESULT</m:mi></m:maction></m:mfenced></m:mfenced></m:mrow>
</m:math></td><td class="formula2"/></tr></table></div>

this indicates that the routine has probably failed to achieve the requested accuracy within <m:math><m:mn>87</m:mn></m:math>&#160;function evaluations.</div><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">D01BDF attempts to compute an approximation, <a class="arg" href="#RESULT">RESULT</a>, such that:

<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 error tolerances.  There can be no guarantee that this is achieved, and you are advised to subdivide the interval if you have any doubts about the accuracy obtained.  Note that <a class="arg" href="#ABSERR">ABSERR</a> contains an estimated bound on <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><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The time taken by D01BDF depends on the integrand and the accuracy required.</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:msup><m:mi>x</m:mi><m:mn>2</m:mn></m:msup>
 <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/d01bdfe.f">Program Text (d01bdfe.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/d01bdfe.r">Program Results (d01bdfe.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/D01/d01bdf.pdf">D01BDF (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>
