<?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>E04CCF/E04CCA : 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/e04ccf.pdf">E04CCF/E04CCA (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/>E04CCF/E04CCA</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 E04CCF</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 E04CCA</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">E04CCF/E04CCA minimizes a general function <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;of <m:math><m:mi>n</m:mi></m:math>&#160;independent variables <m:math>
 <m:mi>x</m:mi>
 <m:mo>=</m:mo>
 <m:msup><m:mfenced separators=""><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>x</m:mi><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:msub><m:mi>x</m:mi><m:mi>n</m:mi></m:msub></m:mfenced><m:mi mathvariant="normal">T</m:mi></m:msup>
</m:math>&#160;by the Simplex method.  Derivatives of the function need not be supplied.</div>
<div class="paramtext">E04CCA is a version of E04CCF 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 E04CCF</h3>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;E04CCF&#160;(</td><td class="tdfspec2"><a class="arg" href="#N">N</a>, <a class="arg" href="#X">X</a>, <a class="arg" href="#F">F</a>, <a class="arg" href="#TOL">TOL</a>, <a class="arg" href="#IW">IW</a>, <a class="arg" href="#W1">W1</a>, <a class="arg" href="#W2">W2</a>, <a class="arg" href="#W3">W3</a>, <a class="arg" href="#W4">W4</a>, <a class="arg" href="#W5">W5</a>, <a class="arg" href="#W6">W6</a>, <a class="arg" href="#FUNCT">FUNCT</a>, <a class="arg" href="#MONIT">MONIT</a>, <a class="arg" href="#MAXCAL">MAXCAL</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N, IW, MAXCAL, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X(N), F, TOL, W1(N), W2(N), W3(N), W4(N), W5(IW), W6(IW,N)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">FUNCT, MONIT</td></tr></table><h3 class="standard"><a class="sec" name="routAspec" id="routAspec"/>2.2&#160;&#160;Specification for E04CCA</h3>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;E04CCA&#160;(</td><td class="tdfspec2"><a class="arg" href="#N">N</a>, <a class="arg" href="#X">X</a>, <a class="arg" href="#F">F</a>, <a class="arg" href="#TOL">TOL</a>, <a class="arg" href="#IW">IW</a>, <a class="arg" href="#W1">W1</a>, <a class="arg" href="#W2">W2</a>, <a class="arg" href="#W3">W3</a>, <a class="arg" href="#W4">W4</a>, <a class="arg" href="#W5">W5</a>, <a class="arg" href="#W6">W6</a>, <a class="arg" href="#FUNCT">FUNCT</a>, <a class="arg" href="#MONIT">MONIT</a>, <a class="arg" href="#MAXCAL">MAXCAL</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">N, IW, MAXCAL, IUSER(*), IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">X(N), F, TOL, W1(N), W2(N), W3(N), W4(N), W5(IW), W6(IW,N), RUSER(*)</td></tr><tr><td class="tdfspec1">EXTERNAL</td><td class="tdfspec2">FUNCT, MONIT</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">E04CCF/E04CCA finds an approximation to a minimum of a function of  <m:math><m:mi>n</m:mi></m:math>&#160;variables.  You must supply a subroutine to calculate the value of the function for any set of values of the variables.</div><div class="paramtext">The method is iterative.  A simplex of <m:math><m:mi>n</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:math>&#160;points is set up in the <m:math><m:mi>n</m:mi></m:math>-dimensional space of the variables (for example in <m:math><m:mn>2</m:mn></m:math>&#160;dimensions the simplex is a triangle) under the assumption that the problem has been scaled so that the values of the independent variables at the minimum are of order unity.  The starting point you have provided is the first vertex of the simplex, the remaining <m:math><m:mi>n</m:mi></m:math>&#160;vertices are generated by the routine.  The vertex of the simplex with the largest function value is reflected in the centre of gravity of the remaining vertices and the function value at this new point is compared with the remaining function values.  Depending on the outcome of this test the new point is accepted or rejected, a further expansion move may be made, or a contraction may be carried out.  See <a class="ref" href="#ref339">Nelder and Mead (1965)</a> and <a class="ref" href="#ref340">Parkinson and Hutchinson (1972)</a> for more details.  When no further progress can be made the sides of the simplex are reduced in length and the method is repeated.</div><div class="paramtext">The method tends to be slow, but it is robust and therefore very useful for functions that are subject to inaccuracies.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref339" id="ref339"/>Nelder J A and Mead R (1965)  A simplex method for function minimization <i>Comput. J.</i> <b>7</b> 308&#8211;313 </div>
<div class="paramtext"><a name="ref340" id="ref340"/>Parkinson J M and Hutchinson D (1972)  An investigation into the efficiency of variants of the simplex method <i>Numerical Methods for Nonlinear Optimization</i> (ed F A Lootsma) Academic Press </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="N" id="N"/>1: &#160;&#160;&#8194; N &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: 


