<?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>D01DAF : 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/d01daf.pdf">D01DAF (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/>D01DAF</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">D01DAF attempts to evaluate a double integral to a specified absolute accuracy by repeated applications of the method described by <a class="ref" href="#ref271">Patterson (1968)</a> and <a class="ref" href="#ref270">Patterson (1969)</a>.</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;D01DAF&#160;(</td><td class="tdfspec2"><a class="arg" href="#YA">YA</a>, <a class="arg" href="#YB">YB</a>, <a class="arg" href="#PHI1">PHI1</a>, <a class="arg" href="#PHI2">PHI2</a>, <a class="arg" href="#F">F</a>, <a class="arg" href="#ABSACC">ABSACC</a>, <a class="arg" href="#ANS">ANS</a>, <a class="arg" href="#NPTS">NPTS</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">NPTS, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">YA, YB, PHI1, PHI2, F, ABSACC, ANS</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">PHI1, PHI2, F</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">D01DAF attempts to evaluate a definite integral of the form

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mi>I</m:mi><m:mo>=</m:mo>
 <m:munderover><m:mo>&#8747;</m:mo><m:mi>a</m:mi><m:mi>b</m:mi></m:munderover>
 <m:munderover>
  <m:mo>&#8747;</m:mo>
  <m:mrow><m:msub><m:mi>&#981;</m:mi><m:mn>1</m:mn></m:msub><m:mfenced separators=""><m:mi>y</m:mi></m:mfenced></m:mrow>
  <m:mrow><m:msub><m:mi>&#981;</m:mi><m:mn>2</m:mn></m:msub><m:mfenced separators=""><m:mi>y</m:mi></m:mfenced></m:mrow>
 </m:munderover><m:mi>f</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced>
 <m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow>
 <m:mrow><m:mi>d</m:mi><m:mi>y</m:mi></m:mrow>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:mi>a</m:mi></m:math>&#160;and <m:math><m:mi>b</m:mi></m:math>&#160;are constants and  <m:math><m:msub><m:mi>&#981;</m:mi><m:mn>1</m:mn></m:msub><m:mfenced separators=""><m:mi>y</m:mi></m:mfenced></m:math>&#160;and <m:math><m:msub><m:mi>&#981;</m:mi><m:mn>2</m:mn></m:msub><m:mfenced separators=""><m:mi>y</m:mi></m:mfenced></m:math>&#160;are functions of the variable <m:math><m:mi>y</m:mi></m:math>.</div><div class="paramtext">The integral is evaluated by expressing it as

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>I</m:mi><m:mo>=</m:mo><m:munderover><m:mo>&#8747;</m:mo><m:mi>a</m:mi><m:mi>b</m:mi></m:munderover><m:mi>F</m:mi><m:mfenced separators=""><m:mi>y</m:mi></m:mfenced><m:mrow><m:mi>d</m:mi><m:mi>y</m:mi></m:mrow><m:mtext>, &#8195; where &#8195;</m:mtext><m:mi>F</m:mi><m:mfenced separators=""><m:mi>y</m:mi></m:mfenced><m:mo>=</m:mo>
<m:munderover>
 <m:mo>&#8747;</m:mo>
 <m:mrow><m:msub><m:mi>&#981;</m:mi><m:mn>1</m:mn></m:msub><m:mfenced separators=""><m:mi>y</m:mi></m:mfenced></m:mrow>
 <m:mrow><m:msub><m:mi>&#981;</m:mi><m:mn>2</m:mn></m:msub><m:mfenced separators=""><m:mi>y</m:mi></m:mfenced></m:mrow>
</m:munderover><m:mi>f</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced><m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

