<?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>E04BBF/E04BBA : 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/E04/e04bbf.pdf">E04BBF/E04BBA (PDF version)</a></div><div><a class="chap" href="e04conts.xml">E04 Chapter Contents</a></div><div><a class="chapint" href="e04intro.xml">E04 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/>E04BBF/E04BBA</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="htmltoc" onclick="showLevel('tocspecification');"><span class="htmltocplus" id="tocspecificationplus">+</span><span class="htmltocminus" id="tocspecificationminus">&#8722;</span></span>
<a class="htmltoc" href="#specification">2&#160;&#160;<b>Specification</b></a>
<div class="htmltocitem" id="tocspecification">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#routFspec">2.1&#160;&#160;<b>Specification for E04BBF</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#routAspec">2.2&#160;&#160;<b>Specification for E04BBA</b></a>
</div>
</div>
</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">E04BBF/E04BBA searches for a minimum, in a given finite interval,  of a continuous function of a single variable, using function and first derivative values.  The method (based on cubic interpolation) is intended for functions which have a continuous first derivative (although it will usually work if the derivative has occasional discontinuities).</div>
<div class="paramtext">E04BBA is a version of E04BBF that has additional parameters in order to make it safe for use in multithreaded applications (see <a class="sec" href="#parameters">Section 5</a>).</div><h2 class="standard"><a class="sec" name="specification" id="specification"/>2&#160;&#160;Specification</h2><h3 class="standard"><a class="sec" name="routFspec" id="routFspec"/>2.1&#160;&#160;Specification for E04BBF</h3>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;E04BBF&#160;(</td><td class="tdfspec2"><a class="arg" href="#FUNCT">FUNCT</a>, <a class="arg" href="#E1">E1</a>, <a class="arg" href="#E2">E2</a>, <a class="arg" href="#A">A</a>, <a class="arg" href="#B">B</a>, <a class="arg" href="#MAXCAL">MAXCAL</a>, <a class="arg" href="#X">X</a>, <a class="arg" href="#F">F</a>, <a class="arg" href="#G">G</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">MAXCAL, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">E1, E2, A, B, X, F, G</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">FUNCT</td></tr></table><h3 class="standard"><a class="sec" name="routAspec" id="routAspec"/>2.2&#160;&#160;Specification for E04BBA</h3>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;E04BBA&#160;(</td><td class="tdfspec2"><a class="arg" href="#FUNCT">FUNCT</a>, <a class="arg" href="#E1">E1</a>, <a class="arg" href="#E2">E2</a>, <a class="arg" href="#A">A</a>, <a class="arg" href="#B">B</a>, <a class="arg" href="#MAXCAL">MAXCAL</a>, <a class="arg" href="#X">X</a>, <a class="arg" href="#F">F</a>, <a class="arg" href="#G">G</a>, <a class="arg" href="#IUSER">IUSER</a>, <a class="arg" href="#RUSER">RUSER</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">MAXCAL, IUSER(*), IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">E1, E2, A, B, X, F, G, RUSER(*)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">FUNCT</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">E04BBF/E04BBA is applicable to problems of the form:

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mrow><m:mi>Minimize</m:mi><m:mo>&#8289;</m:mo><m:mi>F</m:mi></m:mrow><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mtext>&#8195; subject to &#8195;</m:mtext><m:mi>a</m:mi><m:mo>&#8804;</m:mo><m:mi>x</m:mi><m:mo>&#8804;</m:mo><m:mi>b</m:mi>
</m:math></td><td class="formula2"/></tr></table></div>

when the first derivative <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mi>d</m:mi><m:mi>F</m:mi></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow>
 </m:mfrac>
