<?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>D01GBF : 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/d01gbf.pdf">D01GBF (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/>D01GBF</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">D01GBF returns an approximation to the integral of a function over a hyper-rectangular region, using a Monte Carlo method.  An approximate relative error estimate is also returned.  This routine is suitable for low accuracy work.</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;D01GBF&#160;(</td><td class="tdfspec2"><a class="arg" href="#NDIM">NDIM</a>, <a class="arg" href="#A">A</a>, <a class="arg" href="#B">B</a>, <a class="arg" href="#MINCLS">MINCLS</a>, <a class="arg" href="#MAXCLS">MAXCLS</a>, <a class="arg" href="#FUNCTN">FUNCTN</a>, <a class="arg" href="#EPS">EPS</a>, <a class="arg" href="#ACC">ACC</a>, <a class="arg" href="#LENWRK">LENWRK</a>, <a class="arg" href="#WRKSTR">WRKSTR</a>, <a class="arg" href="#FINEST">FINEST</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NDIM, MINCLS, MAXCLS, LENWRK, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">A(NDIM), B(NDIM), FUNCTN, EPS, ACC, WRKSTR(LENWRK), FINEST</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">FUNCTN</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D01GBF uses an adaptive Monte Carlo method based on the algorithm described in <a class="ref" href="#ref023">Lautrup (1971)</a>.  It is implemented for integrals of the form:

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:munderover>
  <m:mo>&#8747;</m:mo>
  <m:msub><m:mi>a</m:mi><m:mn>1</m:mn></m:msub>
  <m:msub><m:mi>b</m:mi><m:mn>1</m:mn></m:msub>
 </m:munderover>
 <m:munderover>
  <m:mo>&#8747;</m:mo>
  <m:msub><m:mi>a</m:mi><m:mn>2</m:mn></m:msub>
  <m:msub><m:mi>b</m:mi><m:mn>2</m:mn></m:msub>
 </m:munderover>
 <m:mo>&#8943;</m:mo>
 <m:munderover>
  <m:mo>&#8747;</m:mo>
  <m:msub><m:mi>a</m:mi><m:mi>n</m:mi></m:msub>
  <m:msub><m:mi>b</m:mi><m:mi>n</m:mi></m:msub>
 </m:munderover>
 <m:mi>f</m:mi>
 <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>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>x</m:mi><m:mi>n</m:mi></m:msub></m:mfenced>
 <m:mrow><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mi>n</m:mi></m:msub></m:mrow>
 <m:mo>&#8943;</m:mo>
 <m:mrow><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mn>2</m:mn></m:msub></m:mrow>
 <m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub>
 <m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div></div><div class="paramtext">Upon entry, unless <a class="arg" href="#LENWRK">LENWRK</a> has been set to the minimum value  <m:math><m:mn>10</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction></m:math>, the routine subdivides the integration region into a number of equal volume subregions.  Inside each subregion the integral and the variance are estimated by means of pseudorandom sampling.  All contributions are added together to produce an estimate for the whole integral and total variance.  The variance along each co-ordinate axis is determined and the routine uses this information to increase the density and change the widths of the sub-intervals along each axis, so as to reduce the total variance.  The total number of subregions is then increased by a factor of two and the program recycles for another iteration.  The program stops when a desired accuracy has been reached or too many integral evaluations are needed for the next cycle.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref023" id="ref023"/>Lautrup B (1971)  An adaptive multi-dimensional integration procedure <i>Proc. 2nd Coll. Advanced Methods in Theoretical Physics, Marseille</i> </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="NDIM" id="NDIM"/>1: &#160;&#160;&#8194; NDIM &#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 dimensions of the integral.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="A" id="A"/>2: &#160;&#160;&#8194; A(<a class="arg" href="#NDIM">NDIM</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the lower limits of integration, <m:math><m:msub><m:mi>a</m:mi><m:mi>i</m:mi></m:msub></m:math>, 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></dd><dt class="paramhead"><a name="B" id="B"/>3: &#160;&#160;&#8194; B(<a class="arg" href="#NDIM">NDIM</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the upper limits of integration, <m:math><m:msub><m:mi>b</m:mi><m:mi>i</m:mi></m:msub></m:math>, 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></dd><dt class="paramhead"><a name="MINCLS" id="MINCLS"/>4: &#160;&#160;&#8194; MINCLS &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: must be set
