<?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 C Library Manual, Mark 8 : 
   c05 Chapter Introduction</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/C05/c05_intro.pdf">c05 Chapter Introduction (pdf version)</a></div><div><a href="c05_conts.xml">Chapter Contents</a></div>
<div><a href="../mark8.xml">NAG C Library Manual</a></div><hr/><h1 class="libdoc">NAG C Library  Chapter Introduction<br/><br/>c05 &#8212; Roots of One or More Transcendental Equations</h1>
<div class="toc"><h3>Contents</h3>
<h2 class="toc"><a class="rtnref" href="#scope">1&#160;&#160;Scope of the Chapter</a></h2>
<h2 class="toc"><a class="rtnref" href="#background">2&#160;&#160;Background to the Problems</a></h2>
<h3 class="toc"><a class="rtnref" href="#intbackground1">2.1&#160;&#160;A Single Equation</a></h3>
<h3 class="toc"><a class="rtnref" href="#intbackground2">2.2&#160;&#160;Systems of Equations</a></h3>
<h2 class="toc"><a class="rtnref" href="#available">3&#160;&#160;Recommendations on Choice and Use of Available Functions</a></h2>
<h3 class="toc"><a class="rtnref" href="#intrecomm_1">3.1&#160;&#160;Zeros of Functions of One Variable</a></h3>
<h3 class="toc"><a class="rtnref" href="#intrecomm_2">3.2&#160;&#160;Solution of Sets of Nonlinear Equations</a></h3>
<h2 class="toc"><a class="rtnref" href="#dtree">4&#160;&#160;Decision Trees</a></h2>
<h2 class="toc"><a class="rtnref" href="#index">5&#160;&#160;Index</a></h2>
<h2 class="toc"><a class="rtnref" href="#withdrawn">6&#160;&#160;Functions Withdrawn or Scheduled for Withdrawal</a></h2>
<h2 class="toc"><a class="rtnref" href="#references">7&#160;&#160;References</a></h2></div><h2><a name="scope" id="scope"/>1&#160;&#160;Scope of the Chapter</h2><div class="paramtext">This chapter is concerned with the calculation of real zeros of continuous real functions of one or more variables.  (Complex equations must be expressed in terms of the equivalent larger system of real equations.)</div><h2><a name="background" id="background"/>2&#160;&#160;Background to the Problems</h2><div class="paramtext">The chapter divides naturally into two parts.</div><h3><a name="intbackground1" id="intbackground1"/>2.1&#160;&#160;A Single Equation</h3><div class="paramtext">The first deals with the real zeros of a real function of a single variable <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>.</div>
<div class="paramtext">There is one function with simple calling sequences. It first assumes that you can determine an initial 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;within which the desired zero lies, that is <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>f</m:mi><m:mfenced separators=""><m:mi>a</m:mi></m:mfenced><m:mo>&#215;</m:mo><m:mi>f</m:mi><m:mfenced separators=""><m:mi>b</m:mi></m:mfenced><m:mo>&lt;</m:mo><m:mn>0</m:mn></m:math>,  and outside which all other zeros lie.  The function then systematically subdivides the interval to produce a final interval containing the zero.  This final interval has a length bounded by your specified error requirements; the end of the interval where the function has smallest magnitude is returned as the zero.  This function is guaranteed to converge to a <b>simple</b> zero of the function.  (Here we define a simple zero as a zero corresponding to a sign-change of the function; none of the available functions are capable of making any finer distinction.)  However, a non-simple zero might be determined and it is left to you to check for this.  The algorithm used is due to Bus and  Dekker.</div><h3><a name="intbackground2" id="intbackground2"/>2.2&#160;&#160;Systems of Equations</h3><div class="paramtext">The functions in the second part of this chapter are designed to solve a set of nonlinear equations in <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>n</m:mi></m:math>&#160;unknowns
</div>
<div class="formula-eqn"><a name="eqn1" id="eqn1"/><table class="formula-eqn"><tr><td class="formula-eqn"><m:math xmlns:m="http://www.w3.org/1998/Math/MathML" display="block">
 <m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced>
 <m:mo>=</m:mo>
 <m:mn>0</m:mn>
 <m:mtext>, &#8195;</m:mtext>
 <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:mtext>, &#8195;</m:mtext>
 <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:mtext>,</m:mtext>
