<?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>C02AGF : 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/C02/c02agf.pdf">C02AGF (PDF version)</a></div><div><a class="chap" href="c02conts.xml">C02 Chapter Contents</a></div><div><a class="chapint" href="c02intro.xml">C02 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/>C02AGF</h1><div class="paramtext"><div class="header"><b>Note:</b>&#160; before using this routine, please read the Users' Note for your implementation to check the interpretation of <span class="bitalic">bold italicised</span> terms and other implementation-dependent details.</div></div> 
<div class="htmltoc">
<h2 class="htmltoc"><span class="htmltochead" onclick="showLevel('htmltoc');"><span class="htmltocplus" id="htmltocplus">+</span><span class="htmltocminus" id="htmltocminus">&#8722;</span></span>&#160;Contents</h2>
<div class="htmltocitem" id="htmltoc">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#purpose">1&#160;&#160;<b>Purpose</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#specification">2&#160;&#160;<b>Specification</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#description">3&#160;&#160;<b>Description</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#references">4&#160;&#160;<b>References</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#parameters">5&#160;&#160;<b>Parameters</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#errors">6&#160;&#160;<b>Error Indicators and Warnings</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#accuracy">7&#160;&#160;<b>Accuracy</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#fcomments">8&#160;&#160;<b>Further Comments</b></a>
</div><div class="htmltoc">
<span class="htmltoc" onclick="showLevel('tocexample');"><span class="htmltocplus" id="tocexampleplus">+</span><span class="htmltocminus" id="tocexampleminus">&#8722;</span></span>
<a class="htmltoc" href="#example">9&#160;&#160;<b>Example</b></a>
<div class="htmltocitem" id="tocexample">
<div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examtext">9.1&#160;&#160;<b>Program Text</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examdata">9.2&#160;&#160;<b>Program Data</b></a>
</div><div class="htmltoc">
<span class="htmltocplus">&#160;&#160;&#160;</span>
<a class="htmltoc" href="#examresults">9.3&#160;&#160;<b>Program Results</b></a>
</div>
</div>
</div>
</div>
</div><h2 class="standard"><a class="sec" name="purpose" id="purpose"/>1&#160;&#160;Purpose</h2>
<div class="paramtext">C02AGF finds all the roots of a real polynomial equation, using a variant of Laguerre's method.</div><h2 class="standard"><a class="sec" name="specification" id="specification"/>2&#160;&#160;Specification</h2>
<table class="fspec"><tr><td class="tdfspec1">SUBROUTINE&#160;C02AGF&#160;(</td><td class="tdfspec2"><a class="arg" href="#A">A</a>, <a class="arg" href="#N">N</a>, <a class="arg" href="#SCAL">SCAL</a>, <a class="arg" href="#Z">Z</a>, <a class="arg" href="#W">W</a>, <a class="arg" href="#IFAIL">IFAIL</a>)</td></tr><tr><td class="tdfspec1">INTEGER</td><td class="tdfspec2">N, IFAIL</td></tr><tr><td class="tdfspec1"><b><i>double&#160;precision</i></b></td><td class="tdfspec2">A(N+1), Z(2,N), W(2*(N+1))</td></tr><tr><td class="tdfspec1">LOGICAL</td><td class="tdfspec2">SCAL</td></tr></table><h2 class="standard"><a class="sec" name="description" id="description"/>3&#160;&#160;Description</h2>
<div class="paramtext">C02AGF attempts to find all the roots of the <m:math><m:mi>n</m:mi></m:math>th degree real polynomial equation

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mi>P</m:mi><m:mfenced separators=""><m:mi>z</m:mi></m:mfenced>
 <m:mo>=</m:mo>
 <m:msub><m:mi>a</m:mi><m:mn>0</m:mn></m:msub>
 <m:msup><m:mi>z</m:mi><m:mi>n</m:mi></m:msup>
 <m:mo>+</m:mo>
 <m:msub><m:mi>a</m:mi><m:mn>1</m:mn></m:msub>
 <m:msup><m:mi>z</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msup>
 <m:mo>+</m:mo>
 <m:msub><m:mi>a</m:mi><m:mn>2</m:mn></m:msub>
 <m:msup><m:mi>z</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>2</m:mn></m:mrow></m:msup>
 <m:mo>+</m:mo>
 <m:mo>&#8943;</m:mo>
 <m:mo>+</m:mo>
 <m:msub><m:mi>a</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msub>
 <m:mi>z</m:mi>
 <m:mo>+</m:mo>
 <m:msub><m:mi>a</m:mi><m:mi>n</m:mi></m:msub>
 <m:mo>=</m:mo>
 <m:mn>0</m:mn>
 <m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

