Module 10.1: nag polynom eqn Roots of Polynomials. Contents

Similar documents
Module 10.2: nag nlin eqn Roots of a Single Nonlinear Equation. Contents

Module 6.6: nag nsym gen eig Nonsymmetric Generalized Eigenvalue Problems. Contents

NAG Library Routine Document C02AGF.1

Module 5.2: nag sym lin sys Symmetric Systems of Linear Equations. Contents

Module 3.9: nag kelvin fun Kelvin Functions. Contents

Module 29.3: nag tsa spectral Time Series Spectral Analysis. Contents

Module 11.4: nag quad util Numerical Integration Utilities. Contents

NAG Library Routine Document F08UBF (DSBGVX)

NAG Library Routine Document F08PNF (ZGEES)

NAG Library Routine Document F08FPF (ZHEEVX)

NAG Library Routine Document F08FAF (DSYEV)

NAG Library Routine Document F08QUF (ZTRSEN)

NAG Library Routine Document F08JDF (DSTEVR)

QUADRATIC PROGRAMMING?

NAG Library Routine Document F07HAF (DPBSV)

Extended Introduction to Computer Science CS1001.py. Lecture 8 part A: Finding Zeroes of Real Functions: Newton Raphson Iteration

PART I Lecture Notes on Numerical Solution of Root Finding Problems MATH 435

Chapter 6. Nonlinear Equations. 6.1 The Problem of Nonlinear Root-finding. 6.2 Rate of Convergence

Jim Lambers MAT 610 Summer Session Lecture 2 Notes

Math 411 Preliminaries

NAG Library Routine Document F08VAF (DGGSVD)

NAG Library Routine Document F08QVF (ZTRSYL)

A Method for Reducing Ill-Conditioning of Polynomial Root Finding Using a Change of Basis

Chapter 1 Error Analysis

Math 504 (Fall 2011) 1. (*) Consider the matrices

Order of convergence. MA3232 Numerical Analysis Week 3 Jack Carl Kiefer ( ) Question: How fast does x n

Floating-point Computation

CHAPTER 2 EXTRACTION OF THE QUADRATICS FROM REAL ALGEBRAIC POLYNOMIAL

Chapter 1 Computer Arithmetic

NAG Library Routine Document F08YUF (ZTGSEN).1

Communications II Lecture 9: Error Correction Coding. Professor Kin K. Leung EEE and Computing Departments Imperial College London Copyright reserved

Mathematics for Engineers. Numerical mathematics

Compute the behavior of reality even if it is impossible to observe the processes (for example a black hole in astrophysics).

that determines x up to a complex scalar of modulus 1, in the real case ±1. Another condition to normalize x is by requesting that

NAG Fortran Library Routine Document D02JAF.1

NAG Library Routine Document F08FNF (ZHEEV).1

Elements of Floating-point Arithmetic

NAG Library Routine Document F02HDF.1

Notes on floating point number, numerical computations and pitfalls

ELEMENTARY LINEAR ALGEBRA

A Study of Iteration Formulas for Root Finding, Where Mathematics, Computer Algebra and Software Engineering Meet

NAG Fortran Library Routine Document F04CFF.1

you expect to encounter difficulties when trying to solve A x = b? 4. A composite quadrature rule has error associated with it in the following form

F04JGF NAG Fortran Library Routine Document

Computing Eigenvalues and/or Eigenvectors;Part 2, The Power method and QR-algorithm

Finding the Roots of f(x) = 0. Gerald W. Recktenwald Department of Mechanical Engineering Portland State University

Finding the Roots of f(x) = 0

EIGENVALUE PROBLEMS. EIGENVALUE PROBLEMS p. 1/4

NAG Library Routine Document D02JAF.1

Sample questions for Fundamentals of Machine Learning 2018

Two hours. To be provided by Examinations Office: Mathematical Formula Tables. THE UNIVERSITY OF MANCHESTER. 29 May :45 11:45

Numerical Solution of f(x) = 0

CS760, S. Qiao Part 3 Page 1. Kernighan and Pike [5] present the following general guidelines for testing software.

5.3 The Power Method Approximation of the Eigenvalue of Largest Module

