<?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>D01GDF : 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/d01gdf.pdf">D01GDF (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/>D01GDF</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">D01GDF calculates an approximation to a definite integral in up to <m:math><m:mn>20</m:mn></m:math>&#160;dimensions, using the Korobov&#8211;Conroy number theoretic method.  This routine is designed to be particularly efficient on vector processors.</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;D01GDF&#160;(</td><td class="tdfspec2"><a class="arg" href="#NDIM">NDIM</a>, <a class="arg" href="#VECFUN">VECFUN</a>, <a class="arg" href="#VECREG">VECREG</a>, <a class="arg" href="#NPTS">NPTS</a>, <a class="arg" href="#VK">VK</a>, <a class="arg" href="#NRAND">NRAND</a>, <a class="arg" href="#ITRANS">ITRANS</a>, <a class="arg" href="#RES">RES</a>, <a class="arg" href="#ERR">ERR</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NDIM, NPTS, NRAND, ITRANS, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">VK(NDIM), RES, ERR</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">VECFUN, VECREG</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D01GDF calculates an approximation to the integral

<div class="formula-eqn"><a name="eqn1" id="eqn1"/><table class="formula-eqn"><tr><td class="formula-eqn"><m:math display="block">
 <m:mi>I</m:mi><m:mo>=</m:mo>
 <m:munderover>
  <m:mo>&#8747;</m:mo>
  <m:msub><m:mi>c</m:mi><m:mn>1</m:mn></m:msub>
  <m:msub><m:mi>d</m:mi><m:mn>1</m:mn></m:msub>
 </m:munderover>
 <m:mo>&#8943;</m:mo>
 <m:munderover>
  <m:mo>&#8747;</m:mo>
  <m:msub><m:mi>c</m:mi><m:mi>n</m:mi></m:msub>
  <m:msub><m:mi>d</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: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>&#8230;</m:mo>
 <m:mrow><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:mrow>
</m:math></td><td class="formula-eqn2">
      (1)
     </td></tr></table></div>

using the Korobov&#8211;Conroy number theoretic method (see <a class="ref" href="#ref275">Korobov (1957)</a>, <a class="ref" href="#ref276">Korobov (1963)</a> and <a class="ref" href="#ref278">Conroy (1967)</a>).  The region of integration defined in <a class="eqn" href="#eqn1">(1)</a> is such that generally <m:math>
 <m:msub><m:mi>c</m:mi><m:mi>i</m:mi></m:msub>
</m:math>&#160;and <m:math>
 <m:msub><m:mi>d</m:mi><m:mi>i</m:mi></m:msub>
</m:math>&#160;may be functions of <m:math>
 <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:mrow><m:mi>i</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msub>
</m:math>, for <m:math>
 <m:mi>i</m:mi><m:mo>=</m:mo>
 <m:mn>2</m:mn>
 <m:mo>,</m:mo>
 <m:mn>3</m:mn>
 <m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo>
 <m:mi>n</m:mi>
</m:math>,  with <m:math>
 <m:msub><m:mi>c</m:mi><m:mn>1</m:mn></m:msub>
</m:math>&#160;and <m:math>
 <m:msub><m:mi>d</m:mi><m:mn>1</m:mn></m:msub>
</m:math>&#160;constants.  The integral is first of all transformed to an integral over the <m:math><m:mi>n</m:mi></m:math>-cube <m:math>
 <m:msup>
  <m:mfenced separators="" open="[" close="]"><m:mn>0</m:mn><m:mo>,</m:mo><m:mn>1</m:mn></m:mfenced>
  <m:mi>n</m:mi>
 </m:msup>
</m:math>&#160;by the change of variables

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub>
 <m:mo>=</m:mo>
 <m:msub><m:mi>c</m:mi><m:mi>i</m:mi></m:msub>
 <m:mo>+</m:mo>
 <m:mfenced separators="">
  <m:msub><m:mi>d</m:mi><m:mi>i</m:mi></m:msub>
  <m:mo>-</m:mo>
  <m:msub><m:mi>c</m:mi><m:mi>i</m:mi></m:msub>
 </m:mfenced>
 <m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub>
 <m:mtext>, &#8195;</m:mtext>
 <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:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