</m:math></td><td class="formula-eqn2">
      (1)
     </td></tr></table></div>
<div class="paramtext">
where <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>T</m:mi></m:math>&#160;stands for transpose.</div>
<div class="paramtext">It is assumed that the functions are continuous and differentiable so that the matrix of first partial derivatives of the functions, the  <b>Jacobian</b> matrix  <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:msub><m:mi>J</m:mi>
<m:mrow><m:mi>i</m:mi><m:mi>j</m:mi></m:mrow>
</m:msub><m:mfenced separators=""><m:mi>x</m:mi></m:mfenced><m:mo>=</m:mo><m:mfenced separators=""><m:mfrac other="display">
 <m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:mrow>
<m:mrow><m:mo>&#8706;</m:mo><m:msub><m:mi>x</m:mi><m:mi>j</m:mi></m:msub></m:mrow>
</m:mfrac></m:mfenced></m:math>&#160; evaluated at the point <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>x</m:mi></m:math>, exists, though it may not be possible to calculate it directly.</div>
<div class="paramtext">The functions <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;must be independent, otherwise there will be an infinity of solutions and the methods will fail.  However, even when the functions are independent the solutions may not be unique.  Since the methods are iterative, an initial guess at the solution has to be supplied, and the solution located will usually be the one closest to this initial guess.</div><h2><a name="available" id="available"/>3&#160;&#160;Recommendations on Choice and Use of Available Functions</h2><h3><a name="intrecomm_1" id="intrecomm_1"/>3.1&#160;&#160;Zeros of Functions of One Variable</h3><div class="paramtext">If you can supply an 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;containing the zero, that is <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>f</m:mi><m:mfenced separators=""><m:mi>a</m:mi></m:mfenced><m:mo>&#215;</m:mo><m:mi>f</m:mi><m:mfenced separators=""><m:mi>b</m:mi></m:mfenced><m:mo>&lt;</m:mo><m:mn>0</m:mn></m:math>, then  <a class="rtnref" href="../C05/c05adc.xml">nag_zero_cont_func_bd (c05adc)</a> can be used.</div><h3><a name="intrecomm_2" id="intrecomm_2"/>3.2&#160;&#160;Solution of Sets of Nonlinear Equations</h3><div class="paramtext">The solution of a set of nonlinear equations
</div>
<div class="formula-eqn"><a name="eqn2" id="eqn2"/><table class="formula-eqn"><tr><td class="formula-eqn"><m:math xmlns:m="http://www.w3.org/1998/Math/MathML" display="block">
<m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub><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:mo>=</m:mo><m:mn>0</m:mn><m:mtext>, &#8195;</m:mtext><m:mi>i</m:mi><m:mo>=</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mn>2</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi>
</m:math></td><td class="formula-eqn2">
      (2)
     </td></tr></table></div>
<div class="paramtext">
can be regarded as a special case of the problem of finding a minimum of a sum of squares
</div>
<div class="formula-eqn"><a name="eqn3" id="eqn3"/><table class="formula-eqn"><tr><td class="formula-eqn"><m:math xmlns:m="http://www.w3.org/1998/Math/MathML" display="block">
 <m:mi>s</m:mi>
 <m:mfenced separators="">
  <m:mi>x</m:mi>
 </m:mfenced>
 <m:mo>=</m:mo>
 <m:munderover>
  <m:mo>&#8721;</m:mo>
  <m:mrow>
   <m:mi>i</m:mi>
   <m:mo>=</m:mo>
   <m:mn>1</m:mn>
  </m:mrow>
  <m:mi>m</m:mi>
 </m:munderover>
 <m:msup>
  <m:mfenced open="[" close="]" separators="">
   <m:msub>
    <m:mi>f</m:mi>
    <m:mi>i</m:mi>
   </m:msub>
   <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:mfenced>