the number <m:math><m:mi>n</m:mi></m:math>&#160;of independent variables.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>&gt;</m:mo><m:mn>0</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="X" id="X"/>2: &#160;&#160;&#8194; X(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input/Output</span></dt><dd><div class="paramtext"><i>On entry</i>: a guess at the position of the minimum.  Note that the problem should be scaled so that the values of the <m:math><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#X"><m:mi mathcolor="#EE0000" mathvariant="bold">X</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow></m:math>&#160;are of order unity.</div>
<div class="paramtext"><i>On exit</i>: the value of <m:math><m:mi>x</m:mi></m:math>&#160;corresponding to the function value in <a class="arg" href="#F">F</a>.</div></dd><dt class="paramhead"><a name="F" id="F"/>3: &#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 lowest function value found.</div></dd><dt class="paramhead"><a name="TOL" id="TOL"/>4: &#160;&#160;&#8194; TOL &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the error tolerable in the result. If <m:math><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:math>, for <m:math><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:math>, are the individual function values at the vertices of a simplex and <m:math><m:msub><m:mi>f</m:mi><m:mi>m</m:mi></m:msub></m:math>&#160;is the mean of these values, then the routine will terminate when 
<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block"> <m:msqrt><m:mfrac><m:mn>1</m:mn><m:mrow><m:mi>n</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow>
 </m:mfrac><m:munderover><m:mo>&#8721;</m:mo><m:mrow><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:mrow>
  <m:mrow><m:mi>n</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:munderover><m:msup> <m:mfenced separators=""><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub><m:mo>-</m:mo><m:msub><m:mi>f</m:mi><m:mi>m</m:mi></m:msub></m:mfenced> <m:mn>2</m:mn></m:msup></m:msqrt><m:mo>&lt;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mtext>.</m:mtext> </m:math></td><td class="formula2"/></tr></table></div></div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction></m:math>&#160;must be greater than or equal to the <span class="bitalic">machine precision</span> (see <a class="chap" href="../X02/x02conts.xml">Chapter X02</a>)</div></dd><dt class="paramhead"><a name="IW" id="IW"/>5: &#160;&#160;&#8194; IW &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: 


the value <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>+</m:mo><m:mn>1</m:mn></m:math>.</div><div class="paramtext"><i>Constraint</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IW"><m:mi mathcolor="#EE0000" mathvariant="bold">IW</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>+</m:mo><m:mn>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="W1" id="W1"/>6: &#160;&#160;&#8194; W1(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="multi-paramhead"><a name="W2" id="W2"/>7: &#160;&#160;&#8194; W2(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="multi-paramhead"><a name="W3" id="W3"/>8: &#160;&#160;&#8194; W3(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="multi-paramhead"><a name="W4" id="W4"/>9: &#160;&#160;&#8194; W4(<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="multi-paramhead"><a name="W5" id="W5"/>10: &#8194; W5(<a class="arg" href="#IW">IW</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="multi-paramhead"><a name="W6" id="W6"/>11: &#8194; W6(<a class="arg" href="#IW">IW</a>,<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="paramhead"><a name="FUNCT" id="FUNCT"/>12: &#8194; FUNCT &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd><div class="paramtext"><a class="arg" href="#FUNCT">FUNCT</a> must evaluate function <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></m:math>&#160;at a specified point.  It should be tested separately before being used in conjunction with E04CCF/E04CCA.</div><div class="subprog">
<div class="paramtext">The specification of 
   <a class="arg" href="#FUNCT">FUNCT</a>
   for E04CCF is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;FUNCT&#160;(</td><td class="tdfspec2"><a class="arg" href="../E04/e04ccf.xml#FUNCT_N">N</a>, <a class="arg" href="../E04/e04ccf.xml#FUNCT_XC">XC</a>, <a class="arg" href="../E04/e04ccf.xml#FUNCT_FC">FC</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">XC(N), FC</td></tr></table>