<ul class="listind"><li class="listind">either to the minimum number of integrand evaluations to be allowed, in which case <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MINCLS"><m:mi mathcolor="#EE0000" mathvariant="bold">MINCLS</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>0</m:mn></m:math>;</li><li class="listind">or to a negative value. In this case, the routine assumes that a previous call had been made with the same parameters <a class="arg" href="#NDIM">NDIM</a>, <a class="arg" href="#A">A</a> and <a class="arg" href="#B">B</a> and with either the same integrand (in which case D01GBF continues calculation) or a similar integrand (in which case D01GBF begins the calculation with the subdivision used in the last iteration of the previous call). See also <a class="arg" href="#WRKSTR">WRKSTR</a>.</li></ul>
</div>
<div class="paramtext"><i>On exit</i>: contains the number of integrand evaluations actually used by D01GBF.</div></dd><dt class="paramhead"><a name="MAXCLS" id="MAXCLS"/>5: &#160;&#160;&#8194; MAXCLS &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the maximum number of integrand evaluations to be allowed. In the continuation case this is the number of new integrand evaluations to be allowed. These counts do not include zero integrand values.</div><div class="paramtext"><i>Constraints</i>:
   <div class="paramtext"/><ul class="listcons">
<li class="listcons"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MAXCLS"><m:mi mathcolor="#EE0000" mathvariant="bold">MAXCLS</m:mi></m:maction><m:mo>&gt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#MINCLS"><m:mi mathcolor="#EE0000" mathvariant="bold">MINCLS</m:mi></m:maction></m:math>;</li>
<li class="listcons"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MAXCLS"><m:mi mathcolor="#EE0000" mathvariant="bold">MAXCLS</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>4</m:mn><m:mo>&#215;</m:mo><m:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction><m:mo>+</m:mo><m:mn>1</m:mn></m:mfenced></m:math>.</li>
</ul></div></dd><dt class="paramhead"><a name="FUNCTN" id="FUNCTN"/>6: &#160;&#160;&#8194; FUNCTN &#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="#FUNCTN">FUNCTN</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="#FUNCTN">FUNCTN</a> is:</div><table class="fspec"><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b>&#160;FUNCTION&#160;FUNCTN&#160;(</td><td class="tdfspec2"><a class="arg" href="../D01/d01gbf.xml#FUNCTN_NDIM">NDIM</a>, <a class="arg" href="../D01/d01gbf.xml#FUNCTN_X">X</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NDIM</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X(NDIM)</td></tr></table>
<dl><dt class="paramhead"><a name="FUNCTN_NDIM" id="FUNCTN_NDIM"/>1: &#160;&#160;&#8194; NDIM &#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 dimensions of the integral.</div></dd><dt class="paramhead"><a name="FUNCTN_X" id="FUNCTN_X"/>2: &#160;&#160;&#8194; X(<a class="arg" href="../D01/d01gbf.xml#FUNCTN_NDIM">NDIM</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the co-ordinates of 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="#FUNCTN">FUNCTN</a> must be declared as EXTERNAL in the (sub)program from which D01GBF 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="EPS" id="EPS"/>7: &#160;&#160;&#8194; EPS &#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.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#EPS"><m:mi mathcolor="#EE0000" mathvariant="bold">EPS</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>0.0</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="ACC" id="ACC"/>8: &#160;&#160;&#8194; ACC &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: the estimated relative accuracy of <a class="arg" href="#FINEST">FINEST</a>.</div></dd><dt class="paramhead"><a name="LENWRK" id="LENWRK"/>9: &#160;&#160;&#8194; LENWRK &#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="#WRKSTR">WRKSTR</a> as declared in the (sub)program from which D01GBF is called.
<div class="paramtext">For maximum efficiency, <a class="arg" href="#LENWRK">LENWRK</a> should be about 
<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block"> <m:mn>3</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction><m:mo>&#215;</m:mo><m:msup><m:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#MAXCLS"><m:mi mathcolor="#EE0000" mathvariant="bold">MAXCLS</m:mi></m:maction><m:mo>/</m:mo><m:mn>4</m:mn></m:mfenced><m:mrow><m:mn>1</m:mn><m:mo>/</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction></m:mrow></m:msup><m:mo>+</m:mo><m:mn>7</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction><m:mtext>.</m:mtext> </m:math></td><td class="formula2"/></tr></table></div>
 If <a class="arg" href="#LENWRK">LENWRK</a> is given the value <m:math><m:mn>10</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction></m:math>&#160;then the subroutine uses only one iteration of a crude Monte Carlo method with <a class="arg" href="#MAXCLS">MAXCLS</a> sample points.</div>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#LENWRK"><m:mi mathcolor="#EE0000" mathvariant="bold">LENWRK</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>10</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction></m:math>.