11.5 Reduction of a General Matrix to Hessenberg Form

Roots of Polynomials

Newton-Raphson Type Methods

Elements of Floating-point Arithmetic

Considering our result for the sum and product of analytic functions, this means that for (a 0, a 1,..., a N ) C N+1, the polynomial.

Topic 1 Part 3 [483 marks]

Find the common ratio of the geometric sequence. (2) 1 + 2

CHAPTER 1: Functions

MATH2071: LAB #5: Norms, Errors and Condition Numbers

Numerical Methods I Solving Nonlinear Equations

An Introduction to Numerical Analysis. James Brannick. The Pennsylvania State University

THE TEACHER UNDERSTANDS THE REAL NUMBER SYSTEM AND ITS STRUCTURE, OPERATIONS, ALGORITHMS, AND REPRESENTATIONS

LU Factorization. LU factorization is the most common way of solving linear systems! Ax = b LUx = b

DELFT UNIVERSITY OF TECHNOLOGY

1 Floating point arithmetic

Begin accumulation of transformation matrices. This block skipped when i=1. Use u and u/h stored in a to form P Q.

Gaussian Elimination for Linear Systems

SCHOOL OF MATHEMATICS MATHEMATICS FOR PART I ENGINEERING. Self-paced Course

Computing Science Group STABILITY OF THE MAHALANOBIS DISTANCE: A TECHNICAL NOTE. Andrew D. Ker CS-RR-10-20

Primality Testing SURFACE. Syracuse University. Per Brinch Hansen Syracuse University, School of Computer and Information Science,

Scientific Computing. Roots of Equations

Math From Scratch Lesson 29: Decimal Representation

Lecture 7. Floating point arithmetic and stability

Computer Arithmetic. MATH 375 Numerical Analysis. J. Robert Buchanan. Fall Department of Mathematics. J. Robert Buchanan Computer Arithmetic

ELEMENTARY LINEAR ALGEBRA

On the reduction of matrix polynomials to Hessenberg form

FAMILIES OF ALGEBRAIC TEST EQUATIONS W. GAUTSCHI (I)

The PRIMES 2014 problem set

G01NBF NAG Fortran Library Routine Document

4 Nonlinear Equations

The numerical stability of barycentric Lagrange interpolation

On NP-Completeness for Linear Machines

Number Systems III MA1S1. Tristan McLoughlin. December 4, 2013

Introduction. An Introduction to Algorithms and Data Structures

G13CCF NAG Fortran Library Routine Document

CS 221 Lecture 9. Tuesday, 1 November 2011

11.2 Reduction of a Symmetric Matrix to Tridiagonal Form: Givens and Householder Reductions

Linear Algebra Massoud Malek

G03ACF NAG Fortran Library Routine Document

APPROXIMATION OF ROOTS OF EQUATIONS WITH A HAND-HELD CALCULATOR. Jay Villanueva Florida Memorial University Miami, FL

Integral Section List for OCR Specification

numerical analysis 1

Lecture 4: Linear Algebra 1

Complex numbers, the exponential function, and factorization over C

Problem Set 5 Solution Set

Program 1 Foundations of Computational Math 1 Fall 2018

Transcription:

Nonlinear Equations Module Contents Module 10.1: nag polynom eqn Roots of Polynomials nag polynom eqn provides a procedure for computing the roots of a polynomial with real or complex coefficients. Contents Procedures nag polynom roots... 10.1.3 Calculates the roots of a polynomial Examples Example 1: Roots of a polynomial with real coefficients... 10.1.7 Example 2: Roots of a polynomial with complex coefficients... 10.1.9 Mathematical Background... 10.1.11 References... 10.1.12 [NP3245/3/pdf] Module 10.1: nag polynom eqn 10.1.1

Module Contents Nonlinear Equations 10.1.2 Module 10.1: nag polynom eqn [NP3245/3/pdf]

