Library: | nummath |
See also: | nmpolroots complex |
Quantlet: | nmpolrootlaguer | |
Description: | implements Laguerre's method for improving a given complex value until it converges to a root of a given polynomial |
Usage: | root = nmpolrootlaguer(coef {,m,x}) | |
Input: | ||
coef | n x 1 vector of real or complex numbers, coefficients of the polynomial sum_{i=0}^{n-1} coef[i] * x^i | |
m | optional integer, order of the polynomial. Default m = rows(coef) - 1. | |
x | optional complex number, initial estimate of the root. Default x = 0 + 0*i. | |
Output: | ||
root | complex number, approximation of a root of the given polynomial |
If m < rows(coef) - 1, the polynomial of m-th order will be considered, i.e., the coefficients corresponding to x^j, j > m, will not be taken into account.
Accuracy of the root finding is given by the achievable roundoff error by polynomial evaluation.
A warning will be produced if no root is found with a given precision in maxiter iterations.
library("nummath") ; x^2 + 16 coef = #(16,0,1) nmpolrootlaguer(coef,2,complex(10,-2)) nmpolrootlaguer(coef,2,1)
Contents of root.re [1,] 0 Contents of root.im [1,] -4 Contents of root.re [1,] -2.2204e-16 Contents of root.im [1,] 4
library("nummath") ; x^5 - 32 coef = #(-32,0,0,0,0,1) nmpolrootlaguer(coef,5,1)
Contents of root.re [1,] 2 Contents of root.im [1,] 0
library("nummath") ; x coef = #(0,1) nmpolrootlaguer(coef)
Contents of root.re [1,] 0 Contents of root.im [1,] 0
library("nummath") ; 1 => no solution coef = #(1,0) nmpolrootlaguer(coef)
Produces a warning "Convergence not achieved before maxiter! Maybe different initial guess helps."