The method then uses as its basis the number theoretic formula for the <m:math><m:mi>n</m:mi></m:math>-cube, <m:math>
 <m:msup>
  <m:mfenced separators="" open="[" close="]"><m:mn>0</m:mn><m:mo>,</m:mo><m:mn>1</m:mn></m:mfenced>
  <m:mi>n</m:mi>
 </m:msup>
</m:math>:

<div class="formula-eqn"><a name="eqn2" id="eqn2"/><table class="formula-eqn"><tr><td class="formula-eqn"><m:math display="block">
 <m:munderover><m:mo>&#8747;</m:mo><m:mn>0</m:mn><m:mn>1</m:mn></m:munderover>
 <m:mo>&#8943;</m:mo>
 <m:munderover><m:mo>&#8747;</m:mo><m:mn>0</m:mn><m:mn>1</m:mn></m:munderover>
 <m:mi>g</m:mi>
 <m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>1</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>1</m:mn></m:msub></m:mrow>
 <m:mo>=</m:mo>
 <m:mfrac other="small"><m:mn>1</m:mn><m:mi>p</m:mi></m:mfrac>
 <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>p</m:mi></m:munderover>
 <m:mi>g</m:mi>
 <m:mfenced separators=""><m:mfenced open="{" close="}" separators="">
   <m:mi>k</m:mi>
   <m:mfrac><m:msub><m:mi>a</m:mi><m:mn>1</m:mn></m:msub><m:mi>p</m:mi></m:mfrac>
  </m:mfenced><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mfenced open="{" close="}" separators="">
   <m:mi>k</m:mi>
   <m:mfrac><m:msub><m:mi>a</m:mi><m:mi>n</m:mi></m:msub><m:mi>p</m:mi></m:mfrac>
  </m:mfenced></m:mfenced>
 <m:mo>-</m:mo>
 <m:mi>E</m:mi>
</m:math></td><td class="formula-eqn2">
      (2)
     </td></tr></table></div>

where <m:math>
 <m:mfenced open="{" close="}" separators=""><m:mi>x</m:mi></m:mfenced>
</m:math>&#160;denotes the fractional part of <m:math><m:mi>x</m:mi></m:math>, <m:math>
 <m:msub><m:mi>a</m:mi><m:mn>1</m:mn></m:msub>
 <m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo>
 <m:msub><m:mi>a</m:mi><m:mi>n</m:mi></m:msub>
</m:math>&#160;are the so-called optimal coefficients, <m:math><m:mi>E</m:mi></m:math>&#160;is the error, and <m:math><m:mi>p</m:mi></m:math>&#160;is a prime integer.  (It is strictly only necessary that <m:math><m:mi>p</m:mi></m:math>&#160;be relatively prime to all <m:math>
 <m:msub><m:mi>a</m:mi><m:mn>1</m:mn></m:msub>
 <m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo>
 <m:msub><m:mi>a</m:mi><m:mi>n</m:mi></m:msub>
</m:math>&#160;and is in fact chosen to be even for some cases in <a class="ref" href="#ref278">Conroy (1967)</a>.)  The method makes use of properties of the Fourier expansion of <m:math>
 <m:mi>g</m:mi>
 <m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>1</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:math>&#160;which is assumed to have some degree of periodicity.  Depending on the choice of <m:math>
 <m:msub><m:mi>a</m:mi><m:mn>1</m:mn></m:msub>
 <m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo>
 <m:msub><m:mi>a</m:mi><m:mi>n</m:mi></m:msub>
</m:math>&#160;the contributions from certain groups of Fourier coefficients are eliminated from the error, <m:math><m:mi>E</m:mi></m:math>.  Korobov shows that <m:math>
 <m:msub><m:mi>a</m:mi><m:mn>1</m:mn></m:msub>
 <m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo>
 <m:msub><m:mi>a</m:mi><m:mi>n</m:mi></m:msub>
</m:math>&#160;can be chosen so that the error satisfies

<div class="formula-eqn"><a name="eqn3" id="eqn3"/><table class="formula-eqn"><tr><td class="formula-eqn"><m:math display="block">
 <m:mi>E</m:mi><m:mo>&#8804;</m:mo><m:mi>C</m:mi><m:mi>K</m:mi>
 <m:msup><m:mi>p</m:mi><m:mrow><m:mo>-</m:mo><m:mi>&#945;</m:mi></m:mrow></m:msup>
 <m:mrow>
   <m:msup>
    <m:mi mathvariant="normal">ln</m:mi>
    <m:mrow><m:mi>&#945;</m:mi><m:mi>&#946;</m:mi></m:mrow>
   </m:msup>
  <m:mo>&#8289;</m:mo><m:mi>p</m:mi></m:mrow>