Both the outer integral <m:math><m:mi>I</m:mi></m:math>&#160;and the inner integrals  <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>y</m:mi></m:mfenced></m:math>&#160;are evaluated by the method, described by 
<a class="ref" href="#ref271">Patterson (1968)</a> and <a class="ref" href="#ref270">Patterson (1969)</a>, of the optimum addition of points to Gauss quadrature formulae.</div><div class="paramtext">This method uses a family of interlacing common point formulae.  Beginning with the <m:math><m:mn>3</m:mn></m:math>-point Gauss rule, formulae using <m:math><m:mn>7</m:mn></m:math>, <m:math><m:mn>15</m:mn></m:math>, <m:math><m:mn>31</m:mn></m:math>, <m:math><m:mn>63</m:mn></m:math>, <m:math><m:mn>127</m:mn></m:math>&#160;and finally <m:math><m:mn>255</m:mn></m:math>&#160;points are derived.  Each new formula contains all the pivots of the earlier formulae so that no function evaluations are wasted.  Each integral is evaluated by applying these formulae successively until two results are obtained which differ by less than the specified absolute accuracy.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref271" id="ref271"/>Patterson T N L (1968)  On some Gauss and Lobatto based integration formulae <i>Math. Comput.</i> <b>22</b> 877&#8211;881 </div>
<div class="paramtext"><a name="ref270" id="ref270"/>Patterson T N L (1969)  The optimum addition of points to quadrature formulae, errata <i>Math. Comput.</i> <b>23</b> 892 </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="YA" id="YA"/>1: &#160;&#160;&#8194; YA &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: <m:math><m:mi>a</m:mi></m:math>, the lower limit of the integral.</div></dd><dt class="paramhead"><a name="YB" id="YB"/>2: &#160;&#160;&#8194; YB &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: <m:math><m:mi>b</m:mi></m:math>, the upper limit of the integral. It is not necessary that <m:math><m:mi>a</m:mi><m:mo>&lt;</m:mo><m:mi>b</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="PHI1" id="PHI1"/>3: &#160;&#160;&#8194; PHI1 &#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="#PHI1">PHI1</a> must return the lower limit of the inner integral for a given value of <m:math><m:mi>y</m:mi></m:math>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#PHI1">PHI1</a> is:</div><table class="fspec"><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b>&#160;FUNCTION&#160;PHI1&#160;(</td><td class="tdfspec2"><a class="arg" href="../D01/d01daf.xml#PHI1_Y">Y</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">Y</td></tr></table>
<dl><dt class="paramhead"><a name="PHI1_Y" id="PHI1_Y"/>1: &#160;&#160;&#8194; Y &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the value of <m:math><m:mi>y</m:mi></m:math>&#160;for which the lower limit must be evaluated.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#PHI1">PHI1</a> must be declared as EXTERNAL in the (sub)program from which D01DAF 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="PHI2" id="PHI2"/>4: &#160;&#160;&#8194; PHI2 &#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="#PHI2">PHI2</a> must return the upper limit of the inner integral for a given value of <m:math><m:mi>y</m:mi></m:math>.</div><div class="subprog">
<div class="paramtext">The specification of <a class="arg" href="#PHI2">PHI2</a> is:</div><table class="fspec"><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b>&#160;FUNCTION&#160;PHI2&#160;(</td><td class="tdfspec2"><a class="arg" href="../D01/d01daf.xml#PHI2_Y">Y</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">Y</td></tr></table>
<dl><dt class="paramhead"><a name="PHI2_Y" id="PHI2_Y"/>1: &#160;&#160;&#8194; Y &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the value of <m:math><m:mi>y</m:mi></m:math>&#160;for which the upper limit must be evaluated.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#PHI2">PHI2</a> must be declared as EXTERNAL in the (sub)program from which D01DAF 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="F" id="F"/>5: &#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/d01daf.xml#F_X">X</a>, <a class="arg" href="../D01/d01daf.xml#F_Y">Y</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X, Y</td></tr></table>
<dl><dt class="paramhead"><a name="F_X" id="F_X"/>1: &#160;&#160;&#8194; X &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dt class="multi-paramhead"><a name="F_Y" id="F_Y"/>2: &#160;&#160;&#8194; Y &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the co-ordinates of the point <m:math><m:mfenced separators=""><m:mi>x</m:mi><m:mo>,</m:mo><m:mi>y</m:mi></m:mfenced></m:math>&#160;at which the integrand <m:math><m:mi>f</m:mi></m:math>&#160;must be evaluated.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#F">F</a> must be declared as EXTERNAL in the (sub)program from which D01DAF 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="ABSACC" id="ABSACC"/>6: &#160;&#160;&#8194; ABSACC &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the absolute accuracy requested.</div></dd><dt class="paramhead"><a name="ANS" id="ANS"/>7: &#160;&#160;&#8194; ANS &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: the estimated value of the integral.</div></dd><dt class="paramhead"><a name="NPTS" id="NPTS"/>8: &#160;&#160;&#8194; NPTS &#8211; INTEGER<span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: the total number of function evaluations.</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>9: &#160;&#160;&#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> D01DAF 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">This indicates that <m:math><m:mn>255</m:mn></m:math>&#160;points have been used in the outer integral and convergence has not been obtained.  All the inner integrals have, however, converged.  In this case <a class="arg" href="#ANS">ANS</a> may still contain an approximate estimate of the integral.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq10timesn" id="IFeq10timesn"/><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:mrow><m:mn>10</m:mn><m:mo>&#215;</m:mo><m:mi>n</m:mi></m:mrow></m:math></dt>
<dd>
<div class="paramtext">This indicates that the outer integral has converged but <m:math><m:mi>n</m:mi></m:math>&#160;inner integrals have failed to converge with the use of <m:math><m:mn>255</m:mn></m:math>&#160;points.  In this case <a class="arg" href="#ANS">ANS</a> may still contain an approximate estimate of the integral, but its reliability will decrease as <m:math><m:mi>n</m:mi></m:math>&#160;increases.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq10timesnplus1" id="IFeq10timesnplus1"/><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:mrow><m:mn>10</m:mn><m:mo>&#215;</m:mo><m:mi>n</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:math></dt>
<dd>
<div class="paramtext">This indicates that both the outer integral and <m:math><m:mi>n</m:mi></m:math>&#160;of the inner integrals have not converged.  <a class="arg" href="#ANS">ANS</a> may still contain an approximate estimate of the integral, but its reliability will decrease as <m:math><m:mi>n</m:mi></m:math>&#160;increases.</div>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">The absolute accuracy is specified by the variable <a class="arg" href="#ABSACC">ABSACC</a>.  If, on exit, <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;then the result is most likely correct to this accuracy.  Even if <a class="arg" href="#IFAIL">IFAIL</a> is nonzero on exit, it is still possible that the calculated result could differ from the true value by less than the given accuracy.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The time taken by D01DAF depends upon the complexity of the integrand and the accuracy requested.</div><div class="paramtext">With Patterson's method accidental convergence may occasionally occur, when two estimates of an integral agree to within the requested accuracy, but both estimates differ considerably from the true result.  This could occur in either the outer integral or in one or more of the inner integrals.</div><div class="paramtext">If it occurs in the outer integral then apparent convergence is likely to be obtained with considerably fewer integrand evaluations than may be expected.  If it occurs in an inner integral, the incorrect value could make the function <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>y</m:mi></m:mfenced></m:math>&#160;appear to be badly behaved, in which case a very large number of pivots may be needed for the overall evaluation of the integral.  Thus both unexpectedly small and unexpectedly large numbers of integrand evaluations should be considered as indicating possible trouble.  If accidental convergence is suspected, the integral may be recomputed, requesting better accuracy; if the new request is more stringent than the degree of accidental agreement (which is of course unknown), improved results should be obtained.  This is only possible when the accidental agreement is not better than machine accuracy.  It should be noted that the routine requests the same accuracy for the inner integrals as for the outer integral.  In practice it has been found that in the vast majority of cases this has proved to be adequate for the overall result of the double integral to be accurate to within the specified value.</div><div class="paramtext">The routine is not well-suited to non-smooth integrands, i.e., integrands having some kind of analytic discontinuity (such as a discontinuous or infinite partial derivative of some low-order) in, on the boundary of, or near, the region of integration.  <b>Warning</b>: such singularities may be induced by incautiously presenting an apparently smooth interval over the positive quadrant of the unit circle, <m:math><m:mi>R</m:mi></m:math>&#160;
<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>I</m:mi><m:mo>=</m:mo><m:msub><m:mo>&#8747;</m:mo><m:mi>R</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi><m:mo>+</m:mo><m:mi>y</m:mi></m:mfenced><m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:mi>y</m:mi></m:mrow><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

