<?xml-stylesheet type="text/xsl" href="../styles/pmathml.xsl"?><html xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://www.w3.org/1999/xhtml" xmlns:dsi="http://www.w3.org/1999/xlink" xml:space="preserve"><head>
<!-- saved from url=(0014)about:internet -->
<title>
    NAG Fortran Library Manual, Mark 21 : 
   E04ABF</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 href="../../pdf/E04/e04abf.pdf">E04ABF (pdf version)</a></div><div><a href="e04_conts.xml">Chapter Contents</a></div><div><a href="e04_intro.xml">Chapter Introduction</a></div>
<div><a href="../mark21.xml">NAG Library Manual</a></div><hr/><h1 class="libdoc">NAG Fortran Library Routine Document<br/><br/>E04ABF/E04ABA</h1><div class="paramtext"><div class="header"><b>Note:</b> 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><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">&#160;1&#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">&#160;2&#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">&#160;2.1&#160;<b>Specification for </b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#routAspec">&#160;2.2&#160;<b>Specification for </b></a>
</div>
</div>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#description">&#160;3&#160;<b>Description</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#references">&#160;4&#160;<b>References</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#parameters">&#160;5&#160;<b>Parameters</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#errors">&#160;6&#160;<b>Error Indicators and Warnings</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#accuracy">&#160;7&#160;<b>Accuracy</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments">&#160;8&#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">&#160;9&#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">&#160;9.1&#160;<b>Program Text</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examdata">&#160;9.2&#160;<b>Program Data</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examresults">&#160;9.3&#160;<b>Program Results</b></a>
</div>
</div>
</div>
</div>
</div><h2><a name="purpose" id="purpose"/>1&#160;&#160;Purpose</h2><div class="paramtext">E04ABF/E04ABA searches for a minimum, in a given finite interval,  of a continuous function of a single variable, using function values only.  The method (based on quadratic 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">E04ABA is a version of E04ABF that has additional parameters in order to make it safe for use in multithreaded applications (see Section <a class="secref" href="#parameters">5</a>).</div><h2><a name="specification" id="specification"/>2&#160;&#160;Specification</h2><h3><a name="routFspec" id="routFspec"/>2.1&#160;&#160;Specification for E04ABF</h3>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;E04ABF&#160;(</td><td class="tdfspec2"><a class="argref" href="#FUNCT">FUNCT</a>, <a class="argref" href="#E1">E1</a>, <a class="argref" href="#E2">E2</a>, <a class="argref" href="#A">A</a>, <a class="argref" href="#B">B</a>, <a class="argref" href="#MAXCAL">MAXCAL</a>, <a class="argref" href="#X">X</a>, <a class="argref" href="#F">F</a>, <a class="argref" 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</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">FUNCT</td></tr></table><h3><a name="routAspec" id="routAspec"/>2.2&#160;&#160;Specification for E04ABA</h3>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;E04ABA&#160;(</td><td class="tdfspec2"><a class="argref" href="#FUNCT">FUNCT</a>, <a class="argref" href="#E1">E1</a>, <a class="argref" href="#E2">E2</a>, <a class="argref" href="#A">A</a>, <a class="argref" href="#B">B</a>, <a class="argref" href="#MAXCAL">MAXCAL</a>, <a class="argref" href="#X">X</a>, <a class="argref" href="#F">F</a>, <a class="argref" href="#IUSER">IUSER</a>, <a class="argref" href="#RUSER">RUSER</a>, <a class="argref" 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, RUSER(*)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">FUNCT</td></tr></table><h2><a name="description" id="description"/>3&#160;&#160;Description</h2><div class="paramtext">E04ABF/E04ABA is applicable to problems of the form:
</div>
<div class="formula"><table class="formula"><tr><td class="formula"><m:math xmlns:m="http://www.w3.org/1998/Math/MathML" 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:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>
<div class="paramtext">
It normally computes a sequence of <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>x</m:mi></m:math>&#160;values which tend in the limit to a minimum of <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><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 quadratic-interpolation method described in <a class="litref" href="#ref335">Gill  and Murray (1973)</a>.</div>
<div class="paramtext">You must supply a (sub)program <a class="argref" href="#FUNCT">FUNCT</a> to evaluate <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>.  The parameters  <a class="argref" href="#E1">E1</a> and  <a class="argref" href="#E2">E2</a> together specify the accuracy
</div>
<div class="formula"><table class="formula"><tr><td class="formula"><m:math xmlns:m="http://www.w3.org/1998/Math/MathML" 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:href="#E1" dsi:type="simple"><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:href="#E2" dsi:type="simple"><m:mi mathcolor="#EE0000" mathvariant="bold">E2</m:mi></m:maction>
</m:math></td><td class="formula2"/></tr></table></div>
<div class="paramtext">
to which the position of the minimum is required.  Note that  <a class="argref" href="#FUNCT">FUNCT</a> is never called at any point which is closer than <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><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, E04ABF/E04ABA will normally find one of the minima.</div><h2><a name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext">
<p><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 </p>
</div><h2><a 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 value of the function <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;at any point <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>x</m:mi></m:math>&#160;in <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mfenced separators="" open="[" close="]"><m:mi>a</m:mi><m:mo>,</m:mo><m:mi>b</m:mi></m:mfenced></m:math>.  It should be tested separately before being used in conjunction with E04ABF/E04ABA.</div><div class="subprog">
<div class="paramtext">The specification of 
   <a class="argref" href="#FUNCT">FUNCT</a>
   for E04ABF is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;FUNCT&#160;(</td><td class="tdfspec2"><a class="argref" href="#FUNCT_XC">XC</a>, <a class="argref" href="#FUNCT_FC">FC</a>)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">XC, FC</td></tr></table>