</m:math></td><td class="formula-eqn2">
      (3)
     </td></tr></table></div>

where <m:math><m:mi>&#945;</m:mi></m:math>&#160;and <m:math><m:mi>C</m:mi></m:math>&#160;are real numbers depending on the convergence rate of the Fourier series, <m:math><m:mi>&#946;</m:mi></m:math>&#160;is a constant depending on <m:math><m:mi>n</m:mi></m:math>, and <m:math><m:mi>K</m:mi></m:math>&#160;is a constant depending on <m:math><m:mi>&#945;</m:mi></m:math>&#160;and <m:math><m:mi>n</m:mi></m:math>.  There are a number of procedures for calculating these optimal coefficients.  Korobov imposes the constraint that

<div class="formula-eqn"><a name="eqn4" id="eqn4"/><table class="formula-eqn"><tr><td class="formula-eqn"><m:math display="block">
 <m:msub><m:mi>a</m:mi><m:mn>1</m:mn></m:msub>
 <m:mo>=</m:mo>
 <m:mn>1</m:mn>
 <m:mtext>&#8195; and &#8195;</m:mtext>
 <m:msub><m:mi>a</m:mi><m:mi>i</m:mi></m:msub>
 <m:mo>=</m:mo>
 <m:msup><m:mi>a</m:mi><m:mrow><m:mi>i</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msup>
 <m:mfenced separators=""><m:mrow><m:mi>mod</m:mi><m:mo>&#8289;</m:mo><m:mi>p</m:mi></m:mrow></m:mfenced>
</m:math></td><td class="formula-eqn2">
      (4)
     </td></tr></table></div>

and gives a procedure for calculating the parameter, <m:math><m:mi>a</m:mi></m:math>, to satisfy the optimal conditions.</div><div class="paramtext">In this routine the periodisation is achieved by the simple transformation

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub>
 <m:mo>=</m:mo>
 <m:msubsup><m:mi>y</m:mi><m:mi>i</m:mi><m:mn>2</m:mn></m:msubsup>
 <m:mfenced separators=""><m:mn>3</m:mn><m:mo>-</m:mo><m:mn>2</m:mn><m:msub><m:mi>y</m:mi><m:mi>i</m:mi></m:msub></m:mfenced>
 <m:mtext>, &#8195;</m:mtext>
 <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:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

More sophisticated periodisation procedures are available but in practice the degree of periodisation does not appear to be a critical requirement of the method.</div><div class="paramtext">An easily calculable error estimate is not available apart from repetition with an increasing sequence of values of <m:math><m:mi>p</m:mi></m:math>&#160;which can yield erratic results.  The difficulties have been studied by <a class="ref" href="#ref279">Cranley and Patterson (1976)</a> who have proposed a Monte Carlo error estimate arising from converting <a class="eqn" href="#eqn2">(2)</a> into a stochastic integration rule by the inclusion of a random origin shift which leaves the form of the error <a class="eqn" href="#eqn3">(3)</a> unchanged; i.e., in the formula <a class="eqn" href="#eqn2">(2)</a>, <m:math>
 <m:mfenced open="{" close="}" separators="">
  <m:mi>k</m:mi>
  <m:mfrac other="display">
   <m:msub><m:mi>a</m:mi><m:mi>i</m:mi></m:msub>
   <m:mi>p</m:mi>
  </m:mfrac>
 </m:mfenced>
</m:math>&#160;is replaced by <m:math>
 <m:mfenced open="{" close="}" separators="">
  <m:msub><m:mi>&#945;</m:mi><m:mi>i</m:mi></m:msub><m:mo>+</m:mo><m:mi>k</m:mi>
  <m:mfrac other="display">
   <m:msub><m:mi>a</m:mi><m:mi>i</m:mi></m:msub>
   <m:mi>p</m:mi>
  </m:mfrac>
 </m:mfenced>
</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>, where each <m:math>
 <m:msub><m:mi>&#945;</m:mi><m:mi>i</m:mi></m:msub>
</m:math>,  is uniformly distributed over <m:math>
 <m:mfenced separators="" open="[" close="]"><m:mn>0</m:mn><m:mo>,</m:mo><m:mn>1</m:mn></m:mfenced>