<div class="paramtext">The specification of 
   <a class="arg" href="#FUNCT">FUNCT</a>
   for E04CCA is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;FUNCT&#160;(</td><td class="tdfspec2"><a class="arg" href="../E04/e04ccf.xml#FUNCT_N">N</a>, <a class="arg" href="../E04/e04ccf.xml#FUNCT_XC">XC</a>, <a class="arg" href="../E04/e04ccf.xml#FUNCT_FC">FC</a>, <a class="arg" href="../E04/e04ccf.xml#FUNCT_IUSER">IUSER</a>, <a class="arg" href="../E04/e04ccf.xml#FUNCT_RUSER">RUSER</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N, IUSER(*)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">XC(N), FC, RUSER(*)</td></tr></table>
<dl><dt class="paramhead"><a name="FUNCT_N" id="FUNCT_N"/>1: &#160;&#160;&#8194; N &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the number <m:math><m:mi>n</m:mi></m:math>&#160;of variables.</div></dd><dt class="paramhead"><a name="FUNCT_XC" id="FUNCT_XC"/>2: &#160;&#160;&#8194; XC(<a class="arg" href="../E04/e04ccf.xml#FUNCT_N">N</a>) &#8211; <span class="bitalic">double precision</span> array<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 function is required.</div></dd><dt class="paramhead"><a name="FUNCT_FC" id="FUNCT_FC"/>3: &#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>: the value of the function <m:math><m:mi>F</m:mi><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced></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 E04CCA.  Users of E04CCF 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 E04CCA with the parameters <a class="arg" href="../E04/e04ccf.xml#FUNCT_IUSER">IUSER</a> and <a class="arg" href="../E04/e04ccf.xml#FUNCT_RUSER">RUSER</a> as supplied to E04CCA.  You are free to use the arrays <a class="arg" href="../E04/e04ccf.xml#FUNCT_IUSER">IUSER</a> and <a class="arg" href="../E04/e04ccf.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 E04CCF/E04CCA 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="MONIT" id="MONIT"/>13: &#8194; MONIT &#8211; SUBROUTINE, supplied by the user.<span class="pclass">External Procedure</span></dt><dd><div class="paramtext"><a class="arg" href="#MONIT">MONIT</a> is called once every iteration in E04CCF/E04CCA.  It can be used to print out the current values of any selection of its parameters but must not be used to change the values of the parameters.</div><div class="subprog">
<div class="paramtext">The specification of 
   <a class="arg" href="#MONIT">MONIT</a>
   for E04CCF is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;MONIT&#160;(</td><td class="tdfspec2"><a class="arg" href="../E04/e04ccf.xml#MONIT_FMIN">FMIN</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_FMAX">FMAX</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_SIM">SIM</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_N">N</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_NVERT">NVERT</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_NCALL">NCALL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N, NVERT, NCALL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">FMIN, FMAX, SIM(NVERT,N)</td></tr></table>
<div class="paramtext">The specification of 
   <a class="arg" href="#MONIT">MONIT</a>
   for E04CCA is:</div><table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;MONIT&#160;(</td><td class="tdfspec2"><a class="arg" href="../E04/e04ccf.xml#MONIT_FMIN">FMIN</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_FMAX">FMAX</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_SIM">SIM</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_N">N</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_NVERT">NVERT</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_NCALL">NCALL</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_IUSER">IUSER</a>, <a class="arg" href="../E04/e04ccf.xml#MONIT_RUSER">RUSER</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N, NVERT, NCALL, IUSER(*)</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">FMIN, FMAX, SIM(NVERT,N), RUSER(*)</td></tr></table>