Nonlinear Equations nag polynom roots Procedure: nag polynom roots 1 Description nag polynom roots is a procedure for finding all the roots of the nth degree real or complex polynomial equation P (z) =a n z n + a n 1 z n 1 + a n 2 z n 2 + + a 1 z + a 0 =0, using a variant of Laguerre s Method. 2 Usage USE nag polynom eqn CALL nag polynom roots(a, z [, optional arguments]) 3 Arguments Note. All array arguments are assumed-shape arrays. The extent in each dimension must be exactly that required by the problem. Notation such as x(n) is used in the argument descriptions to specify that the array x must have exactly n elements. This procedure derives the value of the following problem parameter from the shape of the supplied arrays. n 1 the degree of the polynomial 3.1 Mandatory Arguments a(n +1) real(kind=wp) / complex(kind=wp), intent(in) Input: the coefficients of the polynomial. If a is declared with bounds (0 : n), then a(i) must contain a i (i.e., the coefficient of z i )fori =0, 1,...,n. Constraints: the coefficient of z n, a(n +1) 0.0. z(n) complex(kind=wp), intent(out) Output: the roots of the polynomial, stored in z(i), for i =1, 2,...,n. 3.2 Optional Arguments Note. Optional arguments must be supplied by keyword, not by position. The order in which they are described below may differ from the order in which they occur in the argument list. scale logical, intent(in), optional Input: indicates whether or not the polynomial is to be scaled. Default: scale =.true.. Note: see Section 6.2 for advice on when it may be preferable to set scale =.false. and for a description of the scaling strategy. error type(nagerror), intent(inout), optional The NAG fl 90 error-handling argument. See the Essential Introduction, or the module document nag error handling (1.2). You are recommended to omit this argument if you are unsure how to use it. If this argument is supplied, it must be initialized by a call to nag set error before this procedure is called. [NP3245/3/pdf] Module 10.1: nag polynom eqn 10.1.3

nag polynom roots Nonlinear Equations 4 Error Codes Fatal errors (error%level = 3): error%code Description 301 An input argument has an invalid value. 303 Array arguments have inconsistent shapes. Failures (error%level = 2): error%code Description 201 The iterative procedure has failed to converge. For this procedure this failure should not normally occur; please contact NAG. 202 Overflow/underflow prevents the evaluation of P (z) near some of its zeros. 5 Examples of Usage Complete examples of the use of this procedure appear in Examples 1 and 2 of this module document. 6 Further Comments 6.1 Algorithmic Detail The roots are located using a modified form of Laguerre s Method, originally proposed by Smith [4]. The method of Laguerre (see Wilkinson [5]) can be described by the iterative scheme L(z k )=z k+1 z k = np (z k ) P (z k ) ± H(z k ), where H(z k )=(n 1)[(n 1)(P (z k )) 2 np (z k )P (z k )], and z 0 is specified. The sign in the denominator is chosen so that the modulus of the Laguerre step at z k,namely L(z k ), 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. The procedure generates a sequence of iterates z 1, z 2, z 3,..., such that P (z k+1 ) < P (z k ) and ensures that z k+1 + L(z k+1 ) roughly lies inside a circular region of radius F about z k knowntocontainazero of P (z); that is, L(z k+1 ) F, wheref denotes the Féjer bound (see Marden [2]) at the point z k. Following Smith [4], F is taken to be min(b,1.445nr), where B is an upper bound for the magnitude of the smallest root, given by B =1.0001 min( n L(z k ), r 1, a 0 /a n 1/n ), where r 1 is the zero, X, of smaller magnitude of the quadratic equation (P (z k )/(n(n 1)))X 2 +2(P (z k )/n)x + P (z k )=0 and the Cauchy lower bound R for the smallest root is computed (using Newton s Method) as the positive root of the polynomial equation a n z n + a n 1 z n 1 + a n 2 z n 2 + + a 1 z a 0 =0. Starting from the origin, successive iterates are generated according to the rule z k+1 = z k + L(z k )for k =1, 2, 3,...,andL(z k )is adjusted sothat P (z k+1 ) < P (z k ) and L(z k+1 ) F. The iterative procedure terminates if P (z k+1 ) is smaller in absolute value than the bound on the rounding error in P (z k+1 ) and the current iterate z p = z k+1 is taken to be a root of P (z) (as is its conjugate z p if z p is complex when P (z) has real coefficients). A deflated polynomial, P (z), is then formed as follows. 10.1.4 Module 10.1: nag polynom eqn [NP3245/3/pdf]