</m:math>.  Computing the integral for each of a sequence of random vectors <m:math><m:mi>&#945;</m:mi></m:math>&#160;allows a &#8216;standard error&#8217; to be estimated.</div><div class="paramtext">This routine provides built-in sets of optimal coefficients, corresponding to six different values of <m:math><m:mi>p</m:mi></m:math>.  Alternatively, the optimal coefficients may be supplied by you.  Routines <a class="rout" href="../D01/d01gyf.xml">D01GYF</a> and <a class="rout" href="../D01/d01gzf.xml">D01GZF</a> compute the optimal coefficients for the cases where <m:math><m:mi>p</m:mi></m:math>&#160;is a prime number or <m:math><m:mi>p</m:mi></m:math>&#160;is a product of two primes, respectively.</div><div class="paramtext">This routine is designed to be particularly efficient on vector processors,  although it is very important that you also code <a class="arg" href="#VECFUN">VECFUN</a> and <a class="arg" href="#VECREG">VECREG</a> efficiently.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref278" id="ref278"/>Conroy H (1967)  Molecular Shroedinger equation VIII. A new method for evaluting multi-dimensional integrals <i>J. Chem. Phys.</i> <b>47</b> 5307&#8211;5318 </div>
<div class="paramtext"><a name="ref279" id="ref279"/>Cranley R and Patterson T N L (1976)  Randomisation of number theoretic methods for mulitple integration <i>SIAM J. Numer. Anal.</i> <b>13</b> 904&#8211;914 </div>
<div class="paramtext"><a name="ref275" id="ref275"/>Korobov N M (1957)  The approximate calculation of multiple integrals using number theoretic methods <i>Dokl. Acad. Nauk SSSR</i> <b>115</b> 1062&#8211;1065 </div>
<div class="paramtext"><a name="ref276" id="ref276"/>Korobov N M (1963)  <i>Number Theoretic Methods in Approximate Analysis</i> Fizmatgiz, Moscow </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:mn>1</m:mn><m:mo>&#8804;</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>&#8804;</m:mo><m:mn>20</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="VECFUN" id="VECFUN"/>2: &#160;&#160;&#8194; VECFUN &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd><div class="paramtext"><a class="arg" href="#VECFUN">VECFUN</a> must evaluate the integrand at a specified set of points.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#VECFUN">VECFUN</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;VECFUN&#160;(</td><td class="tdfspec2"><a class="arg" href="../D01/d01gdf.xml#VECFUN_NDIM">NDIM</a>, <a class="arg" href="../D01/d01gdf.xml#VECFUN_X">X</a>, <a class="arg" href="../D01/d01gdf.xml#VECFUN_FV">FV</a>, <a class="arg" href="../D01/d01gdf.xml#VECFUN_M">M</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NDIM, M</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X(M,NDIM), FV(M)</td></tr></table>
<dl><dt class="paramhead"><a name="VECFUN_NDIM" id="VECFUN_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="VECFUN_X" id="VECFUN_X"/>2: &#160;&#160;&#8194; X(<a class="arg" href="../D01/d01gdf.xml#VECFUN_M">M</a>,<a class="arg" href="../D01/d01gdf.xml#VECFUN_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 <m:math><m:mi>m</m:mi></m:math>&#160;points at which the integrand must be evaluated. <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#VECFUN_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mi>j</m:mi></m:mfenced></m:mrow></m:math>&#160;contains the <m:math><m:mi>j</m:mi></m:math>th co-ordinate of the <m:math><m:mi>i</m:mi></m:math>th point.</div></dd><dt class="paramhead"><a name="VECFUN_FV" id="VECFUN_FV"/>3: &#160;&#160;&#8194; FV(<a class="arg" href="../D01/d01gdf.xml#VECFUN_M">M</a>) &#8211; <span class="bitalic">double precision</span> 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="#VECFUN_FV"><m:mi mathcolor="#EE0000" mathvariant="bold">FV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;must contain the value of the integrand of the <m:math><m:mi>i</m:mi></m:math>th point, i.e., <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#VECFUN_FV"><m:mi mathcolor="#EE0000" mathvariant="bold">FV</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>=</m:mo><m:mi>f</m:mi> <m:mfenced separators=""><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#VECFUN_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#VECFUN_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#VECFUN_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:maction actiontype="link" dsi:type="simple" dsi:href="#VECFUN_NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction></m:mfenced></m:mrow></m:mfenced></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:maction actiontype="link" dsi:type="simple" dsi:href="#VECFUN_M"><m:mi mathcolor="#EE0000" mathvariant="bold">M</m:mi></m:maction></m:math>.</div></dd><dt class="paramhead"><a name="VECFUN_M" id="VECFUN_M"/>4: &#160;&#160;&#8194; M &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the number of points <m:math><m:mi>m</m:mi></m:math>&#160;at which the integrand is to be evaluated.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#VECFUN">VECFUN</a> must be declared as EXTERNAL in the (sub)program from which D01GDF 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="VECREG" id="VECREG"/>3: &#160;&#160;&#8194; VECREG &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd><div class="paramtext"><a class="arg" href="#VECREG">VECREG</a> must evaluate the limits of integration in any dimension for a set of points.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#VECREG">VECREG</a> is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;VECREG&#160;(</td><td class="tdfspec2"><a class="arg" href="../D01/d01gdf.xml#VECREG_NDIM">NDIM</a>, <a class="arg" href="../D01/d01gdf.xml#VECREG_X">X</a>, <a class="arg" href="../D01/d01gdf.xml#VECREG_J">J</a>, <a class="arg" href="../D01/d01gdf.xml#VECREG_C">C</a>, <a class="arg" href="../D01/d01gdf.xml#VECREG_D">D</a>, <a class="arg" href="../D01/d01gdf.xml#VECREG_M">M</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NDIM, J, M</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X(M,NDIM), C(M), D(M)</td></tr></table>
<dl><dt class="paramhead"><a name="VECREG_NDIM" id="VECREG_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="VECREG_X" id="VECREG_X"/>2: &#160;&#160;&#8194; X(<a class="arg" href="../D01/d01gdf.xml#VECREG_M">M</a>,<a class="arg" href="../D01/d01gdf.xml#VECREG_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>: 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>m</m:mi></m:math>, <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#VECREG_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mn>1</m:mn></m:mfenced></m:mrow></m:math>, <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#VECREG_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mn>2</m:mn></m:mfenced></m:mrow><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#VECREG_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mrow><m:mi>j</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow></m:math>&#160;contain the current values of the first <m:math><m:mfenced separators=""><m:mi>j</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced></m:math>&#160;co-ordinates of the <m:math><m:mi>i</m:mi></m:math>th point, which may be used if necessary in calculating the <m:math><m:mi>m</m:mi></m:math>&#160;values of <m:math><m:msub><m:mi>c</m:mi><m:mi>j</m:mi></m:msub></m:math>&#160;and <m:math><m:msub><m:mi>d</m:mi><m:mi>j</m:mi></m:msub></m:math>.</div></dd><dt class="paramhead"><a name="VECREG_J" id="VECREG_J"/>3: &#160;&#160;&#8194; J &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the index <m:math><m:mi>j</m:mi></m:math>&#160;for which the limits of the range of integration are required.</div></dd><dt class="paramhead"><a name="VECREG_C" id="VECREG_C"/>4: &#160;&#160;&#8194; C(<a class="arg" href="../D01/d01gdf.xml#VECREG_M">M</a>) &#8211; <span class="bitalic">double precision</span> 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="#VECREG_C"><m:mi mathcolor="#EE0000" mathvariant="bold">C</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 lower limit of the range for <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#VECREG_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mi>j</m:mi></m:mfenced></m:mrow></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>m</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="VECREG_D" id="VECREG_D"/>5: &#160;&#160;&#8194; D(<a class="arg" href="../D01/d01gdf.xml#VECREG_M">M</a>) &#8211; <span class="bitalic">double precision</span> 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="#VECREG_D"><m:mi mathcolor="#EE0000" mathvariant="bold">D</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 upper limit of the range for <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#VECREG_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi><m:mi>j</m:mi></m:mfenced></m:mrow></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>m</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="VECREG_M" id="VECREG_M"/>6: &#160;&#160;&#8194; M &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the number of points <m:math><m:mi>m</m:mi></m:math>&#160;at which the limits of integration must be specified.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#VECREG">VECREG</a> must be declared as EXTERNAL in the (sub)program from which D01GDF 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="NPTS" id="NPTS"/>4: &#160;&#160;&#8194; NPTS &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the Korobov rule to be used. There are two alternatives depending on the value of <a class="arg" href="#NPTS">NPTS</a>. 
 <table class="standard-90"><tr>