<dl><dt class="paramhead"><a name="MONIT_FMIN" id="MONIT_FMIN"/>1: &#160;&#160;&#8194; FMIN &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the smallest function value in the current simplex.</div></dd><dt class="paramhead"><a name="MONIT_FMAX" id="MONIT_FMAX"/>2: &#160;&#160;&#8194; FMAX &#8211; <span class="bitalic">double precision</span><span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the largest function value in the current simplex.</div></dd><dt class="paramhead"><a name="MONIT_SIM" id="MONIT_SIM"/>3: &#160;&#160;&#8194; SIM(<a class="arg" href="../E04/e04ccf.xml#MONIT_NVERT">NVERT</a>,<a class="arg" href="../E04/e04ccf.xml#MONIT_N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the <m:math><m:mi>n</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:math>&#160;position vectors of the current simplex..</div></dd><dt class="paramhead"><a name="MONIT_N" id="MONIT_N"/>4: &#160;&#160;&#8194; N &#8211; INTEGER<span class="pclass">Input</span></dt><dd>
<div class="paramtext"><i>On entry</i>: the number of variables.</div></dd><dt class="paramhead"><a name="MONIT_NVERT" id="MONIT_NVERT"/>5: &#160;&#160;&#8194; NVERT &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the number of vertices in the current simplex.</div></dd><dt class="paramhead"><a name="MONIT_NCALL" id="MONIT_NCALL"/>6: &#160;&#160;&#8194; NCALL &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the number of times that <a class="arg" href="#FUNCT">FUNCT</a> has been called so far.</div></dd><dd class="note"><b>Note:</b> <span class="italic"> the following are additional parameters for specific use with E04CCA.  Users of E04CCF therefore need not read the remainder of this description</span>.</dd><dt class="paramhead"><a name="MONIT_IUSER" id="MONIT_IUSER"/>7: &#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="MONIT_RUSER" id="MONIT_RUSER"/>8: &#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="#MONIT">MONIT</a> is called from E04CCA with the parameters <a class="arg" href="../E04/e04ccf.xml#MONIT_IUSER">IUSER</a> and <a class="arg" href="../E04/e04ccf.xml#MONIT_RUSER">RUSER</a> as supplied to E04CCA.  You are free to use the arrays <a class="arg" href="../E04/e04ccf.xml#MONIT_IUSER">IUSER</a> and <a class="arg" href="../E04/e04ccf.xml#MONIT_RUSER">RUSER</a> to supply information to <a class="arg" href="#MONIT">MONIT</a>.</div></dd></dl>
</div>
<div class="paramtext"><a class="arg" href="#MONIT">MONIT</a> must be declared as EXTERNAL in the (sub)program from which E04CCF/E04CCA 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="MAXCAL" id="MAXCAL"/>14: &#8194; MAXCAL &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: the maximum number of function evaluations 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>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>15: &#8194; IFAIL &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><b>Note:</b> <span class="italic">for E04CCA, <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, if you are not familiar with this parameter, the recommended value is <m:math><m:mn>0</m:mn></m:math>.  <b>When the value <m:math><m:mrow><m:mo>-</m:mo><m:mn mathvariant="bold">1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn mathvariant="bold">1</m:mn></m:math>&#160;is used it is essential to test the value of <a class="arg" href="#IFAIL">IFAIL</a> on exit.</b></div></div></dd><dd class="note"><b>Note:</b> <span class="italic"> the following are additional parameters for specific use with E04CCA.  Users of E04CCF therefore need not read the remainder of this description</span>.</dd><dt class="paramhead"><a name="IUSER" id="IUSER"/>15: &#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 E04CCA, but is passed directly to <a class="arg" href="#FUNCT">FUNCT</a> and <a class="arg" href="#MONIT">MONIT</a> and may be used to pass information to those routines.</div></dd><dt class="paramhead"><a name="RUSER" id="RUSER"/>16: &#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 E04CCA, but is passed directly to <a class="arg" href="#FUNCT">FUNCT</a> and <a class="arg" href="#MONIT">MONIT</a> and may be used to pass information to those routines.</div></dd><dt class="paramhead"><a name="IFAIL2" id="IFAIL2"/>17: &#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">Errors or warnings detected by the routine:</div>
<dl class="ifail">
<dt class="errorhead"><a name="IFeq1" id="IFeq1"/><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:mn>1</m:mn></m:math></dt>
<dd>
<table class="ifail"><tr><td class="ifail1">On&#160;entry,</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>1</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#TOL"><m:mi mathcolor="#EE0000" mathvariant="bold">TOL</m:mi></m:maction><m:mo>&lt;</m:mo><m:mi mathvariant="bold-italic">machine&#160;precision</m:mi></m:math>&#160;(see <a class="chap" href="../X02/x02conts.xml">Chapter X02</a>),</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IW"><m:mi mathcolor="#EE0000" mathvariant="bold">IW</m:mi></m:maction><m:mo>&#8800;</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#N"><m:mi mathcolor="#EE0000" mathvariant="bold">N</m:mi></m:maction><m:mo>+</m:mo><m:mn>1</m:mn></m:math>,</td></tr><tr><td class="ifail1">or</td><td class="ifail2-90"><m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#MAXCAL"><m:mi mathcolor="#EE0000" mathvariant="bold">MAXCAL</m:mi></m:maction><m:mo>&lt;</m:mo><m:mn>1</m:mn></m:math>.</td></tr></table>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="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"><a class="arg" href="#MAXCAL">MAXCAL</a> function evaluations have been completed, E04CCF/E04CCA has been terminated prematurely.  Check the coding of <a class="arg" href="#FUNCT">FUNCT</a> before increasing the value of <a class="arg" href="#MAXCAL">MAXCAL</a>.</div>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">On a successful exit the accuracy will be as defined by <a class="arg" href="#TOL">TOL</a>.</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">The time taken by E04CCF/E04CCA depends on the number of variables, the behaviour of the function and the distance of the starting point from the minimum.  Each iteration consists of <m:math><m:mn>1</m:mn></m:math>&#160;or <m:math><m:mn>2</m:mn></m:math>&#160;function evaluations unless the size of the simplex is reduced, in which case <m:math><m:mi>n</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:math>&#160;function evaluations are required.</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">This example finds a minimum of the function

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
<m:mi>F</m:mi><m:mo>=</m:mo><m:msup><m:mi>e</m:mi><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub></m:msup><m:mfenced separators=""><m:mn>4</m:mn><m:msubsup><m:mi>x</m:mi><m:mn>1</m:mn><m:mn>2</m:mn></m:msubsup><m:mo>+</m:mo><m:mn>2</m:mn><m:msubsup><m:mi>x</m:mi><m:mn>2</m:mn><m:mn>2</m:mn></m:msubsup><m:mo>+</m:mo><m:mn>4</m:mn><m:msub><m:mi>x</m:mi><m:mn>1</m:mn></m:msub><m:msub><m:mi>x</m:mi><m:mn>2</m:mn></m:msub><m:mo>+</m:mo><m:mn>2</m:mn><m:msub><m:mi>x</m:mi><m:mn>2</m:mn></m:msub><m:mo>+</m:mo><m:mn>1</m:mn></m:mfenced><m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div></div><h3 class="standard"><a class="sec" name="examtext" id="examtext"/>9.1&#160;&#160;Program Text</h3>
<div class="paramtext"><b>Note:</b> <span class="italic">the following programs illustrate the use of E04CCF and E04CCA</span>.</div><p><a class="verbatimref" href="../../examples/source/e04ccfe.f">Program Text (e04ccfe.f)</a></p><p><a class="verbatimref" href="../../examples/source/e04ccae.f">Program Text (e04ccae.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/e04ccfe.r">Program Results (e04ccfe.r)</a></p><p><a class="verbatimref" href="../../examples/baseresults/e04ccae.r">Program Results (e04ccae.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/E04/e04ccf.pdf">E04CCF/E04CCA (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>