This may be presented to D01DAF as

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>I</m:mi><m:mo>=</m:mo><m:munderover><m:mo>&#8747;</m:mo><m:mn>0</m:mn><m:mn>1</m:mn></m:munderover> <m:mrow><m:mi>d</m:mi><m:mi>y</m:mi></m:mrow> <m:munderover><m:mo>&#8747;</m:mo><m:mn>0</m:mn><m:msqrt><m:mn>1</m:mn><m:mo>-</m:mo><m:msup><m:mi>y</m:mi><m:mn>2</m:mn></m:msup></m:msqrt></m:munderover> <m:mfenced separators=""><m:mi>x</m:mi><m:mo>+</m:mo><m:mi>y</m:mi></m:mfenced><m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow><m:mo>=</m:mo><m:munderover><m:mo>&#8747;</m:mo><m:mn>0</m:mn><m:mn>1</m:mn></m:munderover>
<m:mfenced separators=""><m:mfrac other="small"><m:mn>1</m:mn><m:mn>2</m:mn></m:mfrac><m:mfenced separators=""><m:mn>1</m:mn><m:mo>-</m:mo><m:msup><m:mi>y</m:mi><m:mn>2</m:mn></m:msup></m:mfenced><m:mo>+</m:mo><m:mi>y</m:mi><m:msqrt><m:mn>1</m:mn><m:mo>-</m:mo><m:msup><m:mi>y</m:mi><m:mn>2</m:mn></m:msup></m:msqrt></m:mfenced> <m:mrow><m:mi>d</m:mi><m:mi>y</m:mi></m:mrow> </m:math></td><td class="formula2"/></tr></table></div>