The roots are located using a modified form of Laguerre's method, originally proposed by <a class="ref" href="#ref002">Smith (1967)</a>.</div><div class="paramtext">The method of Laguerre (see <a class="ref" href="#ref003">Wilkinson (1965)</a>) can be described by the iterative scheme

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mi>L</m:mi><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced>
 <m:mo>=</m:mo>
 <m:msub><m:mi>z</m:mi><m:mrow><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub>
 <m:mo>-</m:mo>
 <m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub>
 <m:mo>=</m:mo>
 <m:mfrac>
  <m:mrow>
   <m:mrow><m:mo>-</m:mo><m:mi>n</m:mi></m:mrow>
   <m:mi>P</m:mi>
   <m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced>
  </m:mrow>
  <m:mrow>
   <m:msup><m:mi>P</m:mi><m:mo>&#8242;</m:mo></m:msup>
   <m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced>
   <m:mo>&#177;</m:mo>
   <m:msqrt><m:mi>H</m:mi><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced></m:msqrt>
  </m:mrow>
 </m:mfrac>
 <m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div>

where <m:math><m:mi>H</m:mi><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced><m:mo>=</m:mo><m:mfenced separators=""><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced><m:mfenced open="[" close="]" separators=""><m:mfenced separators=""><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced><m:msup><m:mfenced separators=""><m:msup><m:mi>P</m:mi><m:mo>&#8242;</m:mo></m:msup><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced></m:mfenced><m:mn>2</m:mn></m:msup><m:mo>-</m:mo><m:mi>n</m:mi><m:mi>P</m:mi><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced><m:msup><m:mi>P</m:mi><m:mrow><m:mo>&#8242;</m:mo><m:mo>&#8242;</m:mo></m:mrow></m:msup><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced></m:mfenced></m:math>&#160;and <m:math><m:msub><m:mi>z</m:mi><m:mn>0</m:mn></m:msub></m:math>&#160;is specified.</div><div class="paramtext">The sign in the denominator is chosen so that the modulus of the Laguerre step at <m:math><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:math>, viz. <m:math><m:mfenced open="|" close="|" separators=""><m:mi>L</m:mi><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced></m:mfenced></m:math>, is as small as possible.  The method can be shown to be cubically convergent for isolated roots (real or complex) and linearly convergent for multiple roots.</div><div class="paramtext">The routine generates a sequence of iterates <m:math><m:msub><m:mi>z</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>z</m:mi><m:mn>2</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>z</m:mi><m:mn>3</m:mn></m:msub><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mtext/></m:math>, such that <m:math><m:mfenced open="|" close="|" separators=""><m:mi>P</m:mi><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mrow><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub></m:mfenced></m:mfenced><m:mo>&lt;</m:mo><m:mfenced open="|" close="|" separators=""><m:mi>P</m:mi><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced></m:mfenced></m:math>&#160;and ensures that <m:math><m:msub><m:mi>z</m:mi><m:mrow><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub><m:mo>+</m:mo><m:mi>L</m:mi><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mrow><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub></m:mfenced></m:math>&#160;&#8216;roughly&#8217; lies inside a circular region of radius <m:math><m:mfenced open="|" close="|" separators=""><m:mi>F</m:mi></m:mfenced></m:math>&#160;about <m:math><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:math>&#160;known to contain a zero of <m:math><m:mi>P</m:mi><m:mfenced separators=""><m:mi>z</m:mi></m:mfenced></m:math>; that is, <m:math><m:mfenced open="|" close="|" separators=""><m:mi>L</m:mi><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mrow><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub></m:mfenced></m:mfenced><m:mo>&#8804;</m:mo><m:mfenced open="|" close="|" separators=""><m:mi>F</m:mi></m:mfenced></m:math>, where <m:math><m:mi>F</m:mi></m:math>&#160;denotes the Fej&#233;r bound (see <a class="ref" href="#ref001">Marden (1966)</a>) at the point <m:math><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:math>.  Following <a class="ref" href="#ref002">Smith (1967)</a>, <m:math><m:mi>F</m:mi></m:math>&#160;is taken to be <m:math>
 <m:mrow><m:mi>min</m:mi><m:mspace width="0.125em"/><m:mfenced separators=""><m:mi>B</m:mi><m:mo>,</m:mo><m:mrow><m:mn>1.445</m:mn><m:mi>n</m:mi><m:mi>R</m:mi></m:mrow></m:mfenced></m:mrow>