Nonlinear Equations nag polynom roots P (z) =P (z)/(z z p ), degree (n 1), if z p is real and P (z) has real coefficients; P (z) =P (z)/ ((z z p )(z z p )), degree (n 2), if z p is complex and P (z) has real coefficients; P (z) =P (z)/(z z p ), degree (n 1), if P (z) has complex coefficients. The above procedure is then repeated on the deflated polynomial until n<3, whereupon the remaining roots are obtained via the standard closed formulae for a linear (n = 1) or quadratic (n =2)equation. 6.2 Scaling If scale =.true. (the default), then a scaling factor for the coefficients is chosen as a power of the base b of the machine so that the largest coefficient in magnitude approaches thresh = b emax p,where b = RADIX(1.0 wp), p = DIGITS(1.0 wp), ande max = MAXEXPONENT(1.0 wp). Note that no scaling is performed if the largest coefficient in magnitude exceeds thresh, evenifscale =.true.. However, with scale =.true., overflow may be encountered when the input coefficients a 0,a 1,a 2,...,a n vary widely in magnitude, particularly on those machines for which b (4p) overflows. In such cases, scale should be set to.false. and the coefficients scaled so that the largest coefficient in magnitude does not exceed b (emax 2p). Even so, the scaling strategy used in this procedure is sometimes insufficient to avoid overflow and/or underflow conditions. In such cases, you are recommended to scale the independent variable (z) so that the disparity between the largest and smallest coefficient in magnitude is reduced. That is, use the procedure to locate the zeros of the polynomial d P (cz) for some suitable values of c and d. For example, if the original polynomial was P (z) =2 100 i +2 100 z 20, then choosing c =2 10 and d =2 100, for instance, would yield the scaled polynomial i + z 20, which is well behaved relative to overflow and underflow and has zeros which are 2 10 times those of P (z). [NP3245/3/pdf] Module 10.1: nag polynom eqn 10.1.5

nag polynom roots Nonlinear Equations 10.1.6 Module 10.1: nag polynom eqn [NP3245/3/pdf]

Nonlinear Equations Example 1 Example 1: Roots of a polynomial with real coefficients The following example program can be used to find the roots of an nth degree real polynomial. It is used to find the roots of the 5th degree polynomial z 5 +2z 4 +3z 3 +4z 2 +5z +6=0. 1 Program Text Note. The listing of the example program presented below is double precision. Single precision users are referred to Section 5.2 of the Essential Introduction for further information. PROGRAM nag_polynom_eqn_ex01! Example Program Text for nag_polynom_eqn! NAG fl90, Release 3. NAG Copyright 1997.!.. Use Statements.. USE nag_examples_io, ONLY : nag_std_in, nag_std_out USE nag_polynom_eqn, ONLY : nag_polynom_roots!.. Implicit None Statement.. IMPLICIT NONE!.. Intrinsic Functions.. INTRINSIC KIND!.. Parameters.. INTEGER, PARAMETER :: wp = KIND(1.0D0)!.. Local Scalars.. INTEGER :: i, n!.. Local Arrays.. REAL (wp), ALLOCATABLE :: a(:) COMPLEX (wp), ALLOCATABLE :: z(:)!.. Executable Statements.. WRITE (nag_std_out,*) Example Program Results for nag_polynom_eqn_ex01 READ (nag_std_in,*) READ (nag_std_in,*) n ALLOCATE (a(0:n),z(n))! Skip heading in data file! Allocate storage! Read the polynomial coefficients READ (nag_std_in,*) a! Find the roots CALL nag_polynom_roots(a,z) WRITE (nag_std_out, (/,1X,A,I4,/) ) Degree of Polynomial =, n DO i = 1, n WRITE (nag_std_out, (1X,A,"(",E12.4,",",E12.4,")") ) z =, z(i) END DO DEALLOCATE (a,z)! Deallocate storage END PROGRAM nag_polynom_eqn_ex01 2 Program Data Example Program Data for nag_polynom_eqn_ex01 5 : n ( Degree of Polynomial ) 6.0 5.0 4.0 3.0 2.0 1.0 : a ( Vector of Coefficients ) [NP3245/3/pdf] Module 10.1: nag polynom eqn 10.1.7