but here the outer integral has an induced square-root singularity stemming from the way the region has been presented to D01DAF.  This situation should be avoided by re-casting the problem.  For the example given, the use of polar co-ordinates would avoid the difficulty:

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>I</m:mi><m:mo>=</m:mo><m:munderover><m:mo>&#8747;</m:mo><m:mn>0</m:mn><m:mn>1</m:mn></m:munderover><m:mrow><m:mi>d</m:mi><m:mi>r</m:mi></m:mrow><m:munderover><m:mo>&#8747;</m:mo><m:mn>0</m:mn><m:mfrac><m:mi>&#960;</m:mi><m:mn>2</m:mn></m:mfrac></m:munderover><m:msup><m:mi>r</m:mi><m:mn>2</m:mn></m:msup><m:mfenced separators=""><m:mrow><m:mi>cos</m:mi><m:mo>&#8289;</m:mo><m:mi>&#965;</m:mi></m:mrow><m:mo>+</m:mo><m:mrow><m:mi>sin</m:mi><m:mo>&#8289;</m:mo><m:mi>&#965;</m:mi></m:mrow></m:mfenced><m:mrow><m:mi>d</m:mi><m:mi>&#965;</m:mi></m:mrow><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div></div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example evaluates the integral discussed in  <a class="sec" href="#fcomments">Section 8</a>, presenting it to D01DAF  first as

<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:msqrt><m:mn>1</m:mn><m:mo>-</m:mo><m:msup><m:mi>y</m:mi><m:mn>2</m:mn></m:msup></m:msqrt></m:munderover><m:mfenced separators=""><m:mi>x</m:mi><m:mo>+</m:mo><m:mi>y</m:mi></m:mfenced> <m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:mi>y</m:mi></m:mrow>
</m:math></td><td class="formula2"/></tr></table></div>

and then as

<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:mfrac><m:mi>&#960;</m:mi><m:mn>2</m:mn></m:mfrac></m:munderover><m:msup><m:mi>r</m:mi><m:mn>2</m:mn></m:msup><m:mfenced separators=""><m:mrow><m:mi>cos</m:mi><m:mo>&#8289;</m:mo><m:mi>&#965;</m:mi></m:mrow><m:mo>+</m:mo><m:mrow><m:mi>sin</m:mi><m:mo>&#8289;</m:mo><m:mi>&#965;</m:mi></m:mrow></m:mfenced><m:mrow><m:mi>d</m:mi><m:mi>&#965;</m:mi></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:mi>r</m:mi></m:mrow><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

Note the difference in the number of function evaluations.</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/d01dafe.f">Program Text (d01dafe.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/d01dafe.r">Program Results (d01dafe.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/D01/d01daf.pdf">D01DAF (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>