</m:math>, where <m:math><m:mi>B</m:mi></m:math>&#160;is an upper bound for the magnitude of the smallest zero given by

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mi>B</m:mi>
 <m:mo>=</m:mo>
 <m:mn>1.0001</m:mn>
 <m:mo>&#215;</m:mo>
 <m:mrow><m:mi>min</m:mi><m:mspace width="0.125em"/><m:mfenced separators=""><m:mrow>
   <m:msqrt><m:mi>n</m:mi></m:msqrt>
   <m:mi>L</m:mi>
   <m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced>
  </m:mrow><m:mo>,</m:mo><m:mfenced open="|" close="|" separators=""><m:msub><m:mi>r</m:mi><m:mn>1</m:mn></m:msub></m:mfenced><m:mo>,</m:mo><m:msup>
   <m:mfenced open="|" close="|" separators="">
    <m:msub><m:mi>a</m:mi><m:mi>n</m:mi></m:msub>
    <m:mo>/</m:mo>
    <m:msub><m:mi>a</m:mi><m:mn>0</m:mn></m:msub></m:mfenced>
    <m:mrow><m:mn>1</m:mn><m:mo>/</m:mo><m:mi>n</m:mi></m:mrow>
  </m:msup></m:mfenced></m:mrow>
 <m:mtext>,</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div><m:math><m:msub><m:mi>r</m:mi><m:mn>1</m:mn></m:msub></m:math>&#160;is the zero <m:math><m:mi>X</m:mi></m:math>&#160;of smaller magnitude of the quadratic equation

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mfrac>
  <m:mrow>
   <m:msup><m:mi>P</m:mi><m:mrow><m:mo>&#8242;</m:mo><m:mo>&#8242;</m:mo></m:mrow></m:msup>
   <m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced>
  </m:mrow>
  <m:mrow>
   <m:mn>2</m:mn>
   <m:mi>n</m:mi>
   <m:mfenced separators=""><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mfenced>
  </m:mrow>
 </m:mfrac>
 <m:msup><m:mi>X</m:mi><m:mn>2</m:mn></m:msup>
 <m:mo>+</m:mo>
 <m:mfrac>
  <m:mrow>
   <m:msup><m:mi>P</m:mi><m:mo>&#8242;</m:mo></m:msup>
   <m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced>
  </m:mrow>
  <m:mi>n</m:mi>
 </m:mfrac>
 <m:mi>X</m:mi>
 <m:mo>+</m:mo>
 <m:mfrac other="small"><m:mn>1</m:mn><m:mn>2</m:mn></m:mfrac>
 <m:mi>P</m:mi><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced>
 <m:mo>=</m:mo>
 <m:mn>0</m:mn>
</m:math></td><td class="formula2"/></tr></table></div>

and the Cauchy lower bound <m:math><m:mi>R</m:mi></m:math>&#160;for the smallest zero is computed (using Newton's Method) as the positive root of the polynomial equation

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:mfenced open="|" close="|" separators=""><m:msub><m:mi>a</m:mi><m:mn>0</m:mn></m:msub></m:mfenced>
 <m:msup><m:mi>z</m:mi><m:mi>n</m:mi></m:msup>
 <m:mo>+</m:mo>
 <m:mfenced open="|" close="|" separators=""><m:msub><m:mi>a</m:mi><m:mn>1</m:mn></m:msub></m:mfenced>
 <m:msup><m:mi>z</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msup>
 <m:mo>+</m:mo>
 <m:mfenced open="|" close="|" separators=""><m:msub><m:mi>a</m:mi><m:mn>2</m:mn></m:msub></m:mfenced>
 <m:msup><m:mi>z</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>2</m:mn></m:mrow></m:msup>
 <m:mo>+</m:mo><m:mo>&#8943;</m:mo><m:mo>+</m:mo>
 <m:mfenced open="|" close="|" separators=""><m:msub><m:mi>a</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:msub></m:mfenced>
 <m:mi>z</m:mi>
 <m:mo>-</m:mo>
 <m:mfenced open="|" close="|" separators=""><m:msub><m:mi>a</m:mi><m:mi>n</m:mi></m:msub></m:mfenced>
 <m:mo>=</m:mo>
 <m:mn>0</m:mn>
 <m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div></div><div class="paramtext">Starting from the origin, successive iterates are generated according to the rule 
<m:math>
 <m:msub><m:mi>z</m:mi><m:mrow><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub>
 <m:mo>=</m:mo>
 <m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub>
 <m:mo>+</m:mo>
 <m:mi>L</m:mi>
 <m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced>
</m:math>, for 
<m:math>
 <m:mi>k</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:mn>3</m:mn>
 <m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mtext/></m:math>, and 
<m:math><m:mi>L</m:mi><m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub></m:mfenced></m:math>&#160;is &#8216;adjusted&#8217; so that 
<m:math>
 <m:mfenced open="|" close="|" separators="">
  <m:mi>P</m:mi>
  <m:mfenced separators="">
   <m:msub><m:mi>z</m:mi><m:mrow><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub>
  </m:mfenced>
 </m:mfenced>
 <m:mo>&lt;</m:mo>
 <m:mfenced open="|" close="|" separators="">
  <m:mi>P</m:mi>
  <m:mfenced separators="">
   <m:msub><m:mi>z</m:mi><m:mi>k</m:mi></m:msub>
  </m:mfenced>
 </m:mfenced>