<td style="width:2.1em;" valign="baseline">(i)</td>
<td valign="top"><m:math><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NPTS"><m:mi mathcolor="#EE0000" mathvariant="bold">NPTS</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>6</m:mn></m:math>.
   <div class="paramtext">In this case one of six preset rules is chosen using <m:math><m:mn>2129</m:mn></m:math>, <m:math><m:mn>5003</m:mn></m:math>, <m:math><m:mn>10007</m:mn></m:math>, <m:math><m:mn>20011</m:mn></m:math>, <m:math><m:mn>40009</m:mn></m:math>&#160;or <m:math><m:mn>80021</m:mn></m:math>&#160;points depending on the respective value of <a class="arg" href="#NPTS">NPTS</a> being <m:math><m:mn>1</m:mn></m:math>, <m:math><m:mn>2</m:mn></m:math>, <m:math><m:mn>3</m:mn></m:math>, <m:math><m:mn>4</m:mn></m:math>, <m:math><m:mn>5</m:mn></m:math>&#160;or <m:math><m:mn>6</m:mn></m:math>.</div></td>
</tr><tr>
<td style="width:2.1em;" valign="baseline">(ii)</td>
<td valign="top"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NPTS"><m:mi mathcolor="#EE0000" mathvariant="bold">NPTS</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>6</m:mn></m:math>.
   <div class="paramtext"><a class="arg" href="#NPTS">NPTS</a> is the number of actual points to be used with corresponding optimal coefficients supplied in the array <a class="arg" href="#VK">VK</a>.</div></td>