<m:mn>2</m:mn>
 </m:msup>
 <m:mtext>, &#8195;</m:mtext>
 <m:mfenced separators="">
  <m:mi>m</m:mi>
  <m:mo>&#8805;</m:mo>
  <m:mi>n</m:mi>
 </m:mfenced>
 <m:mtext>.</m:mtext>
</m:math></td><td class="formula-eqn2">
      (3)
     </td></tr></table></div>
<div class="paramtext">
So the functions in Chapter <a class="secref" href="../E04/e04_conts.xml">e04</a> are relevant as well as the special nonlinear equations functions.</div><div class="paramtext"><a class="rtnref" href="../C05/c05ubc.xml">nag_zero_nonlin_eqns_deriv_1 (c05ubc)</a> requires you to provide the derivatives, whilst <a class="rtnref" href="../C05/c05tbc.xml">nag_zero_nonlin_eqns_1 (c05tbc)</a> does not.</div><div class="paramtext">Firstly, the calculation of the functions and their derivatives should be ordered so that <b>cancellation errors</b> are avoided.  This is particularly important in a function that uses these quantities to build up estimates of higher derivatives.</div>
<div class="paramtext">Secondly, <b>scaling</b> of the variables has a considerable effect on the efficiency of a function.  The problem should be designed so that the elements of <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:mi>x</m:mi></m:math>&#160;are of similar magnitude.  The same comment applies to the functions, i.e., all the <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:msub><m:mi>f</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;should be of comparable size.</div>
<div class="paramtext">The accuracy is usually determined by the accuracy  arguments of the functions, but the following points may be useful
</div><ol class="listroman"><li class="listroman">Greater accuracy in the solution may be requested by choosing smaller input values for the accuracy arguments. However, if unreasonable accuracy is demanded, rounding errors may become important and cause a failure.</li><li class="listroman">Some idea of the accuracies of the <m:math xmlns:m="http://www.w3.org/1998/Math/MathML"><m:msub><m:mi>x</m:mi><m:mi>i</m:mi></m:msub></m:math>&#160;may be obtained by monitoring the progress of the function to see how many figures remain unchanged during the last few iterations.</li></ol><div class="paramtext">
</div><h2><a name="dtree" id="dtree"/>4&#160;&#160;Decision Trees</h2><h4><a name="tree1" id="tree1"/>Tree 1: Functions of One Variable
</h4>
<table class="dtree">
<tr>
<td class="dtentry">Is there available an 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;containing a simple zero, and no others?</td>
<td class="dtnobar">_<br/>yes</td>
<td class="dtentry"><a class="rtnref" href="../C05/c05sdc.xml">c05sdc</a></td></tr>
<tr>
<td class="dtnobar">no<br/>|</td>
<td/></tr>
<tr>
<td class="dtentry">None</td></tr></table><h4><a name="tree2" id="tree2"/>Tree 2: Functions of several variables
</h4>
<table class="dtree">
<tr>
<td class="dtentry">Is the Jacobian matrix available?</td>
<td class="dtnobar">_<br/>yes</td>
<td class="dtentry"><a class="rtnref" href="../C05/c05ubc.xml">c05ubc</a> and <a class="rtnref" href="../C05/c05zcc.xml">c05zcc</a></td></tr>
<tr>
<td class="dtnobar">no<br/>|</td>
<td/></tr>
<tr>
<td class="dtentry"><a class="rtnref" href="../C05/c05tbc.xml">c05tbc</a></td></tr></table><h2><a name="index" id="index"/>5&#160;&#160;Index</h2><table>
   <tr><td class="index1">Derivatrive checker,</td><td class="index2">
  &#160;&#160;&#160;</td></tr>
   
      <tr><td class="index1">&#160;&#160;&#160;&#160;for <a class="rtnref" href="../C05/c05pbc.xml">nag_zero_nonlin_eqns_deriv (c05pbc)</a>
      </td><td class="index2">
  &#160;&#160;&#160;<a class="rtnref" href="../C05/c05zbc.xml">c05zbc</a></td></tr>
      <tr><td class="index1">&#160;&#160;&#160;&#160;for <a class="rtnref" href="../C05/c05ubc.xml">nag_zero_nonlin_eqns_deriv_1 (c05ubc)</a>
      </td><td class="index2">
  &#160;&#160;&#160;<a class="rtnref" href="../C05/c05zcc.xml">c05zcc</a></td></tr>
   
   <tr><td class="index1">Zeros of functions of one variable:</td><td class="index2">
  &#160;&#160;&#160;</td></tr>
   
      <tr><td class="index1">&#160;&#160;&#160;&#160;Direct communication:</td><td class="index2">
  &#160;&#160;&#160;</td></tr>
      
         <tr><td class="index1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Bus and Dekker algorithm</td><td class="index2">
  &#160;&#160;&#160;<a class="rtnref" href="../C05/c05adc.xml">c05adc</a></td></tr>
         <tr><td class="index1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;Bus and Dekker algorithm, thread-safe</td><td class="index2">
  &#160;&#160;&#160;<a class="rtnref" href="../C05/c05sdc.xml">c05sdc</a></td></tr>
      
   
   <tr><td class="index1">Zeros of functions of several variables:</td><td class="index2">
  &#160;&#160;&#160;</td></tr>
   
      <tr><td class="index1">&#160;&#160;&#160;&#160;Direct communication:</td><td class="index2">
  &#160;&#160;&#160;</td></tr>
      
         <tr><td class="index1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;easy-to-use,</td><td class="index2">
  &#160;&#160;&#160;</td></tr>
         
            <tr><td class="index1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;derivatives required</td><td class="index2">
  &#160;&#160;&#160;<a class="rtnref" href="../C05/c05pbc.xml">c05pbc</a></td></tr>
            <tr><td class="index1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;derivatives required, thread-safe</td><td class="index2">
  &#160;&#160;&#160;<a class="rtnref" href="../C05/c05ubc.xml">c05ubc</a></td></tr>
            <tr><td class="index1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;no derivatives required</td><td class="index2">
  &#160;&#160;&#160;<a class="rtnref" href="../C05/c05nbc.xml">c05nbc</a></td></tr>
            <tr><td class="index1">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;no derivatives required, thread-safe</td><td class="index2">
  &#160;&#160;&#160;<a class="rtnref" href="../C05/c05tbc.xml">c05tbc</a></td></tr>
         
      
   