</m:math>&#160;and 
<m:math>
 <m:mfenced open="|" close="|" separators="">
  <m:mi>L</m:mi>
  <m:mfenced separators="">
   <m:msub><m:mi>z</m:mi><m:mrow><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub>
  </m:mfenced>
 </m:mfenced>
 <m:mo>&#8804;</m:mo>
 <m:mfenced open="|" close="|" separators=""><m:mi>F</m:mi></m:mfenced>
</m:math>.  The iterative procedure terminates if 
<m:math>
 <m:mi>P</m:mi>
 <m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mrow><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub></m:mfenced>
</m:math>&#160;is smaller in absolute value than the bound on the rounding error in 
<m:math>
 <m:mi>P</m:mi>
 <m:mfenced separators=""><m:msub><m:mi>z</m:mi><m:mrow><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub></m:mfenced>
</m:math>&#160;and the current iterate 
<m:math>
 <m:msub><m:mi>z</m:mi><m:mi>p</m:mi></m:msub>
 <m:mo>=</m:mo>
 <m:msub><m:mi>z</m:mi><m:mrow><m:mi>k</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:msub>
</m:math>&#160;is taken to be a zero of <m:math><m:mi>P</m:mi><m:mfenced separators=""><m:mi>z</m:mi></m:mfenced></m:math>&#160;(as is its conjugate 
<m:math>
 <m:msub><m:mover><m:mi>z</m:mi><m:mo>-</m:mo></m:mover><m:mi>p</m:mi></m:msub>
</m:math>&#160;if <m:math><m:msub><m:mi>z</m:mi><m:mi>p</m:mi></m:msub></m:math>&#160;is complex).  The deflated polynomial 
<m:math>
 <m:mover><m:mi>P</m:mi><m:mo>~</m:mo></m:mover>
 <m:mfenced separators=""><m:mi>z</m:mi></m:mfenced>
 <m:mo>=</m:mo>
 <m:mi>P</m:mi>
 <m:mfenced separators=""><m:mi>z</m:mi></m:mfenced>
 <m:mo>/</m:mo> 
 <m:mfenced separators=""><m:mi>z</m:mi><m:mo>-</m:mo><m:msub><m:mi>z</m:mi><m:mi>p</m:mi></m:msub></m:mfenced>
</m:math>&#160;of degree <m:math><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:math>&#160;if <m:math><m:msub><m:mi>z</m:mi><m:mi>p</m:mi></m:msub></m:math>&#160;is real 
(<m:math>
 <m:mover><m:mi>P</m:mi><m:mo>~</m:mo></m:mover>
 <m:mfenced separators=""><m:mi>z</m:mi></m:mfenced>
 <m:mo>=</m:mo>
 <m:mi>P</m:mi>
 <m:mfenced separators=""><m:mi>z</m:mi></m:mfenced>
 <m:mo>/</m:mo> 
 <m:mfenced separators="">
  <m:mfenced separators=""><m:mi>z</m:mi><m:mo>-</m:mo><m:msub><m:mi>z</m:mi><m:mi>p</m:mi></m:msub></m:mfenced>
  <m:mfenced separators=""><m:mi>z</m:mi><m:mo>-</m:mo><m:msub><m:mover><m:mi>z</m:mi><m:mo>-</m:mo></m:mover><m:mi>p</m:mi></m:msub></m:mfenced>
 </m:mfenced>
</m:math>&#160;of degree <m:math><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>2</m:mn></m:math>&#160;if <m:math><m:msub><m:mi>z</m:mi><m:mi>p</m:mi></m:msub></m:math>&#160;is complex) is then formed, and the above procedure is repeated on the deflated polynomial until <m:math><m:mi>n</m:mi><m:mo>&lt;</m:mo><m:mn>3</m:mn></m:math>, whereupon the remaining roots are obtained via the &#8216;standard&#8217; closed formulae for a linear (<m:math><m:mi>n</m:mi><m:mo>=</m:mo><m:mn>1</m:mn></m:math>) or quadratic (<m:math><m:mi>n</m:mi><m:mo>=</m:mo><m:mn>2</m:mn></m:math>) equation.</div><div class="paramtext">Note that <a class="rout" href="../C02/c02ajf.xml">C02AJF</a>, <a class="rout" href="../C02/c02akf.xml">C02AKF</a> and <a class="rout" href="../C02/c02alf.xml">C02ALF</a> can be used to obtain the roots of a quadratic, cubic (<m:math><m:mi>n</m:mi><m:mo>=</m:mo><m:mn>3</m:mn></m:math>) and quartic (<m:math><m:mi>n</m:mi><m:mo>=</m:mo><m:mn>4</m:mn></m:math>) polynomial, respectively.</div><h2 class="standard"><a class="sec" name="references" id="references"/>4&#160;&#160;References</h2><div class="paramtext"><a name="ref001" id="ref001"/>Marden M (1966)  Geometry of polynomials <i>Mathematical Surveys</i> <b>3</b> American Mathematical Society, Providence, RI </div>
<div class="paramtext"><a name="ref002" id="ref002"/>Smith B T (1967)  ZERPOL: A zero finding algorithm for polynomials using Laguerre's method <i>Technical Report</i> Department of Computer Science, University of Toronto, Canada </div>
<div class="paramtext"><a name="ref708" id="ref708"/>Thompson K W (1991)  Error analysis for polynomial solvers <i>Fortran Journal (Volume 3)</i> <b>3</b> 10&#8211;13 </div>
<div class="paramtext"><a name="ref003" id="ref003"/>Wilkinson J H (1965)  <i>The Algebraic Eigenvalue Problem</i> Oxford University Press, Oxford </div><h2 class="standard"><a class="sec" name="parameters" id="parameters"/>5&#160;&#160;Parameters</h2>
<dl><dt class="paramhead"><a name="A" id="A"/>1: &#160;&#160;&#8194; A(<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>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: if <a class="arg" href="#A">A</a> is declared with bounds <m:math><m:mfenced separators=""><m:mn>0</m:mn><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:mfenced></m:math>, then 
<m:math>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#A"><m:mi mathcolor="#EE0000" mathvariant="bold">A</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mi>i</m:mi></m:mfenced></m:mrow>
</m:math>&#160;must contain <m:math>
 <m:msub><m:mi>a</m:mi><m:mi>i</m:mi></m:msub>
</m:math>&#160;(i.e., the coefficient of <m:math>
 <m:msup><m:mi>z</m:mi><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mi>i</m:mi></m:mrow></m:msup>
</m:math>), for <m:math>
 <m:mi>i</m:mi><m:mo>=</m:mo><m:mn>0</m:mn><m:mo>,</m:mo><m:mn>1</m:mn><m:mo>,</m:mo><m:mo>&#8230;</m:mo><m:mo>,</m:mo><m:mi>n</m:mi>