Example 1 Nonlinear Equations 3 Program Results Example Program Results for nag_polynom_eqn_ex01 Degree of Polynomial = 5 z = ( -0.1492E+01, 0.0000E+00) z = ( 0.5517E+00, 0.1253E+01) z = ( 0.5517E+00, -0.1253E+01) z = ( -0.8058E+00, 0.1223E+01) z = ( -0.8058E+00, -0.1223E+01) 10.1.8 Module 10.1: nag polynom eqn [NP3245/3/pdf]

Nonlinear Equations Example 2 Example 2: Roots of a polynomial with complex coefficients The following example program can be used to find the roots of an nth degree complex polynomial. It is used to find the roots of the polynomial a 5 z 5 + a 4 z 4 + a 3 z 3 + a 2 z 2 + a 1 z + a 0 =0,wherea 5 =5+6i, a 4 =30+20i, a 3 = 0.2 6i, a 2 = 50 + 100000i, a 1 = 2+40i and a 0 =10+i. 1 Program Text Note. The listing of the example program presented below is double precision. Single precision users are referred to Section 5.2 of the Essential Introduction for further information. PROGRAM nag_polynom_eqn_ex02! Example Program Text for nag_polynom_eqn! NAG fl90, Release 3. NAG Copyright 1997.!.. Use Statements.. USE nag_examples_io, ONLY : nag_std_in, nag_std_out USE nag_polynom_eqn, ONLY : nag_polynom_roots!.. Implicit None Statement.. IMPLICIT NONE!.. Intrinsic Functions.. INTRINSIC KIND!.. Parameters.. INTEGER, PARAMETER :: wp = KIND(1.0D0)!.. Local Scalars.. INTEGER :: i, n!.. Local Arrays.. COMPLEX (wp), ALLOCATABLE :: a(:), z(:)!.. Executable Statements.. WRITE (nag_std_out,*) Example Program Results for nag_polynom_eqn_ex02 READ (nag_std_in,*) READ (nag_std_in,*) n ALLOCATE (a(0:n),z(n))! Skip heading in data file! Allocate storage! Read the polynomial coefficients READ (nag_std_in,*) a! Find the roots CALL nag_polynom_roots(a,z) WRITE (nag_std_out, (/,1X,A,I4,/) ) Degree of Polynomial =, n DO i = 1, n WRITE (nag_std_out, (1X,A,"(",E12.4,",",E12.4,")") ) z =, z(i) END DO DEALLOCATE (a,z)! Deallocate storage END PROGRAM nag_polynom_eqn_ex02 [NP3245/3/pdf] Module 10.1: nag polynom eqn 10.1.9

Example 2 Nonlinear Equations 2 Program Data Example Program Data for nag_polynom_eqn_ex02 5 : n ( Degree of Polynomial) ( 10.0, 1.0 ) ( -2.0, 40.0 ) ( 50.0, 100000.0 ) ( -0.2, -6.0 ) ( 30.0, 20.0 ) ( 5.0, 6.0 ) : End of a ( Vector of Coefficients ) 3 Program Results Example Program Results for nag_polynom_eqn_ex02 Degree of Polynomial = 5 z = ( -0.2433E+02, -0.4855E+01) z = ( 0.5249E+01, 0.2274E+02) z = ( 0.1465E+02, -0.1657E+02) z = ( -0.6926E-02, -0.7443E-02) z = ( 0.6526E-02, 0.7423E-02) 10.1.10 Module 10.1: nag polynom eqn [NP3245/3/pdf]