</tr></table>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NPTS"><m:mi mathcolor="#EE0000" mathvariant="bold">NPTS</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="VK" id="VK"/>5: &#160;&#160;&#8194; VK(<a class="arg" href="#NDIM">NDIM</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="#NPTS"><m:mi mathcolor="#EE0000" mathvariant="bold">NPTS</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>6</m:mn></m:math>, <a class="arg" href="#VK">VK</a> must contain the <m:math><m:mi>n</m:mi></m:math>&#160;optimal coefficients (which may be calculated using <a class="rout" href="../D01/d01gyf.xml">D01GYF</a> or <a class="rout" href="../D01/d01gzf.xml">D01GZF</a>).
<div class="paramtext">If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NPTS"><m:mi mathcolor="#EE0000" mathvariant="bold">NPTS</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>6</m:mn></m:math>, <a class="arg" href="#VK">VK</a> need not be set.</div>
</div>
<div class="paramtext"><i>On exit</i>: if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NPTS"><m:mi mathcolor="#EE0000" mathvariant="bold">NPTS</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>6</m:mn></m:math>, <a class="arg" href="#VK">VK</a> is unchanged.
<div class="paramtext">If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NPTS"><m:mi mathcolor="#EE0000" mathvariant="bold">NPTS</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>6</m:mn></m:math>, <a class="arg" href="#VK">VK</a> contains the <m:math><m:mi>n</m:mi></m:math>&#160;optimal coefficients used by the preset rule.</div>
</div></dd><dt class="paramhead"><a name="NRAND" id="NRAND"/>6: &#160;&#160;&#8194; NRAND &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the number of random samples to be generated (generally a small value, say <m:math><m:mn>3</m:mn></m:math>&#160;to <m:math><m:mn>5</m:mn></m:math>, is sufficient). The estimate, <a class="arg" href="#RES">RES</a>, of the value of the integral returned by the routine is then the average of <a class="arg" href="#NRAND">NRAND</a> calculations with different random origin shifts. If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NPTS"><m:mi mathcolor="#EE0000" mathvariant="bold">NPTS</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>6</m:mn></m:math>, the total number of integrand evaluations will be <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NRAND"><m:mi mathcolor="#EE0000" mathvariant="bold">NRAND</m:mi></m:maction><m:mo>&#215;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NPTS"><m:mi mathcolor="#EE0000" mathvariant="bold">NPTS</m:mi></m:maction></m:math>. If <m:math><m:mn>1</m:mn><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#NPTS"><m:mi mathcolor="#EE0000" mathvariant="bold">NPTS</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>6</m:mn></m:math>, then the number of integrand evaluations will be <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NRAND"><m:mi mathcolor="#EE0000" mathvariant="bold">NRAND</m:mi></m:maction><m:mo>&#215;</m:mo><m:mi>p</m:mi></m:math>, where <m:math><m:mi>p</m:mi></m:math>&#160;is the number of points corresponding to the six preset rules. For reasons of efficiency, these values are calculated a number at a time in <a class="arg" href="#VECFUN">VECFUN</a>.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NRAND"><m:mi mathcolor="#EE0000" mathvariant="bold">NRAND</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="ITRANS" id="ITRANS"/>7: &#160;&#160;&#8194; ITRANS &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: indicates whether the periodising transformation is to be used.

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITRANS"><m:mi mathcolor="#EE0000" mathvariant="bold">ITRANS</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math></dt>
<dd>The transformation is to be used.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITRANS"><m:mi mathcolor="#EE0000" mathvariant="bold">ITRANS</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mn>0</m:mn></m:math></dt>
<dd>The transformation is to be suppressed (to cover cases where the integrand may already be periodic or where you want to specify a particular transformation in the definition of <a class="arg" href="#VECFUN">VECFUN</a>).</dd></dl>
</div>
<div class="paramtext"><i>Suggested value</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ITRANS"><m:mi mathcolor="#EE0000" mathvariant="bold">ITRANS</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>.

