<?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>D01JAF : 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/d01jaf.pdf">D01JAF (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/>D01JAF</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="htmltoc" onclick="showLevel('tocfcomments');"><span class="htmltocplus" id="tocfcommentsplus">+</span><span class="htmltocminus" id="tocfcommentsminus">&#8722;</span></span>
<a class="htmltoc" href="#fcomments">8&#160;&#160;<b>Further Comments</b></a>
<div class="htmltocitem" id="tocfcomments">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments1">8.1&#160;&#160;<b>Timing</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments2">8.2&#160;&#160;<b>Spherical Polar Co-ordinates</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments3">8.3&#160;&#160;<b>Machine Dependencies</b></a>
</div>
</div>
</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">D01JAF attempts to evaluate an integral over an  <m:math><m:mi>n</m:mi></m:math>-dimensional sphere (<m:math><m:mi>n</m:mi><m:mo>=</m:mo><m:mn>2</m:mn></m:math>, <m:math><m:mn>3</m:mn></m:math>, or <m:math><m:mn>4</m:mn></m:math>),  to a user-specified absolute or relative accuracy, by means of a modified Sag&#8211;Szekeres method.  The routine can handle singularities on the surface or at the centre of the sphere, and returns an error estimate.</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;D01JAF&#160;(</td><td class="tdfspec2"><a class="arg" href="#F">F</a>, <a class="arg" href="#NDIM">NDIM</a>, <a class="arg" href="#RADIUS">RADIUS</a>, <a class="arg" href="#EPSA">EPSA</a>, <a class="arg" href="#EPSR">EPSR</a>, <a class="arg" href="#METHOD">METHOD</a>, <a class="arg" href="#ICOORD">ICOORD</a>, <a class="arg" href="#RESULT">RESULT</a>, <a class="arg" href="#ESTERR">ESTERR</a>, <a class="arg" href="#NEVALS">NEVALS</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NDIM, METHOD, ICOORD, NEVALS, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">F, RADIUS, EPSA, EPSR, RESULT, ESTERR</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">D01JAF calculates an approximation to the <m:math><m:mi>n</m:mi></m:math>-dimensional integral

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>I</m:mi><m:mo>=</m:mo><m:mo>&#8747;</m:mo><m:mo>&#8943;</m:mo><m:msub><m:mo>&#8747;</m:mo><m:mi>S</m:mi></m:msub><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:mn>1</m:mn></m:msub></m:mrow><m:mo>&#8943;</m:mo><m:mrow><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mi>n</m:mi></m:msub></m:mrow><m:mtext>, &#8195;</m:mtext><m:mn>2</m:mn><m:mo>&#8804;</m:mo><m:mi>n</m:mi><m:mo>&#8804;</m:mo><m:mn>4</m:mn><m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:mi>S</m:mi></m:math>&#160;is the hypersphere

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:msqrt><m:mfenced separators=""><m:msubsup><m:mi>x</m:mi><m:mn>1</m:mn><m:mn>2</m:mn></m:msubsup><m:mo>+</m:mo><m:mo>&#8943;</m:mo><m:mo>+</m:mo><m:msubsup><m:mi>x</m:mi><m:mi>n</m:mi><m:mn>2</m:mn></m:msubsup></m:mfenced></m:msqrt><m:mo>&#8804;</m:mo><m:mi>&#945;</m:mi><m:mo>&lt;</m:mo><m:mi>&#8734;</m:mi>
</m:math></td><td class="formula2"/></tr></table></div>