</m:math>&#160;can be calculated.  The routine normally computes a sequence of <m:math><m:mi>x</m:mi></m:math>&#160;values which tend in the limit to a minimum of <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;subject to the given bounds.  It also progressively reduces the interval <m:math><m:mfenced separators="" open="[" close="]"><m:mi>a</m:mi><m:mo>,</m:mo><m:mi>b</m:mi></m:mfenced></m:math>&#160;in which the minimum is known to lie.  It uses the safeguarded cubic-interpolation method described in <a class="ref" href="#ref335">Gill and Murray (1973)</a>.</div><div class="paramtext">You must supply a <a class="arg" href="#FUNCT">FUNCT</a> to evaluate  <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;and <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mi>d</m:mi><m:mi>F</m:mi></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow>
 </m:mfrac>
</m:math>.  The parameters <a class="arg" href="#E1">E1</a> and  <a class="arg" href="#E2">E2</a> together specify the accuracy

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi mathvariant="italic">Tol</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#E1"><m:mi mathcolor="#EE0000" mathvariant="bold">E1</m:mi></m:maction><m:mo>&#215;</m:mo><m:mfenced open="|" close="|" separators=""><m:mi>x</m:mi></m:mfenced><m:mo>+</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#E2"><m:mi mathcolor="#EE0000" mathvariant="bold">E2</m:mi></m:maction>
</m:math></td><td class="formula2"/></tr></table></div>

to which the position of the minimum is required.  Note that <a class="arg" href="#FUNCT">FUNCT</a> is never called at a point which is closer than <m:math><m:mi mathvariant="italic">Tol</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;to a previous point.</div><div class="paramtext">If the original interval <m:math><m:mfenced separators="" open="[" close="]"><m:mi>a</m:mi><m:mo>,</m:mo><m:mi>b</m:mi></m:mfenced></m:math>&#160;contains more than one minimum, E04BBF/E04BBA will normally find one of the minima.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref335" id="ref335"/>Gill P E and Murray W (1973)  Safeguarded steplength algorithms for optimization using descent methods <i>NPL Report NAC 37</i> National Physical Laboratory </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="FUNCT" id="FUNCT"/>1: &#160;&#160;&#8194; FUNCT &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd><div class="paramtext">You must supply this routine to calculate the values of <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;and <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mi>d</m:mi><m:mi>F</m:mi></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow>
 </m:mfrac>
</m:math>&#160;at any point <m:math><m:mi>x</m:mi></m:math>&#160;in <m:math><m:mfenced separators="" open="[" close="]"><m:mi>a</m:mi><m:mo>,</m:mo><m:mi>b</m:mi></m:mfenced></m:math>.</div>
<div class="paramtext">It should be tested separately before being used in conjunction with E04BBF/E04BBA.</div><div class="subprog">
<div class="paramtext">The specification of 
   <a class="arg" href="#FUNCT">FUNCT</a>
   for E04BBF is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;FUNCT&#160;(</td><td class="tdfspec2"><a class="arg" href="../E04/e04bbf.xml#FUNCT_XC">XC</a>, <a class="arg" href="../E04/e04bbf.xml#FUNCT_FC">FC</a>, <a class="arg" href="../E04/e04bbf.xml#FUNCT_GC">GC</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">XC, FC, GC</td></tr></table>
<div class="paramtext">The specification of 
   <a class="arg" href="#FUNCT">FUNCT</a>
   for E04BBA is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;FUNCT&#160;(</td><td class="tdfspec2"><a class="arg" href="../E04/e04bbf.xml#FUNCT_XC">XC</a>, <a class="arg" href="../E04/e04bbf.xml#FUNCT_FC">FC</a>, <a class="arg" href="../E04/e04bbf.xml#FUNCT_GC">GC</a>, <a class="arg" href="../E04/e04bbf.xml#FUNCT_IUSER">IUSER</a>, <a class="arg" href="../E04/e04bbf.xml#FUNCT_RUSER">RUSER</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">IUSER(*)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">XC, FC, GC, RUSER(*)</td></tr></table>