</div></dd><dt class="paramhead"><a name="WRKSTR" id="WRKSTR"/>10: &#8194; WRKSTR(<a class="arg" href="#LENWRK">LENWRK</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MINCLS"><m:mi mathcolor="#EE0000" mathvariant="bold">MINCLS</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>0</m:mn></m:math>, <a class="arg" href="#WRKSTR">WRKSTR</a> must be unchanged from the previous call of D01GBF &#8211; except that for a new integrand <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#WRKSTR"><m:mi mathcolor="#EE0000" mathvariant="bold">WRKSTR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:maction actiontype="link" dsi:type="simple" dsi:href="#LENWRK"><m:mi mathcolor="#EE0000" mathvariant="bold">LENWRK</m:mi></m:maction></m:mfenced></m:mrow></m:math>&#160;must be set to <m:math><m:mn>0.0</m:mn></m:math>. See also <a class="arg" href="#MINCLS">MINCLS</a>.</div>
<div class="paramtext"><i>On exit</i>: contains information about the current sub-interval structure which could be used in later calls of D01GBF. In particular, <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#WRKSTR"><m:mi mathcolor="#EE0000" mathvariant="bold">WRKSTR</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>j</m:mi></m:mfenced></m:mrow></m:math>&#160;gives the number of sub-intervals used along the <m:math><m:mi>j</m:mi></m:math>th co-ordinate axis.</div></dd><dt class="paramhead"><a name="FINEST" id="FINEST"/>11: &#8194; FINEST &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: must be unchanged from a previous call to D01GBF.</div>
<div class="paramtext"><i>On exit</i>: the best estimate obtained for the integral.</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>12: &#8194; IFAIL &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: <a class="arg" href="#IFAIL">IFAIL</a> must be set to <m:math><m:mn>0</m:mn></m:math>, <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>. If you are unfamiliar with this parameter you should refer to <a class="sec" href="../GENINT/essint.xml#library3">Section 3.3</a> in  the Essential Introduction for details.</div>
<div class="paramtext"><i>On exit</i>: <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;unless the routine detects an error (see <a class="sec" href="#errors">Section 6</a>).
<div class="paramtext">For environments where it might be inappropriate to halt program execution when an error is detected, the value <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>&#160;is recommended.  If the output of error messages is undesirable, then the value <m:math><m:mn>1</m:mn></m:math>&#160;is recommended.  Otherwise, 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">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="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>1</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MINCLS"><m:mi mathcolor="#EE0000" mathvariant="bold">MINCLS</m:mi></m:maction><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#MAXCLS"><m:mi mathcolor="#EE0000" mathvariant="bold">MAXCLS</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="#LENWRK"><m:mi mathcolor="#EE0000" mathvariant="bold">LENWRK</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>10</m:mn><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</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="#MAXCLS"><m:mi mathcolor="#EE0000" mathvariant="bold">MAXCLS</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>4</m:mn><m:mo>&#215;</m:mo><m:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction><m:mo>+</m:mo><m:mn>1</m:mn></m:mfenced></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="#EPS"><m:mi mathcolor="#EE0000" mathvariant="bold">EPS</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>0.0</m:mn></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>
<div class="paramtext"><a class="arg" href="#MAXCLS">MAXCLS</a> was too small for D01GBF to obtain the required relative accuracy <a class="arg" href="#EPS">EPS</a>.  In this case D01GBF returns a value of <a class="arg" href="#FINEST">FINEST</a> with estimated relative error <a class="arg" href="#ACC">ACC</a>, but <a class="arg" href="#ACC">ACC</a> will be greater than <a class="arg" href="#EPS">EPS</a>.  This error exit may be taken before <a class="arg" href="#MAXCLS">MAXCLS</a> nonzero integrand evaluations have actually occurred, if the routine calculates that the current estimates could not be improved before <a class="arg" href="#MAXCLS">MAXCLS</a> was exceeded.</div>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">A relative error estimate is output through the parameter <a class="arg" href="#ACC">ACC</a>.  The confidence factor is set so that the actual error should be less than <a class="arg" href="#ACC">ACC</a> 90% of the time.  If you want a higher confidence level then a smaller value of <a class="arg" href="#EPS">EPS</a> should be used.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The running time for D01GBF will usually be dominated by the time used to evaluate <a class="arg" href="#FUNCTN">FUNCTN</a>, so the maximum time that could be used is approximately proportional to <a class="arg" href="#MAXCLS">MAXCLS</a>.</div><div class="paramtext">For some integrands, particularly those that are poorly behaved in a small part of the integration region, D01GBF may terminate with a value of <a class="arg" href="#ACC">ACC</a> which is significantly smaller than the actual relative error.  This should be suspected if the returned value of <a class="arg" href="#MINCLS">MINCLS</a> is small relative to the expected difficulty of the integral.  Where this occurs, D01GBF should be called again, but with a higher entry value of <a class="arg" href="#MINCLS">MINCLS</a> (e.g., twice the returned value) and the results compared with those from the previous call.</div>
<div class="paramtext">The exact values of <a class="arg" href="#FINEST">FINEST</a> and <a class="arg" href="#ACC">ACC</a> on return will depend (within statistical limits) on the sequence of random numbers generated within D01GBF by calls to <a class="rout" href="../G05/g05saf.xml">G05SAF</a>.  Separate runs will produce identical answers.</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example calculates the integral