(the integrand function may also be defined in spherical co-ordinates).  The algorithm is based on the Sag&#8211;Szekeres method (see <a class="ref" href="#ref273">Sag and Szekeres (1964)</a>),  applying the product trapezoidal formula after a suitable radial transformation.  An improved transformation technique is developed: depending on the behaviour of the function and on the required accuracy, different transformations can be used, some of which are &#8216;double exponential&#8217;, as defined by <a class="ref" href="#ref280">Takahasi and Mori (1974)</a>.  The resulting technique allows the routine to deal with integrand singularities on the surface or at the centre of the sphere.  When the estimated error of the approximation with mesh size <m:math><m:mi>h</m:mi></m:math>&#160;is larger than the tolerated error, the trapezoidal formula with mesh size <m:math><m:mi>h</m:mi><m:mo>/</m:mo><m:mn>2</m:mn></m:math>&#160;is calculated.  A  drawback of this method is the exponential growth of the number of function evaluations in the successive approximations (this number grows with a factor <m:math><m:mtext/><m:mo>&#8776;</m:mo><m:msup><m:mn>2</m:mn><m:mi>n</m:mi></m:msup></m:math>).  This introduces the restriction <m:math><m:mi>n</m:mi><m:mo>&#8804;</m:mo><m:mn>4</m:mn></m:math>.  Because the convergence rate of the successive approximations is normally better than linear, the error estimate is based on the linear extrapolation of the difference between the successive approximations (see <a class="ref" href="#ref281">Robinson and de Doncker (1981)</a> and <a class="ref" href="#ref282">Roose and de Doncker (1981)</a>).  For further details of the algorithm, see <a class="ref" href="#ref282">Roose and de Doncker (1981)</a>.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref281" id="ref281"/>Robinson I and de Doncker E (1981)  Automatic computation of improper integrals over a bounded or unbounded planar region <i>Computing</i> <b>27</b> 89&#8211;284 </div>
<div class="paramtext"><a name="ref282" id="ref282"/>Roose D and de Doncker E (1981)  Automatic integration over a sphere <i>J. Comput. Appl. Math.</i> <b>7</b> 203&#8211;224 </div>
<div class="paramtext"><a name="ref273" id="ref273"/>Sag T W and Szekeres G (1964)  Numerical evaluation of high-dimensional integrals <i>Math. Comput.</i> <b>18</b> 245&#8211;253 </div>
<div class="paramtext"><a name="ref280" id="ref280"/>Takahasi H and Mori M (1974)  <i>Double Exponential Formulas for Numerical Integration</i> <b>9</b> Publ. RIMS, Kyoto University 721&#8211;741 </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/d01jaf.xml#F_NDIM">NDIM</a>, <a class="arg" href="../D01/d01jaf.xml#F_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="F_NDIM" id="F_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="F_X" id="F_X"/>2: &#160;&#160;&#8194; X(<a class="arg" href="../D01/d01jaf.xml#F_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. These co-ordinates are given in Cartesian or spherical polar form according to the value of <a class="arg" href="#ICOORD">ICOORD</a>.</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 D01JAF is called. Parameters denoted as <span class="italic">Input</span>  must <b>not</b>  be changed by this procedure.</div>
<div class="paramtext">See also <a class="sec" href="#fcomments">Section 8</a>.</div>
</dd><dt class="paramhead"><a name="NDIM" id="NDIM"/>2: &#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 dimension of the sphere.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:mn>2</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>4</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="RADIUS" id="RADIUS"/>3: &#160;&#160;&#8194; RADIUS &#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>&#945;</m:mi></m:math>, the radius of the sphere.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#RADIUS"><m:mi mathcolor="#EE0000" mathvariant="bold">RADIUS</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>0.0</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="EPSA" id="EPSA"/>4: &#160;&#160;&#8194; EPSA &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the requested absolute tolerance. If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#EPSA"><m:mi mathcolor="#EE0000" mathvariant="bold">EPSA</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>0.0</m:mn></m:math>, its absolute value is used. See <a class="sec" href="#accuracy">Section 7</a>.</div></dd><dt class="paramhead"><a name="EPSR" id="EPSR"/>5: &#160;&#160;&#8194; EPSR &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the requested relative tolerance. 

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#EPSR"><m:mi mathcolor="#EE0000" mathvariant="bold">EPSR</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>0.0</m:mn></m:math></dt>
<dd>Its absolute value is used.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#EPSR"><m:mi mathcolor="#EE0000" mathvariant="bold">EPSR</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>10</m:mn><m:mo>&#215;</m:mo><m:mfenced separators=""><m:mi mathvariant="bold-italic">machine&#160;precision</m:mi></m:mfenced></m:math></dt>
<dd>The latter value is used as <a class="arg" href="#EPSR">EPSR</a> by the routine. See <a class="sec" href="#accuracy">Section 7</a>.</dd></dl>
</div></dd><dt class="paramhead"><a name="METHOD" id="METHOD"/>6: &#160;&#160;&#8194; METHOD &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: must specify the transformation to be used by the routine. The choice depends on the behaviour of the integrand and on the required accuracy.
<div class="paramtext">For well-behaved functions and functions with mild singularities on the surface of the sphere only: 
<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>Low accuracy required.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math></dt>
<dd>High accuracy required.</dd></dl>
</div>
<div class="paramtext">For functions with severe singularities on the surface of the sphere only: 
<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math></dt>
<dd>Low accuracy required.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>4</m:mn></m:math></dt>
<dd>High accuracy required.
<div class="paramtext">(in this case <a class="arg" href="#ICOORD">ICOORD</a> must be set to <m:math><m:mn>2</m:mn></m:math>, and the function defined in special spherical co-ordinates).</div></dd></dl>
</div>
<div class="paramtext">For functions with a singularity at the centre of the sphere (and possibly with singularities on the surface as well): 
<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>5</m:mn></m:math></dt>
<dd>Low accuracy required.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>6</m:mn></m:math></dt>
<dd>High accuracy required.</dd></dl>
<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>&#160;can be used as a default value and is equivalent to <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math>&#160;if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#EPSR"><m:mi mathcolor="#EE0000" mathvariant="bold">EPSR</m:mi></m:maction><m:mo>&gt;</m:mo><m:msup><m:mn>10</m:mn><m:mrow><m:mo>-</m:mo><m:mn>6</m:mn></m:mrow></m:msup></m:math>, and to <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math>&#160;if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#EPSR"><m:mi mathcolor="#EE0000" mathvariant="bold">EPSR</m:mi></m:maction><m:mo>&#8804;</m:mo><m:msup><m:mn>10</m:mn><m:mrow><m:mo>-</m:mo><m:mn>6</m:mn></m:mrow></m:msup></m:math>.</div>
<div class="paramtext">The distinction between low and high required accuracies, as mentioned above, depends also on the behaviour of the function. Roughly one may assume the critical value of <a class="arg" href="#EPSA">EPSA</a> and <a class="arg" href="#EPSR">EPSR</a> to be <m:math><m:msup><m:mn>10</m:mn><m:mrow><m:mo>-</m:mo><m:mn>6</m:mn></m:mrow></m:msup></m:math>, but the critical value will be smaller for a well-behaved integrand and larger for an integrand with severe singularities.</div>
</div>
<div class="paramtext"><i>Suggested value</i>:
  