<dl><dt class="paramhead"><a name="FUNCT_XC" id="FUNCT_XC"/>1: &#160;&#160;&#8194; XC &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the point <m:math><m:mi>x</m:mi></m:math>&#160;at which the values of <m:math><m:mi>F</m:mi></m:math>&#160;and <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mi>d</m:mi><m:mi>F</m:mi></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow>
 </m:mfrac>
</m:math>&#160;are required.</div></dd><dt class="paramhead"><a name="FUNCT_FC" id="FUNCT_FC"/>2: &#160;&#160;&#8194; FC &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: must be set to the value of the function <m:math><m:mi>F</m:mi></m:math>&#160;at the current point <m:math><m:mi>x</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="FUNCT_GC" id="FUNCT_GC"/>3: &#160;&#160;&#8194; GC &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: must be set to the value of the first derivative <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mi>d</m:mi><m:mi>F</m:mi></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow>
 </m:mfrac>
</m:math>&#160;at the current point <m:math><m:mi>x</m:mi></m:math>.</div></dd><dd class="note"><b>Note:</b> <span class="italic"> the following are additional parameters for specific use with E04BBA.  Users of E04BBF therefore need not read the remainder of this description</span>.</dd><dt class="paramhead"><a name="FUNCT_IUSER" id="FUNCT_IUSER"/>4: &#160;&#160;&#8194; IUSER(<m:math><m:mo>*</m:mo></m:math>) &#8211; INTEGER array<span class="pclass">User Workspace</span></dt><dt class="multi-paramhead"><a name="FUNCT_RUSER" id="FUNCT_RUSER"/>5: &#160;&#160;&#8194; RUSER(<m:math><m:mo>*</m:mo></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">User Workspace</span></dt><dd><div class="paramtext"><a class="arg" href="#FUNCT">FUNCT</a> is called from E04BBA with the parameters <a class="arg" href="../E04/e04bbf.xml#FUNCT_IUSER">IUSER</a> and <a class="arg" href="../E04/e04bbf.xml#FUNCT_RUSER">RUSER</a> as supplied to E04BBA.  You are free to use the arrays <a class="arg" href="../E04/e04bbf.xml#FUNCT_IUSER">IUSER</a> and <a class="arg" href="../E04/e04bbf.xml#FUNCT_RUSER">RUSER</a> to supply information to <a class="arg" href="#FUNCT">FUNCT</a>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#FUNCT">FUNCT</a> must be declared as EXTERNAL in the (sub)program from which E04BBF/E04BBA 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="E1" id="E1"/>2: &#160;&#160;&#8194; E1 &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: the relative accuracy to which the position of a minimum is required.  (Note that, since <a class="arg" href="#E1">E1</a> is a relative tolerance, the scaling of <m:math><m:mi>x</m:mi></m:math>&#160;is automatically taken into account.)
<div class="paramtext"><a class="arg" href="#E1">E1</a> should be no smaller than <m:math><m:mn>2</m:mn><m:mi>&#949;</m:mi></m:math>, and preferably not much less than <m:math><m:msqrt><m:mi>&#949;</m:mi></m:msqrt></m:math>, where <m:math><m:mi>&#949;</m:mi></m:math>&#160;is the <span class="bitalic">machine precision</span>.</div>
</div>
<div class="paramtext"><i>On exit</i>: if you set <a class="arg" href="#E1">E1</a> to <m:math><m:mn>0.0</m:mn></m:math>&#160;(or to any value less than <m:math><m:mi>&#949;</m:mi></m:math>), <a class="arg" href="#E1">E1</a> will be reset to the default value <m:math><m:msqrt><m:mi>&#949;</m:mi></m:msqrt></m:math>&#160;before starting the minimization process.</div></dd><dt class="paramhead"><a name="E2" id="E2"/>3: &#160;&#160;&#8194; E2 &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: the absolute accuracy to which the position of a minimum is required.  <a class="arg" href="#E2">E2</a> should be no smaller than <m:math><m:mn>2</m:mn><m:mi>&#949;</m:mi></m:math>.</div>
<div class="paramtext"><i>On exit</i>: if you set <a class="arg" href="#E2">E2</a> to <m:math><m:mn>0.0</m:mn></m:math>&#160;(or to any value less than <m:math><m:mi>&#949;</m:mi></m:math>), <a class="arg" href="#E2">E2</a> will be reset to the default value <m:math><m:msqrt><m:mi>&#949;</m:mi></m:msqrt></m:math>.</div></dd><dt class="paramhead"><a name="A" id="A"/>4: &#160;&#160;&#8194; A &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the lower bound <m:math><m:mi>a</m:mi></m:math>&#160;of the interval containing a minimum.</div><div class="paramtext"><i>On exit</i>: an improved lower bound on the position of the minimum.</div></dd><dt class="paramhead"><a name="B" id="B"/>5: &#160;&#160;&#8194; B &#8211; <span class="bitalic">double precision</span><span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the upper bound <m:math><m:mi>b</m:mi></m:math>&#160;of the interval containing a minimum.</div><div class="paramtext"><i>On exit</i>: an improved upper bound on the position of the minimum.</div></dd><dt class="paramhead"><a name="MAXCAL" id="MAXCAL"/>6: &#160;&#160;&#8194; MAXCAL &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: the maximum number of calls of <a class="arg" href="#FUNCT">FUNCT</a> to be allowed.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MAXCAL"><m:mi mathcolor="#EE0000" mathvariant="bold">MAXCAL</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>2</m:mn></m:math>.  (Few problems will require more than <m:math><m:mn>20</m:mn></m:math>.)
<div class="paramtext">There will be an error exit (see <a class="sec" href="#errors">Section 6</a>) after <a class="arg" href="#MAXCAL">MAXCAL</a> calls of <a class="arg" href="#FUNCT">FUNCT</a></div></div>
<div class="paramtext"><i>On exit</i>: the total number of times that <a class="arg" href="#FUNCT">FUNCT</a> was actually called.</div></dd><dt class="paramhead"><a name="X" id="X"/>7: &#160;&#160;&#8194; X &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the estimated position of the minimum.</div></dd><dt class="paramhead"><a name="F" id="F"/>8: &#160;&#160;&#8194; F &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd>
<div class="paramtext"><i>On exit</i>: the function value at the final point given in <a class="arg" href="#X">X</a>.</div></dd><dt class="paramhead"><a name="G" id="G"/>9: &#160;&#160;&#8194; G &#8211; <span class="bitalic">double precision</span><span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: the value of the first derivative at the final point in <a class="arg" href="#X">X</a>.</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"><b>Note:</b> <span class="italic">for E04BBA, <a class="arg" href="#IFAIL">IFAIL</a> does not occur in this position in the parameter list.  See the additional parameters described below</span>.</div><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><dd class="note"><b>Note:</b> <span class="italic"> the following are additional parameters for specific use with E04BBA.  Users of E04BBF therefore need not read the remainder of this description</span>.</dd><dt class="paramhead"><a name="IUSER" id="IUSER"/>10: &#8194; IUSER(<m:math><m:mo>*</m:mo></m:math>) &#8211; INTEGER array<span class="pclass">User Workspace</span></dt><dd><div class="paramtext"><b>Note:</b> the dimension of the array <a class="arg" href="#IUSER">IUSER</a>
must be at least
<m:math><m:mn>1</m:mn></m:math>.</div> <div class="paramtext">
<a class="arg" href="#IUSER">IUSER</a> is not used by E04BBA, but is passed directly to <a class="arg" href="#FUNCT">FUNCT</a> and may be used to pass information to that routine.</div></dd><dt class="paramhead"><a name="RUSER" id="RUSER"/>11: &#8194; RUSER(<m:math><m:mo>*</m:mo></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">User Workspace</span></dt><dd><div class="paramtext"><b>Note:</b> the dimension of the array <a class="arg" href="#RUSER">RUSER</a>
must be at least
<m:math><m:mn>1</m:mn></m:math>.</div> <div class="paramtext">
<a class="arg" href="#RUSER">RUSER</a> is not used by E04BBA, but is passed directly to <a class="arg" href="#FUNCT">FUNCT</a> and may be used to pass information to that routine.</div></dd><dt class="paramhead"><a name="IFAIL2" id="IFAIL2"/>12: &#8194; IFAIL &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><b>Note:</b> see the parameter description for <a class="arg" href="#IFAIL">IFAIL</a> above.</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> E04BBF/E04BBA 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>
<table class="ifail"><tr><td class="ifail1">On&#160;entry,</td><td class="ifail2-90"><m:math><m:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="#A"><m:mi mathcolor="#EE0000" mathvariant="bold">A</m:mi></m:maction><m:mo>+</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#E2"><m:mi mathcolor="#EE0000" mathvariant="bold">E2</m:mi></m:maction></m:mfenced><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#B"><m:mi mathcolor="#EE0000" mathvariant="bold">B</m:mi></m:maction></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MAXCAL"><m:mi mathcolor="#EE0000" mathvariant="bold">MAXCAL</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>2</m:mn></m:math>.</td></tr></table>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq2" id="IFeq2"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>2</m:mn></m:math></dt>
<dd>
<div class="paramtext">The number of calls of <a class="arg" href="#FUNCT">FUNCT</a> has exceeded <a class="arg" href="#MAXCAL">MAXCAL</a>.  This may have happened simply because <a class="arg" href="#MAXCAL">MAXCAL</a> was set too small for a particular problem, or may be due to a mistake in <a class="arg" href="#FUNCT">FUNCT</a>.  If no mistake can be found in <a class="arg" href="#FUNCT">FUNCT</a>, restart E04BBF/E04BBA  (preferably with the values of <a class="arg" href="#A">A</a> and <a class="arg" href="#B">B</a> given on exit from the previous call of E04BBF/E04BBA).</div>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">If <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;is <m:math><m:mi>&#948;</m:mi></m:math>-unimodal for some <m:math><m:mi>&#948;</m:mi><m:mo>&lt;</m:mo><m:mi mathvariant="italic">Tol</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>, where  <m:math><m:mi mathvariant="italic">Tol</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#E1"><m:mi mathcolor="#EE0000" mathvariant="bold">E1</m:mi></m:maction><m:mo>&#215;</m:mo><m:mfenced open="|" close="|" separators=""><m:mi>x</m:mi></m:mfenced><m:mo>+</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#E2"><m:mi mathcolor="#EE0000" mathvariant="bold">E2</m:mi></m:maction></m:math>, then, on exit,  <m:math><m:mi>x</m:mi></m:math>&#160;approximates the minimum of <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;in the original interval <m:math><m:mfenced separators="" open="[" close="]"><m:mi>a</m:mi><m:mo>,</m:mo><m:mi>b</m:mi></m:mfenced></m:math>&#160;with an error less than  <m:math><m:mn>3</m:mn><m:mo>&#215;</m:mo><m:mi mathvariant="italic">Tol</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">Timing depends on the behaviour of <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>, the accuracy demanded and the length of the interval <m:math><m:mfenced separators="" open="[" close="]"><m:mi>a</m:mi><m:mo>,</m:mo><m:mi>b</m:mi></m:mfenced></m:math>.  Unless  <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;and <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mi>d</m:mi><m:mi>F</m:mi></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow>
 </m:mfrac>