</m:math>.</div><div class="paramtext"><i>Constraint</i>:
  <m:math>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#A"><m:mi mathcolor="#EE0000" mathvariant="bold">A</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>0</m:mn></m:mfenced></m:mrow>
 <m:mo>&#8800;</m:mo>
 <m:mn>0.0</m:mn>
</m:math>.
</div></dd><dt class="paramhead"><a name="N" id="N"/>2: &#160;&#160;&#8194; N &#8211; INTEGER<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: 

<m:math><m:mi>n</m:mi></m:math>, the degree of the polynomial.</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>&#8805;</m:mo><m:mn>1</m:mn></m:math>.
</div></dd><dt class="paramhead"><a name="SCAL" id="SCAL"/>3: &#160;&#160;&#8194; SCAL &#8211; LOGICAL<span class="pclass">Input</span></dt><dd><div class="paramtext"><i>On entry</i>: indicates whether or not the polynomial is to be scaled.  See <a class="sec" href="#fcomments">Section 8</a> for advice on when it may be preferable to set <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#SCAL"><m:mi mathcolor="#EE0000" mathvariant="bold">SCAL</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.FALSE.</m:mi></m:math>&#160;and for a description of the scaling strategy.</div>
 <div class="paramtext"><i>Suggested value</i>:
  <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#SCAL"><m:mi mathcolor="#EE0000" mathvariant="bold">SCAL</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>.</div></dd><dt class="paramhead"><a name="Z" id="Z"/>4: &#160;&#160;&#8194; Z(<m:math><m:mn>2</m:mn></m:math>,<a class="arg" href="#N">N</a>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Output</span></dt><dd><div class="paramtext"><i>On exit</i>: the real and imaginary parts of the roots are stored in <m:math>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn><m:mi>i</m:mi></m:mfenced></m:mrow>
</m:math>&#160;and <m:math>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn><m:mi>i</m:mi></m:mfenced></m:mrow>
</m:math>&#160;respectively, 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:math>.  Complex conjugate pairs of roots are stored in consecutive pairs of elements of <a class="arg" href="#Z">Z</a>; that is, <m:math>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn><m:mrow><m:mi>i</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow>
 <m:mo>=</m:mo>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn><m:mi>i</m:mi></m:mfenced></m:mrow>
</m:math>&#160;and <m:math>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn><m:mrow><m:mi>i</m:mi><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow>
 <m:mo>=</m:mo>
 <m:mo>-</m:mo><m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn><m:mi>i</m:mi></m:mfenced></m:mrow>