<m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>, <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 class="paramtext">If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ICOORD"><m:mi mathcolor="#EE0000" mathvariant="bold">ICOORD</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math>, <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>&#160;or <m:math><m:mn>4</m:mn></m:math></div></div></dd><dt class="paramhead"><a name="ICOORD" id="ICOORD"/>7: &#160;&#160;&#8194; ICOORD &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: must specify which kind of co-ordinates are used in <a class="arg" href="#F">F</a>. 

<dl>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ICOORD"><m:mi mathcolor="#EE0000" mathvariant="bold">ICOORD</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math></dt>
<dd>Cartesian co-ordinates <m:math><m:msub><m:mi>x</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>.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ICOORD"><m:mi mathcolor="#EE0000" mathvariant="bold">ICOORD</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>Spherical co-ordinates (see <a class="sec" href="#fcomments2">Section 8.2</a>): <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#F_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mi>&#961;</m:mi></m:math>; <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#F_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>=</m:mo><m:msub><m:mi>&#952;</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>.</dd>
<dt class="paramval"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ICOORD"><m:mi mathcolor="#EE0000" mathvariant="bold">ICOORD</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math>,</dt>
<dd>Special spherical polar co-ordinates (see <a class="sec" href="#fcomments3">Section 8.3</a>), with the additional transformation <m:math><m:mi>&#961;</m:mi><m:mo>=</m:mo><m:mi>&#945;</m:mi><m:mo>-</m:mo><m:mi>&#955;</m:mi></m:math>: <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#F_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mi>&#955;</m:mi><m:mo>=</m:mo><m:mi>&#945;</m:mi><m:mo>-</m:mo><m:mi>&#961;</m:mi></m:math>; <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#F_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow><m:mo>=</m:mo><m:msub><m:mi>&#952;</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>.</dd></dl>
</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ICOORD"><m:mi mathcolor="#EE0000" mathvariant="bold">ICOORD</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>, <m:math><m:mn>1</m:mn></m:math>&#160;or <m:math><m:mn>2</m:mn></m:math>.
<div class="paramtext">If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>&#160;or <m:math><m:mn>4</m:mn></m:math>, <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ICOORD"><m:mi mathcolor="#EE0000" mathvariant="bold">ICOORD</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math></div></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="ESTERR" id="ESTERR"/>9: &#160;&#160;&#8194; ESTERR &#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.</div></dd><dt class="paramhead"><a name="NEVALS" id="NEVALS"/>10: &#8194; NEVALS &#8211; INTEGER<span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: the number of function evaluations used.</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>11: &#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> D01JAF 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 required accuracy cannot be achieved within a limiting number of function evaluations (which is set by the routine).</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">The required accuracy cannot be achieved because of round-off error.</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">The required accuracy cannot be achieved because the maximum accuracy with respect to the machine constants <a class="rout" href="../X02/x02ajf.xml">X02AJF</a> and <a class="rout" href="../X02/x02amf.xml">X02AMF</a> has been attained.  If this maximum accuracy is rather low (compared with <a class="rout" href="../X02/x02ajf.xml">X02AJF</a>), the cause of the problem is a severe singularity on the boundary or at the centre of the sphere.  If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>, <m:math><m:mn>1</m:mn></m:math>&#160;or <m:math><m:mn>2</m:mn></m:math>, then setting  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>&#160;or <m:math><m:mn>4</m:mn></m:math>&#160;may help.</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>
<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>2</m:mn></m:math>&#160;or <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>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="#RADIUS"><m:mi mathcolor="#EE0000" mathvariant="bold">RADIUS</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>0.0</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="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mn>0</m:mn></m:math>, <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>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ICOORD"><m:mi mathcolor="#EE0000" mathvariant="bold">ICOORD</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mn>0</m:mn></m:math>, <m:math><m:mn>1</m:mn></m:math>&#160;or <m:math><m:mn>2</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="#ICOORD"><m:mi mathcolor="#EE0000" mathvariant="bold">ICOORD</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math>&#160;and <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mn>3</m:mn></m:math>&#160;or <m:math><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="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>&#160;or <m:math><m:mn>4</m:mn></m:math>&#160;and <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#ICOORD"><m:mi mathcolor="#EE0000" mathvariant="bold">ICOORD</m:mi></m:maction><m:mo>&#8800;</m:mo><m:mn>2</m:mn></m:math>.</td></tr></table>
<div class="paramtext">No calculations have been performed.  <a class="arg" href="#RESULT">RESULT</a> and <a class="arg" href="#ESTERR">ESTERR</a> are set to <m:math><m:mn>0.0</m:mn></m:math>.</div>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">You can specify an absolute and/or a relative tolerance, setting <a class="arg" href="#EPSA">EPSA</a> and <a class="arg" href="#EPSR">EPSR</a>.  The routine attempts to calculate 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: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="#EPSA"><m:mi mathcolor="#EE0000" mathvariant="bold">EPSA</m:mi></m:maction><m:mo>,</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#EPSR"><m:mi mathcolor="#EE0000" mathvariant="bold">EPSR</m:mi></m:maction><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>