</m:math>&#160;can be evaluated very quickly, the run time will usually be dominated by the time spent in <a class="arg" href="#FUNCT">FUNCT</a>.</div><div class="paramtext">If <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;has more than one minimum in the original interval <m:math><m:mfenced separators="" open="[" close="]"><m:mi>a</m:mi><m:mo>,</m:mo><m:mi>b</m:mi></m:mfenced></m:math>, E04BBF/E04BBA will determine an approximation  <m:math><m:mi>x</m:mi></m:math>&#160;(and improved bounds <m:math><m:mi>a</m:mi></m:math>&#160;and <m:math><m:mi>b</m:mi></m:math>)  for one of the minima.</div><div class="paramtext">If E04BBF/E04BBA finds an <m:math><m:mi>x</m:mi></m:math>&#160;such that <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>-</m:mo><m:msub><m:mi>&#948;</m:mi><m:mn>1</m:mn></m:msub></m:mfenced><m:mo>&gt;</m:mo><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>&lt;</m:mo><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>+</m:mo><m:msub><m:mi>&#948;</m:mi><m:mn>2</m:mn></m:msub></m:mfenced></m:math>&#160;for some <m:math><m:msub><m:mi>&#948;</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>&#948;</m:mi><m:mn>2</m:mn></m:msub><m:mo>&#8805;</m:mo><m:mi mathvariant="italic">Tol</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>, the interval <m:math><m:mfenced separators="" open="[" close="]"><m:mrow><m:mi>x</m:mi><m:mo>-</m:mo><m:msub><m:mi>&#948;</m:mi><m:mn>1</m:mn></m:msub></m:mrow><m:mo>,</m:mo><m:mrow><m:mi>x</m:mi><m:mo>+</m:mo><m:msub><m:mi>&#948;</m:mi><m:mn>2</m:mn></m:msub></m:mrow></m:mfenced></m:math>&#160;will be regarded as containing a minimum, even if <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;is less than  <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>-</m:mo><m:msub><m:mi>&#948;</m:mi><m:mn>1</m:mn></m:msub></m:mfenced></m:math>&#160;and <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi><m:mo>+</m:mo><m:msub><m:mi>&#948;</m:mi><m:mn>2</m:mn></m:msub></m:mfenced></m:math>&#160;only due to rounding errors in the subroutine.  Therefore  <a class="arg" href="#FUNCT">FUNCT</a> should be programmed to calculate <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;as accurately as possible, so that E04BBF/E04BBA will not be liable to find a spurious minimum.  (For similar reasons,  <m:math>
 <m:mfrac other="display">
  <m:mrow><m:mi>d</m:mi><m:mi>F</m:mi></m:mrow>
  <m:mrow><m:mi>d</m:mi><m:mi>x</m:mi></m:mrow>
 </m:mfrac>