</div></dd><dt class="paramhead"><a name="RES" id="RES"/>8: &#160;&#160;&#8194; RES &#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="ERR" id="ERR"/>9: &#160;&#160;&#8194; ERR &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: the standard error as computed from <a class="arg" href="#NRAND">NRAND</a> sample values. If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NRAND"><m:mi mathcolor="#EE0000" mathvariant="bold">NRAND</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math>, then <a class="arg" href="#ERR">ERR</a> contains zero.</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>10: &#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="#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="#NDIM"><m:mi mathcolor="#EE0000" mathvariant="bold">NDIM</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>20</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>
<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="#NPTS"><m:mi mathcolor="#EE0000" mathvariant="bold">NPTS</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>1</m:mn></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>
<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="#NRAND"><m:mi mathcolor="#EE0000" mathvariant="bold">NRAND</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>1</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">If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NRAND"><m:mi mathcolor="#EE0000" mathvariant="bold">NRAND</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>1</m:mn></m:math>, an estimate of the absolute standard error is given by the value, on exit, of <a class="arg" href="#ERR">ERR</a>.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">D01GDF performs the same computation as <a class="rout" href="../D01/d01gcf.xml">D01GCF</a>.  However, the interface has been modified so that it can perform more efficiently on machines with vector processing capabilities.  In particular, <a class="arg" href="#VECFUN">VECFUN</a> and <a class="arg" href="#VECREG">VECREG</a> must calculate the integrand and limits of integration at a <span class="italic">set</span> of points.  For some problems the amount of time spent in these two subroutines, which must be supplied by you, may account for a significant part of the total computation time.  For this reason it is vital that you consider the possibilities for vectorization in the code supplied for these two subroutines.</div><div class="paramtext">The time taken will be approximately proportional to <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#NRAND"><m:mi mathcolor="#EE0000" mathvariant="bold">NRAND</m:mi></m:maction><m:mo>&#215;</m:mo><m:mi>p</m:mi></m:math>, where <m:math><m:mi>p</m:mi></m:math>&#160;is the number of points used, but may depend significantly on the efficiency of the code provided by you in <a class="arg" href="#VECFUN">VECFUN</a> and <a class="arg" href="#VECREG">VECREG</a>.</div>
<div class="paramtext">The exact values of <a class="arg" href="#RES">RES</a> and <a class="arg" href="#ERR">ERR</a> on return will depend (within statistical limits) on the sequence of random numbers generated within D01GDF 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:mrow><m:mi>cos</m:mi><m:mfenced separators="">
   <m:mn>0.5</m:mn><m:mo>+</m:mo><m:mn>2</m:mn>
   <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:msub><m:mi>x</m:mi><m:mn>3</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:mo>-</m:mo>
   <m:mn>4</m:mn>
  </m:mfenced></m:mrow>
 <m:mrow><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:mrow>
 <m:mrow><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mn>2</m:mn></m:msub></m:mrow>
 <m:mrow><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mn>3</m:mn></m:msub></m:mrow>
 <m:mrow><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mn>4</m:mn></m:msub></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/d01gdfe.f">Program Text (d01gdfe.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/d01gdfe.r">Program Results (d01gdfe.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/D01/d01gdf.pdf">D01GDF (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>