If <m:math><m:mn>0</m:mn><m:mo>&#8804;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>&#8804;</m:mo><m:mn>3</m:mn></m:math>, <a class="arg" href="#ESTERR">ESTERR</a> returns an estimate of, but not necessarily a 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><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2><h3 class="standard"><a class="sec" name="fcomments1" id="fcomments1"/>8.1&#160;&#160;Timing</h3>
<div class="paramtext">Timing depends on the integrand and the accuracy required.</div><h3 class="standard"><a class="sec" name="fcomments2" id="fcomments2"/>8.2&#160;&#160;Spherical Polar Co-ordinates</h3>
<div class="paramtext">Cartesian co-ordinates are related to the spherical polar co-ordinates by:

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mtable columnalign="center left">
 <m:mtr>
  <m:mtd><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:mtd>
  <m:mtd><m:mo>=</m:mo></m:mtd>
  <m:mtd><m:mi>&#961;</m:mi><m:mo>.</m:mo><m:mrow><m:mi>sin</m:mi><m:mo>&#8289;</m:mo><m:msub><m:mi>&#952;</m:mi><m:mn>1</m:mn></m:msub></m:mrow><m:mo>&#8943;</m:mo><m:mrow><m:mi>sin</m:mi><m:mo>&#8289;</m:mo><m:msub><m:mi>&#952;</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>2</m:mn></m:mrow></m:msub></m:mrow><m:mo>.</m:mo><m:mrow><m:mi>sin</m:mi><m:mo>&#8289;</m:mo><m:msub><m:mi>&#952;</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msub></m:mrow></m:mtd>
 </m:mtr><m:mtr>
  <m:mtd><m:msub><m:mi>x</m:mi><m:mn>2</m:mn></m:msub></m:mtd>
  <m:mtd><m:mo>=</m:mo></m:mtd>
  <m:mtd><m:mi>&#961;</m:mi><m:mo>.</m:mo><m:mrow><m:mi>sin</m:mi><m:mo>&#8289;</m:mo><m:msub><m:mi>&#952;</m:mi><m:mn>1</m:mn></m:msub></m:mrow><m:mo>&#8943;</m:mo><m:mrow><m:mi>sin</m:mi><m:mo>&#8289;</m:mo><m:msub><m:mi>&#952;</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>2</m:mn></m:mrow></m:msub></m:mrow><m:mo>.</m:mo><m:mrow><m:mi>cos</m:mi><m:mo>&#8289;</m:mo><m:msub><m:mi>&#952;</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msub></m:mrow></m:mtd>
 </m:mtr><m:mtr>
  <m:mtd><m:msub><m:mi>x</m:mi><m:mn>3</m:mn></m:msub></m:mtd>
  <m:mtd><m:mo>=</m:mo></m:mtd>
  <m:mtd><m:mi>&#961;</m:mi><m:mo>.</m:mo><m:mrow><m:mi>sin</m:mi><m:mo>&#8289;</m:mo><m:msub><m:mi>&#952;</m:mi><m:mn>1</m:mn></m:msub></m:mrow><m:mo>&#8943;</m:mo><m:mrow><m:mi>cos</m:mi><m:mo>&#8289;</m:mo><m:msub><m:mi>&#952;</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>2</m:mn></m:mrow></m:msub></m:mrow></m:mtd>
 </m:mtr><m:mtr>
  <m:mtd><m:mo>&#8942;</m:mo></m:mtd>
  <m:mtd/>
  <m:mtd/></m:mtr><m:mtr>
  <m:mtd><m:msub><m:mi>x</m:mi><m:mi>n</m:mi></m:msub></m:mtd>
  <m:mtd><m:mo>=</m:mo></m:mtd>
  <m:mtd><m:mi>&#961;</m:mi><m:mo>.</m:mo><m:mrow><m:mi>cos</m:mi><m:mo>&#8289;</m:mo><m:msub><m:mi>&#952;</m:mi><m:mn>1</m:mn></m:msub></m:mrow></m:mtd>
 </m:mtr>