</m:math>.</div></dd><dt class="paramhead"><a name="W" id="W"/>5: &#160;&#160;&#8194; W(<m:math><m:mn>2</m:mn><m:mo>&#215;</m:mo><m:mfenced separators=""><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:mfenced></m:math>) &#8211; <span class="bitalic">double precision</span> array<span class="pclass">Workspace</span></dt><dt class="paramhead"><a name="IFAIL" id="IFAIL"/>6: &#160;&#160;&#8194; IFAIL &#8211; INTEGER<span class="pclass">Input/Output</span></dt><dd>
<div class="paramtext"><i>On entry</i>: <a class="arg" href="#IFAIL">IFAIL</a> must be set to <m:math><m:mn>0</m:mn></m:math>, <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>. If you are unfamiliar with this parameter you should refer to <a class="sec" href="../GENINT/essint.xml#library3">Section 3.3</a> in  the Essential Introduction for details.</div>
<div class="paramtext"><i>On exit</i>: <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFAIL"><m:mi mathcolor="#EE0000" mathvariant="bold">IFAIL</m:mi></m:maction><m:mo>=</m:mo><m:maction actiontype="link" dsi:type="simple" dsi:href="#errors"><m:mn mathcolor="#003399" mathvariant="bold">0</m:mn></m:maction></m:math>&#160;unless the routine detects an error (see <a class="sec" href="#errors">Section 6</a>). <div class="paramtext">For environments where it might be inappropriate to halt program execution when an error is detected, the value <m:math><m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow><m:mtext>&#8203; or &#8203;</m:mtext><m:mn>1</m:mn></m:math>&#160;is recommended.  If the output of error messages is undesirable, then the value <m:math><m:mn>1</m:mn></m:math>&#160;is recommended.  Otherwise, 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></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:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#A"><m:mi mathcolor="#EE0000" mathvariant="bold">A</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>0</m:mn></m:mfenced></m:mrow><m:mo>=</m:mo><m:mn>0.0</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="#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></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 iterative procedure has failed to converge.  This error is very unlikely to occur.  If it does, please contact <a class="url" href="http://www.nag.co.uk">NAG</a>, as some basic assumption for the arithmetic has been violated.  See also <a class="sec" href="#fcomments">Section 8</a>.</div>
</dd>
</dl><dl class="ifail">
<dt class="errorhead"><a name="IFeq3" id="IFeq3"/><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>3</m:mn></m:math></dt>
<dd>
<div class="paramtext">Either overflow or underflow prevents the evaluation of <m:math><m:mi>P</m:mi><m:mfenced separators=""><m:mi>z</m:mi></m:mfenced></m:math>&#160;near some of its zeros.  This error is very unlikely to occur.  If it does, please contact <a class="url" href="http://www.nag.co.uk">NAG</a>.  See also <a class="sec" href="#fcomments">Section 8</a>.</div>
</dd>
</dl><h2 class="standard"><a class="sec" name="accuracy" id="accuracy"/>7&#160;&#160;Accuracy</h2>
<div class="paramtext">All roots are evaluated as accurately as possible, but because of the inherent nature of the problem complete accuracy cannot be guaranteed. 
See also <a class="sec" href="#example">Section 9</a>.
</div><h2 class="standard"><a class="sec" name="fcomments" id="fcomments"/>8&#160;&#160;Further Comments</h2>
<div class="paramtext">If <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#SCAL"><m:mi mathcolor="#EE0000" mathvariant="bold">SCAL</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>, then a scaling factor for the coefficients is chosen as a power of the base <m:math><m:mi>b</m:mi></m:math>&#160;of the machine so that the largest coefficient in magnitude approaches <m:math><m:mi mathvariant="italic">thresh</m:mi><m:mo>=</m:mo><m:msup><m:mi>b</m:mi><m:mrow><m:msub><m:mi>e</m:mi><m:mi mathvariant="normal">max</m:mi></m:msub><m:mo>-</m:mo><m:mi>p</m:mi></m:mrow></m:msup></m:math>.  You should note that no scaling is performed if the largest coefficient in magnitude exceeds <m:math><m:mi mathvariant="italic">thresh</m:mi></m:math>, even if <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#SCAL"><m:mi mathcolor="#EE0000" mathvariant="bold">SCAL</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>. (<m:math><m:mi>b</m:mi></m:math>, <m:math><m:msub><m:mi>e</m:mi><m:mi mathvariant="normal">max</m:mi></m:msub></m:math>&#160;and <m:math><m:mi>p</m:mi></m:math>&#160;are defined in <a class="chap" href="../X02/x02conts.xml">Chapter X02</a>.)</div><div class="paramtext">However, with <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#SCAL"><m:mi mathcolor="#EE0000" mathvariant="bold">SCAL</m:mi></m:maction><m:mo>=</m:mo><m:mi mathvariant="normal">.TRUE.</m:mi></m:math>, overflow may be encountered when the input coefficients <m:math><m:msub><m:mi>a</m:mi><m:mn>0</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>a</m:mi><m:mn>1</m:mn></m:msub><m:mo>,</m:mo><m:msub><m:mi>a</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>a</m:mi><m:mi>n</m:mi></m:msub></m:math>&#160;vary widely in magnitude, particularly on those machines for which <m:math>
 <m:msup><m:mi>b</m:mi><m:mfenced separators=""><m:mn>4</m:mn><m:mi>p</m:mi></m:mfenced></m:msup>