</table><h2><a name="withdrawn" id="withdrawn"/>6&#160;&#160;Functions Withdrawn or Scheduled for Withdrawal</h2><div class="paramtext">None.</div><h2><a name="references" id="references"/>7&#160;&#160;References</h2><div class="paramtext">
<p><a name="ref195" id="ref195"/>Gill P E and Murray W (1976) Algorithms for the solution of the nonlinear least-squares problem <i>Report NAC 71</i> National Physical Laboratory </p>
<p><a name="ref004" id="ref004"/>Mor&#233; J J, Garbow B S and Hillstrom K E (1980) User guide for MINPACK-1 <i>Technical Report ANL-80-74</i> Argonne National Laboratory </p>
<p><a name="ref197" id="ref197"/>Ortega J M and Rheinboldt W C (1970) <i>Iterative Solution of Nonlinear Equations in Several Variables</i> Academic Press </p>
<p><a name="ref198" id="ref198"/>Rabinowitz P (1970) <i>Numerical Methods for Nonlinear Algebraic Equations</i> Gordon and Breach </p>
</div><hr/><div><a href="../../pdf/C05/c05_intro.pdf">c05 Chapter Introduction (pdf version)</a></div><div><a href="c05_conts.xml">Chapter Contents</a></div>
<div><a href="../mark8.xml">NAG C Library Manual</a></div>
<div><hr/>
  &#169; The Numerical Algorithms Group Ltd, Oxford, UK. 2005
  </div></body></html>