Nonlinear Equations Mathematical Background Mathematical Background 1 Introduction Let f(z) a n z n + a n 1 z n 1 + a n 2 z n 2 + + a 1 z + a 0, a n 0 be a polynomial of degree n with complex coefficients a i.acomplexnumberz 1 is called a zero of f(z) (or equivalently a root of the equation f(z) =0),iff(z 1 )=0. If z 1 is a zero, then f(z) can be divided by a factor (z z 1 ): f(z) =(z z 1 )f 1 (z) (1) where f 1 (z) is a polynomial of degree n 1. By the Fundamental Theorem of Algebra, a polynomial f(z) has at least one zero, and so the process of dividing out factors (z z i ) can be continued until we have a complete factorization of f(z): f(z) a n (z z 1 )(z z 2 ) (z z n ). Here the complex numbers z 1,z 2,...,z n are the zeros of f(z); they may not all be distinct, so it is sometimes more convenient to write: f(z) a n (z z 1 ) m1 (z z 2 ) m2 (z z k ) m k, k n, with distinct zeros z 1,z 2,...,z k and multiplicities m i 1. If m i =1,z i is called a single zero; if m i > 1, z i is called a multiple or repeated zero; a multiple zero is also a zero of the derivative of f(z). If the coefficients of f(z) are all real, then the zeros of f(z) are either real or else occur as pairs of conjugate complex numbers a + ib and a ib. A pair of complex conjugate zeros are the zeros of a quadratic factor of f(z), (z 2 + rz + s), with real coefficients r and s. Although polynomials are generally regarded as simple functions, the problem of numerically computing the zeros of an arbitrary polynomial is far from simple. A great variety of algorithms have been proposed, of which a number have been widely used in practice; for a fairly comprehensive survey, see Householder [1]. All general algorithms are iterative. Most converge to one zero at a time; the corresponding factor can then be divided out as in (1) above (this process is called deflation or, loosely, dividing out the zero) and the algorithm can be applied again to the polynomial f 1 (z). A pair of complex conjugate zeros can be divided out together; this corresponds to dividing f(z) by a quadratic factor. Whatever the theoretical basis of the algorithm, a number of practical problems arise; for a thorough discussion of some of them see Peters and Wilkinson [3]. The most elementary point is that, even if z 1 is mathematically an exact zero of f(z), because of the fundamental limitations of computer arithmetic the computed value of f(z 1 ) will not necessarily be exactly 0.0. In practice there is usually a small region of values of z about the exact zero at which the computed value of f(z) becomes dominated by rounding errors. Moreover in many algorithms this inaccuracy in the computed value of f(z) results in a similar inaccuracy in the computed step from one iterate to the next. This limits the precision with which any zero can be computed. Deflation is another potential cause of trouble, since, in the notation of (1), the computed coefficients of f 1 (z) will not be completely accurate, especially if z 1 is not an exact zero of f(z); so the zeros of the computed f 1 (z) will deviate from the zeros of f(z). A zero is called ill conditioned if it is sensitive to small changes in the coefficients of the polynomial. An ill conditioned zero is likewise sensitive to the computational inaccuracies just mentioned. Conversely a zero is called well conditioned if it is comparatively insensitive to such perturbations. Roughly speaking a zero which is well separated from other zeros is well conditioned, while zeros which are close together are ill conditioned, but in talking about closeness the decisive factor is not the absolute distance between neighbouring zeros but their ratio: if the ratio is close to 1 the zeros are ill conditioned. In particular, multiple zeros are ill conditioned. A multiple zero is usually split into a cluster of zeros by perturbations in the polynomial or computational inaccuracies. [NP3245/3/pdf] Module 10.1: nag polynom eqn 10.1.11

References Nonlinear Equations References [1] Householder A S (1970) The Numerical Treatment of a Single Nonlinear Equation McGraw-Hill [2] Marden M (1966) Geometry of polynomials Mathematical Surveys 3 American Mathematical Society, Providence, RI [3] Peters G and Wilkinson J H (1971) Practical problems arising in the solution of polynomial equations J. Inst. Maths. Applics. 8 16 35 [4] Smith B T (1967) ZERPOL: A zero finding algorithm for polynomials using Laguerre s method Technical Report Department of Computer Science, University of Toronto, Canada [5] Wilkinson J H (1965) The Algebraic Eigenvalue Problem Oxford University Press, London 10.1.12 Module 10.1: nag polynom eqn [NP3245/3/pdf]