</m:mtable>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:mn>0</m:mn><m:mo>&lt;</m:mo><m:msub><m:mi>&#952;</m:mi><m:mi>i</m:mi></m:msub><m:mo>&lt;</m:mo><m:mi>&#960;</m:mi></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:mo>-</m:mo><m:mn>2</m:mn></m:math>&#160;and <m:math><m:mn>0</m:mn><m:mo>&lt;</m:mo><m:msub><m:mi>&#952;</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msub><m:mo>&lt;</m:mo><m:mn>2</m:mn><m:mi>&#960;</m:mi></m:math>.</div><h3 class="standard"><a class="sec" name="fcomments3" id="fcomments3"/>8.3&#160;&#160;Machine Dependencies</h3>
<div class="paramtext">As a consequence of the transformation technique, the severity of the singularities which can be handled by D01JAF depends on the precision and range of real numbers on the machine.  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>&#160;or <m:math><m:mn>4</m:mn></m:math>&#160;must be used when the singularity on the surface is &#8216;severe&#8217; in view of the requested accuracy and <span class="bitalic">machine precision</span>.  In practice one has to set <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>&#160;or <m:math><m:mn>4</m:mn></m:math>&#160;if D01JAF terminates with <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="#IFeq3"><m:mn mathcolor="#003399" mathvariant="bold">3</m:mn></m:maction></m:math>&#160;when called with  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>0</m:mn></m:math>, <m:math><m:mn>1</m:mn></m:math>&#160;or <m:math><m:mn>2</m:mn></m:math>.</div><div class="paramtext">When integrating a function with a severe singular behaviour on the surface of the sphere, the additional transformation  <m:math><m:mi>&#961;</m:mi><m:mo>=</m:mo><m:mi>&#945;</m:mi><m:mo>-</m:mo><m:mi>&#955;</m:mi></m:math>&#160;helps to avoid the loss of significant figures due to round-off error in the calculation of the integration nodes which are very close to the surface.  For these points, the value of  <m:math><m:mi>&#955;</m:mi></m:math>&#160;can be computed more accurately than the value of <m:math><m:mi>&#961;</m:mi></m:math>.  Naturally, care must be taken that the function subprogram does not contain expressions of the form  <m:math><m:mi>&#945;</m:mi><m:mo>-</m:mo><m:mi>&#955;</m:mi></m:math>, which could cause a large round-off error in the calculation of the integrand at the boundary of the sphere.</div><div class="paramtext">Care should be taken to avoid underflow and/or overflow problems in the function subprogram, because some of the integration nodes used by D01JAF may be very close to the surface or to the centre of the sphere.</div><div class="paramtext">Example:</div><ul class="listind"><li class="listind">suppose the function

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>f</m:mi><m:mfenced separators=""><m:mi>&#961;</m:mi></m:mfenced><m:mo>=</m:mo><m:msup><m:mfenced separators=""><m:mn>1</m:mn><m:mo>-</m:mo><m:msup><m:mi>&#961;</m:mi><m:mn>2</m:mn></m:msup></m:mfenced><m:mrow><m:mo>-</m:mo><m:mn>0.7</m:mn></m:mrow></m:msup>
</m:math></td><td class="formula2"/></tr></table></div>