<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:munderover><m:mo>&#8747;</m:mo><m:mn>0</m:mn><m:mn>1</m:mn></m:munderover><m:munderover><m:mo>&#8747;</m:mo><m:mn>0</m:mn><m:mn>1</m:mn></m:munderover><m:munderover><m:mo>&#8747;</m:mo><m:mn>0</m:mn><m:mn>1</m:mn></m:munderover><m:mfrac><m:mrow><m:mn>4</m:mn><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub><m:msub><m:mi>x</m:mi><m:mn>3</m:mn></m:msub><m:mrow><m:mi>exp</m:mi><m:mfenced separators=""><m:mn>2</m:mn><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub><m:msub><m:mi>x</m:mi><m:mn>3</m:mn></m:msub></m:mfenced></m:mrow></m:mrow><m:msup>
<m:mfenced separators=""><m:mn>1</m:mn><m:mo>+</m:mo><m:msub><m:mi>x</m:mi><m:mn>2</m:mn></m:msub><m:mo>+</m:mo><m:msub><m:mi>x</m:mi><m:mn>4</m:mn></m:msub></m:mfenced>
<m:mn>2</m:mn></m:msup></m:mfrac><m:mrow><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:mrow><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mn>2</m:mn></m:msub><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mn>3</m:mn></m:msub><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mn>4</m:mn></m:msub><m:mo>=</m:mo><m:mn>0.575364</m:mn><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/d01gbfe.f">Program Text (d01gbfe.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/d01gbfe.r">Program Results (d01gbfe.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/D01/d01gbf.pdf">D01GBF (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>