</m:math>&#160;overflows.  In such cases, <a class="arg" href="#SCAL">SCAL</a> should be set to .FALSE. and the coefficients scaled so that the largest coefficient in magnitude does not exceed <m:math>
 <m:msup><m:mi>b</m:mi>
 <m:mfenced separators=""><m:msub><m:mi>e</m:mi><m:mi mathvariant="normal">max</m:mi></m:msub><m:mo>-</m:mo><m:mn>2</m:mn><m:mi>p</m:mi></m:mfenced>
</m:msup></m:math>.</div><div class="paramtext">Even so, the scaling strategy used by C02AGF is sometimes insufficient to avoid overflow and/or underflow conditions.  In such cases, you are recommended to scale the independent variable <m:math><m:mfenced separators=""><m:mi>z</m:mi></m:mfenced></m:math>&#160;so that the disparity between the largest and smallest coefficient in magnitude is reduced.  That is, use the routine to locate the zeros of the polynomial <m:math><m:mi>d</m:mi><m:mi>P</m:mi><m:mfenced separators=""><m:mi>c</m:mi><m:mi>z</m:mi></m:mfenced></m:math>&#160;for some suitable values of <m:math><m:mi>c</m:mi></m:math>&#160;and <m:math><m:mi>d</m:mi></m:math>.  For example, if the original polynomial was <m:math><m:mi>P</m:mi><m:mfenced separators=""><m:mi>z</m:mi></m:mfenced><m:mo>=</m:mo><m:msup><m:mn>2</m:mn><m:mrow><m:mo>-</m:mo><m:mn>100</m:mn></m:mrow></m:msup><m:mo>+</m:mo><m:msup><m:mn>2</m:mn><m:mn>100</m:mn></m:msup><m:msup><m:mi>z</m:mi><m:mn>20</m:mn></m:msup></m:math>, then choosing <m:math><m:mi>c</m:mi><m:mo>=</m:mo><m:msup><m:mn>2</m:mn><m:mrow><m:mo>-</m:mo><m:mn>10</m:mn></m:mrow></m:msup></m:math>&#160;and <m:math><m:mi>d</m:mi><m:mo>=</m:mo><m:msup><m:mn>2</m:mn><m:mn>100</m:mn></m:msup></m:math>, for instance, would yield the scaled polynomial <m:math><m:mn>1</m:mn><m:mo>+</m:mo><m:msup><m:mi>z</m:mi><m:mn>20</m:mn></m:msup></m:math>, which is well-behaved relative to overflow and underflow and has zeros which are <m:math><m:msup><m:mn>2</m:mn><m:mn>10</m:mn></m:msup></m:math>&#160;times those of <m:math><m:mi>P</m:mi><m:mfenced separators=""><m:mi>z</m:mi></m:mfenced></m:math>.</div><div class="paramtext">If the routine fails with <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="#IFeq2"><m:mn mathcolor="#003399" mathvariant="bold">2</m:mn></m:maction></m:math>&#160;or <m:math><m:maction actiontype="link" dsi:type="simple" dsi:href="#IFeq3"><m:mn mathcolor="#003399" mathvariant="bold">3</m:mn></m:maction></m:math>, then the real and imaginary parts of any roots obtained before the failure occurred are stored in <a class="arg" href="#Z">Z</a> in the reverse order in which they were found. 
Let <m:math>
 <m:msub><m:mi>n</m:mi><m:mi>R</m:mi></m:msub>
</m:math>&#160;denote the number of roots found before the failure occurred.  Then <m:math>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn><m:mi>n</m:mi></m:mfenced></m:mrow>
</m:math>&#160;and <m:math>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn><m:mi>n</m:mi></m:mfenced></m:mrow>
</m:math>&#160;contain the real and imaginary parts of the first root found, <m:math>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow>
</m:math>&#160;and <m:math>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn><m:mrow><m:mi>n</m:mi><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow>
</m:math>&#160;contain the real and imaginary parts of the second root found, <m:math>
 <m:mo>&#8230;</m:mo>
 <m:mo>,</m:mo>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>1</m:mn><m:mrow>
   <m:mi>n</m:mi><m:mo>-</m:mo>
   <m:msub><m:mi>n</m:mi><m:mi>R</m:mi></m:msub><m:mo>+</m:mo><m:mn>1</m:mn></m:mrow></m:mfenced></m:mrow>