is to be integrated over the unit sphere, with  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#METHOD"><m:mi mathcolor="#EE0000" mathvariant="bold">METHOD</m:mi></m:maction><m:mo>=</m:mo><m:mn>3</m:mn></m:math>&#160;or <m:math><m:mn>4</m:mn></m:math>.  Then <a class="arg" href="#ICOORD">ICOORD</a> should be set to 2;  the transformation <m:math><m:mi>&#961;</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>-</m:mo><m:mi>&#955;</m:mi></m:math>&#160;gives  <m:math><m:mi>f</m:mi><m:mfenced separators=""><m:mi>&#961;</m:mi></m:mfenced><m:mo>=</m:mo><m:msup><m:mfenced separators=""><m:mn>2</m:mn><m:mi>&#955;</m:mi><m:mo>-</m:mo><m:msup><m:mi>&#955;</m:mi><m:mn>2</m:mn></m:msup></m:mfenced>
  <m:mrow><m:mo>-</m:mo><m:mn>0.7</m:mn></m:mrow></m:msup></m:math>; and  <a class="arg" href="#F">F</a> could be coded thus:
<pre class="verbatim">
F = 1.0
A = X(1)
IF (A.GT.0.0) F = 1.0/(A*(2.0-A))**0.7
RETURN
</pre></li></ul><div class="paramtext">Note that D01JAF ensures that  <m:math><m:mi>&#955;</m:mi><m:mo>=</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#F_X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn></m:mfenced></m:mrow><m:mo>&gt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="../X02/x02amf.xml#X02AMF"><m:mi mathcolor="#5555FF" mathvariant="bold">X02AMF</m:mi></m:maction></m:math>, but underflow could occur in the computation of <m:math><m:msup><m:mi>&#955;</m:mi><m:mn>2</m:mn></m:msup></m:math>.</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example evaluates the integrals

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mo>&#8747;</m:mo><m:mo>&#8943;</m:mo><m:msub><m:mo>&#8747;</m:mo><m:mi>S</m:mi></m:msub><m:mfrac><m:mn>1</m:mn><m:msqrt><m:mn>1</m:mn><m:mo>-</m:mo><m:msup><m:mi>&#961;</m:mi><m:mn>2</m:mn></m:msup></m:msqrt></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:mo>&#8943;</m:mo><m:mrow><m:mi>d</m:mi><m:msub><m:mi>x</m:mi><m:mi>n</m:mi></m:msub></m:mrow></m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:mi>&#961;</m:mi><m:mo>=</m:mo><m:msqrt><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:msubsup><m:mi>x</m:mi><m:mi>i</m:mi><m:mn>2</m:mn></m:msubsup></m:msqrt></m:math>, and  <m:math><m:mi>S</m:mi></m:math>&#160;is the unit sphere of dimension <m:math><m:mi>n</m:mi><m:mo>=</m:mo><m:mn>2</m:mn><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>4</m:mn></m:math>.</div><div class="paramtext">The exact values (to <m:math><m:mn>12</m:mn></m:math>&#160;decimal places) are <m:math><m:mn>6.28318530718</m:mn></m:math>&#160;and <m:math><m:mn>13.1594725348</m:mn></m:math>.</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/d01jafe.f">Program Text (d01jafe.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/d01jafe.r">Program Results (d01jafe.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/D01/d01jaf.pdf">D01JAF (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>