</m:math>&#160;should be evaluated as accurately as possible.)</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">A sketch of 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>x</m:mi></m:mfenced><m:mo>=</m:mo><m:mfrac><m:mrow><m:mi>sin</m:mi><m:mo>&#8289;</m:mo><m:mi>x</m:mi></m:mrow><m:mi>x</m:mi></m:mfrac>
</m:math></td><td class="formula2"/></tr></table></div>

shows that it has a minimum somewhere in the range <m:math><m:mfenced separators="" open="[" close="]"><m:mn>3.5</m:mn><m:mo>,</m:mo><m:mn>5.0</m:mn></m:mfenced></m:math>.  The following program shows how E04BBF/E04BBA can be used to obtain a good approximation to the position of a minimum.</div><h3 class="standard"><a class="sec" name="examtext" id="examtext"/>9.1&#160;&#160;Program Text</h3>
<div class="paramtext"><b>Note:</b> <span class="italic">the following programs illustrate the use of E04BBF and E04BBA</span>.</div><p><a class="verbatimref" href="../../examples/source/e04bbfe.f">Program Text (e04bbfe.f)</a></p><p><a class="verbatimref" href="../../examples/source/e04bbae.f">Program Text (e04bbae.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/e04bbfe.r">Program Results (e04bbfe.r)</a></p><p><a class="verbatimref" href="../../examples/baseresults/e04bbae.r">Program Results (e04bbae.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/E04/e04bbf.pdf">E04BBF/E04BBA (PDF version)</a></div><div><a class="chap" href="e04conts.xml">E04 Chapter Contents</a></div><div><a class="chapint" href="e04intro.xml">E04 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>