<div class="paramtext">The specification of 
   <a class="argref" href="#FUNCT">FUNCT</a>
   for E04ABA is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;FUNCT&#160;(</td><td class="tdfspec2"><a class="argref" href="#FUNCT_XC">XC</a>, <a class="argref" href="#FUNCT_FC">FC</a>, <a class="argref" href="#FUNCT_IUSER">IUSER</a>, <a class="argref" href="#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, 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 xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>x</m:mi></m:math>&#160;at which the value of <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>F</m:mi></m:math>&#160;is 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 xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>F</m:mi></m:math>&#160;at the current point <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 E04ABA.  Users of E04ABF therefore need not read the remainder of this description</span>.</dd><dt class="paramhead"><a name="FUNCT_IUSER" id="FUNCT_IUSER"/>3:
  
  &#160;&#160;&#8194;
  IUSER(<m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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"/>4:
  
  &#160;&#160;&#8194;
  RUSER(<m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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="argref" href="#FUNCT">FUNCT</a> is called from E04ABA with the parameters  <a class="argref" href="#FUNCT_IUSER">IUSER</a> and  <a class="argref" href="#FUNCT_RUSER">RUSER</a> as supplied to E04ABA.  You are free to use the arrays  <a class="argref" href="#FUNCT_IUSER">IUSER</a> and  <a class="argref" href="#FUNCT_RUSER">RUSER</a> to supply information to  <a class="argref" href="#FUNCT">FUNCT</a>.</div></dd></dl>
</div>
<div class="paramtext"><a class="argref" href="#FUNCT">FUNCT</a>
 must be declared as EXTERNAL in the (sub)program from which E04ABF/E04ABA 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="argref" href="#E1">E1</a> is a relative tolerance, the scaling of <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>x</m:mi></m:math>&#160;is automatically taken into account.)
<div class="paramtext"><a class="argref" href="#E1">E1</a> should be no smaller than <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mn>2</m:mn><m:mi>&#949;</m:mi></m:math>, and preferably not much less than <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:msqrt><m:mi>&#949;</m:mi></m:msqrt></m:math>, where <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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="argref" href="#E1">E1</a> to <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mn>0.0</m:mn></m:math>&#160;(or to any value less than <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>&#949;</m:mi></m:math>), <a class="argref" href="#E1">E1</a>will be reset to the default value <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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="argref" href="#E2">E2</a> should be no smaller than <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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="argref" href="#E2">E2</a> to <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mn>0.0</m:mn></m:math>&#160;(or to any value less than <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>&#949;</m:mi></m:math>), <a class="argref" href="#E2">E2</a> will be reset to the default value <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><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 <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;to be allowed.</div><div class="paramtext"><i>Constraint</i>:
  <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:maction actiontype="link" dsi:href="#MAXCAL" dsi:type="simple"><m:mi mathcolor="#EE0000" mathvariant="bold">MAXCAL</m:mi></m:maction><m:mo>&#8805;</m:mo><m:mn>3</m:mn></m:math>.  (Few problems will require more than 30.)
<div class="paramtext">There will be an error exit (see Section <a class="secref" href="#errors">6</a>) after <a class="argref" href="#MAXCAL">MAXCAL</a> calls of <a class="argref" href="#FUNCT">FUNCT</a></div></div>
<div class="paramtext"><i>On exit</i>: the total number of times that <a class="argref" 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="argref" href="#X">X</a>.</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"><b>Note:</b> <span class="italic">for E04ABA, <a class="argref" href="#IFAIL2">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 initial entry</i>: <a class="argref" href="#IFAIL">IFAIL</a> must be set to 0, <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 Chapter <a class="secref" href="../P01/p01_conts.xml">P01</a> for details.</div><div class="paramtext"><i>On final exit</i>: <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:maction actiontype="link" dsi:href="#IFAIL" dsi:type="simple"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction> <m:mo>=</m:mo><m:maction actiontype="link" dsi:href="#errors" dsi:type="simple"><m:mn mathvariant="bold" mathcolor="#003399">0</m:mn></m:maction></m:math>&#160;unless the routine detects an error (see Section <a class="secref" href="#errors">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 xmlns:m="http://www.w3.org/1998/Math/MathML"><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 1 is recommended.  Otherwise, because for this routine the values of the output parameters may be useful even if <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:maction actiontype="link" dsi:href="#IFAIL" dsi:type="simple"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction> <m:mo>&#8800;</m:mo><m:maction actiontype="link" dsi:href="#errors" dsi:type="simple"><m:mn mathvariant="bold" mathcolor="#003399">0</m:mn></m:maction></m:math>&#160;on exit, the recommended value is <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:math>.  <b>When the value <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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="argref" 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 E04ABA.  Users of E04ABF therefore need not read the remainder of this description</span>.</dd><dt class="paramhead"><a name="IUSER" id="IUSER"/>9:
  
  &#160;&#160;&#8194;
  IUSER(<m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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="argref" href="#IUSER">IUSER</a> must be at least <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mn>1</m:mn></m:math>.</div> <div class="paramtext">
<a class="argref" href="#IUSER">IUSER</a> is not used by E04ABA, but is passed directly to the user-supplied (sub)program <a class="argref" href="#FUNCT">FUNCT</a> and may be used to pass information to that routine.</div></dd><dt class="paramhead"><a name="RUSER" id="RUSER"/>10:
  
  &#8194;
  RUSER(<m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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="argref" href="#RUSER">RUSER</a> must be at least <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mn>1</m:mn></m:math>.</div> <div class="paramtext">
<a class="argref" href="#RUSER">RUSER</a> is not used by E04ABA, but is passed directly to the user-supplied (sub)program <a class="argref" href="#FUNCT">FUNCT</a> and may be used to pass information to that routine.</div></dd><dt class="paramhead"><a name="IFAIL2" id="IFAIL2"/>11:
  
  &#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="argref" href="#IFAIL">IFAIL</a> above.</div></dd></dl><h2><a name="errors" id="errors"/>6&#160;&#160;Error Indicators and Warnings</h2>
 <div class="paramtext">If on entry <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:maction actiontype="link" dsi:href="#IFAIL" dsi:type="simple"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction> <m:mo>=</m:mo></m:math>&#160;<a class="ifailref" href="#errors">0</a> or <a class="ifailref" href="#errors">&#8722;1</a>, explanatory error messages are output on the current error message unit (as defined by <a class="rtnref" href="../X04/x04aaf.xml">X04AAF</a>).</div><div class="paramtext">Errors or warnings detected by the routine:</div>
<dl class="ifails"><dt class="errorhead"><a name="IFeq1" id="IFeq1"/><m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:maction actiontype="link" dsi:href="#IFAIL" dsi:type="simple"><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" style="width:100%"><m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mfenced separators=""><m:maction actiontype="link" dsi:href="#A" dsi:type="simple"><m:mi mathcolor="#EE0000" mathvariant="bold">A</m:mi></m:maction><m:mo>+</m:mo><m:maction actiontype="link" dsi:href="#E2" dsi:type="simple"><m:mi mathcolor="#EE0000" mathvariant="bold">E2</m:mi></m:maction></m:mfenced><m:mo>&#8805;</m:mo><m:maction actiontype="link" dsi:href="#B" dsi:type="simple"><m:mi mathcolor="#EE0000" mathvariant="bold">B</m:mi></m:maction></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2" style="width:100%"><m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:maction actiontype="link" dsi:href="#MAXCAL" dsi:type="simple"><m:mi mathcolor="#EE0000" mathvariant="bold">MAXCAL</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>3</m:mn></m:math>,</td></tr></table>
</dd><dt class="errorhead"><a name="IFeq2" id="IFeq2"/><m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:maction actiontype="link" dsi:href="#IFAIL" dsi:type="simple"><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="argref" href="#FUNCT">FUNCT</a> has exceeded <a class="argref" href="#MAXCAL">MAXCAL</a>.  This may have happened simply because <a class="argref" href="#MAXCAL">MAXCAL</a> was set too small for a particular problem, or may be due to a mistake in the user-supplied (sub)program <a class="argref" href="#FUNCT">FUNCT</a>.  If no mistake can be found in <a class="argref" href="#FUNCT">FUNCT</a>, restart E04ABF/E04ABA (preferably with values of <a class="argref" href="#A">A</a> and <a class="argref" href="#B">B</a> given on exit from the previous call of E04ABF/E04ABA).</div>
</dd></dl><h2><a name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2><div class="paramtext">If <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;is <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>&#948;</m:mi></m:math>-unimodal for some <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><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:href="#E1" dsi:type="simple"><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:href="#E2" dsi:type="simple"><m:mi mathcolor="#EE0000" mathvariant="bold">E2</m:mi></m:maction></m:math>, then, on exit,  <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>x</m:mi></m:math>&#160;approximates the minimum of <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;in the original interval <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><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><a name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2><div class="paramtext">Timing depends on the behaviour of <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;can be evaluated very quickly, the run time will usually be dominated by the time spent in <a class="argref" href="#FUNCT">FUNCT</a>.</div>
<div class="paramtext">If <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mfenced separators="" open="[" close="]"><m:mi>a</m:mi><m:mo>,</m:mo><m:mi>b</m:mi></m:mfenced></m:math>, E04ABF/E04ABA will determine an approximation  <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>x</m:mi></m:math>&#160;(and improved bounds <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>a</m:mi></m:math>&#160;and <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>b</m:mi></m:math>)  for one of the minima.</div>
<div class="paramtext">If E04ABF/E04ABA finds an <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>x</m:mi></m:math>&#160;such that <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;is less than  <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 xmlns:m="http://www.w3.org/1998/Math/MathML"><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 user-supplied (sub)program.  Therefore  <a class="argref" href="#FUNCT">FUNCT</a> should be programmed to calculate <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;as accurately as possible, so that E04ABF/E04ABA will not be liable to find a spurious minimum.</div><h2><a name="example" id="example"/>9&#160;&#160;Example</h2><div class="paramtext">A sketch of the function
</div>
<div class="formula"><table class="formula"><tr><td class="formula"><m:math xmlns:m="http://www.w3.org/1998/Math/MathML" 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>
<div class="paramtext">
shows that it has a minimum somewhere in the range <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><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 E04ABF/E04ABA can be used to obtain a good approximation to the position of a minimum.</div><h3><a name="examtext" id="examtext"/>9.1&#160;&#160;Program Text</h3>
    <div class="paramtext"><b>Note:</b> <span class="italic">the following program illustrates the use of E04ABF.  An equivalent program illustrating the use of E04ABA is available with the supplied Library and is also available from the NAG web site</span>.</div>
<p><a href="../../examples/source/e04abfe.f">Program Text (e04abfe.f)</a></p><h3><a name="examdata" id="examdata"/>9.2&#160;&#160;Program Data</h3><div class="paramtext">None.</div><h3><a name="examresults" id="examresults"/>9.3&#160;&#160;Program Results</h3><p><a href="../../examples/baseresults/e04abfe.r">Program Results (e04abfe.r)</a></p><hr/><div><a href="../../pdf/E04/e04abf.pdf">E04ABF (pdf version)</a></div><div><a href="e04_conts.xml">Chapter Contents</a></div><div><a href="e04_intro.xml">Chapter Introduction</a></div>
<div><a href="../mark21.xml">NAG Library Manual</a></div>
<div><hr/>
  &#169; The Numerical Algorithms Group Ltd, Oxford, UK. 2006
  </div></body></html>