</m:math>&#160;and <m:math>
 <m:mrow><m:maction actiontype="link" dsi:type="simple" dsi:href="#Z"><m:mi mathcolor="#EE0000" mathvariant="bold">Z</m:mi></m:maction><m:mfenced separators="," open="(" close=")"><m:mn>2</m:mn><m:mrow>
   <m:mi>n</m:mi><m:mo>-</m:mo>
   <m:msub><m:mi>n</m:mi><m:mi>R</m:mi></m:msub><m:mo>+</m:mo><m:mn>1</m:mn>
  </m:mrow></m:mfenced></m:mrow>
</m:math>&#160;contain the real and imaginary parts of the <m:math>
 <m:msub><m:mi>n</m:mi><m:mi>R</m:mi></m:msub>
</m:math>th root found.  After the failure has occurred, the remaining <m:math>
 <m:mn>2</m:mn><m:mo>&#215;</m:mo>
 <m:mfenced separators=""><m:mi>n</m:mi><m:mo>-</m:mo><m:msub><m:mi>n</m:mi><m:mi>R</m:mi></m:msub></m:mfenced>
</m:math>&#160;elements of <a class="arg" href="#Z">Z</a> contain a large negative number (equal to <m:math>
 <m:mrow><m:mo>-</m:mo><m:mn>1</m:mn></m:mrow>
 <m:mo>/</m:mo>
 <m:mfenced separators=""><m:maction actiontype="link" dsi:type="simple" dsi:href="../X02/x02amf.xml#X02AMF"><m:mi mathcolor="#5555FF" mathvariant="bold">X02AMF</m:mi></m:maction><m:mfenced separators=""/><m:mo>&#215;</m:mo><m:msqrt><m:mn>2</m:mn></m:msqrt></m:mfenced>
</m:math>).

</div><h2 class="standard"><a class="sec" name="example" id="example"/>9&#160;&#160;Example</h2>
<div class="paramtext">For this routine two examples are presented.  There is a single example program for C02AGF, with a main program and the code to solve the two example problems given in the subroutines EX1 and EX2.</div><div class="paramtext"><b>Example 1 (EX1)</b></div><div class="paramtext">This example finds the roots of the fifth degree polynomial

<div class="formula"><table class="formula"><tr><td class="formula"><m:math display="block">
 <m:msup><m:mi>z</m:mi><m:mn>5</m:mn></m:msup>
 <m:mo>+</m:mo>
 <m:mn>2</m:mn><m:mo>&#8290;</m:mo><m:msup><m:mi>z</m:mi><m:mn>4</m:mn></m:msup>
 <m:mo>+</m:mo>
 <m:mn>3</m:mn><m:mo>&#8290;</m:mo><m:msup><m:mi>z</m:mi><m:mn>3</m:mn></m:msup>
 <m:mo>+</m:mo>
 <m:mn>4</m:mn><m:mo>&#8290;</m:mo><m:msup><m:mi>z</m:mi><m:mn>2</m:mn></m:msup>
 <m:mo>+</m:mo>
 <m:mn>5</m:mn><m:mi>z</m:mi>
 <m:mo>+</m:mo>
 <m:mn>6</m:mn><m:mo>=</m:mo><m:mn>0</m:mn>
 <m:mtext>.</m:mtext>
</m:math></td><td class="formula2"/></tr></table></div></div><div class="paramtext"><b>Example 2 (EX2)</b></div><div class="paramtext">This example solves the same problem as subroutine EX1, but in addition attempts to estimate the accuracy of the computed roots using a perturbation analysis.  Further details can be found in <a class="ref" href="#ref708">Thompson (1991)</a>.</div><h3 class="standard"><a class="sec" name="examtext" id="examtext"/>9.1&#160;&#160;Program Text</h3>
<p><a class="verbatimref" href="../../examples/source/c02agfe.f">Program Text (c02agfe.f)</a></p><h3 class="standard"><a class="sec" name="examdata" id="examdata"/>9.2&#160;&#160;Program Data</h3>
<p><a class="verbatimref" href="../../examples/data/c02agfe.d">Program&#160;Data (c02agfe.d)</a></p><h3 class="standard"><a class="sec" name="examresults" id="examresults"/>9.3&#160;&#160;Program Results</h3>
<p><a class="verbatimref" href="../../examples/baseresults/c02agfe.r">Program Results (c02agfe.r)</a></p>
<hr/><div><a class="rout" href="../../pdf/C02/c02agf.pdf">C02AGF (PDF version)</a></div><div><a class="chap" href="c02conts.xml">C02 Chapter Contents</a></div><div><a class="chapint" href="c02intro.xml">C02 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>
