c9-2 (779532), страница 2
Текст из файла (страница 2)
Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).A powerful variant on false position is due to Ridders [1]. When a root isbracketed between x1 and x2 , Ridders’ method first evaluates the function at themidpoint x3 = (x1 + x2 )/2. It then factors out that unique exponential functionwhich turns the residual function into a straight line.
Specifically, it solves for afactor eQ that gives9.3 Van Wijngaarden–Dekker–Brent Method359}else {if (fl == 0.0) return x1;if (fh == 0.0) return x2;nrerror("root must be bracketed in zriddr.");}return 0.0;Never get here.}CITED REFERENCES AND FURTHER READING:Ralston, A., and Rabinowitz, P. 1978, A First Course in Numerical Analysis, 2nd ed. (New York:McGraw-Hill), §8.3.Ostrowski, A.M. 1966, Solutions of Equations and Systems of Equations, 2nd ed. (New York:Academic Press), Chapter 12.Ridders, C.J.F. 1979, IEEE Transactions on Circuits and Systems, vol.
CAS-26, pp. 979–980. [1]9.3 Van Wijngaarden–Dekker–Brent MethodWhile secant and false position formally converge faster than bisection, onefinds in practice pathological functions for which bisection converges more rapidly.These can be choppy, discontinuous functions, or even smooth functions if the secondderivative changes sharply near the root.
Bisection always halves the interval, whilesecant and false position can sometimes spend many cycles slowly pulling distantbounds closer to a root. Ridders’ method does a much better job, but it too cansometimes be fooled. Is there a way to combine superlinear convergence with thesureness of bisection?Sample page from NUMERICAL RECIPES IN C: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43108-5)Copyright (C) 1988-1992 by Cambridge University Press.Programs Copyright (C) 1988-1992 by Numerical Recipes Software.Permission is granted for internet users to make one paper copy for their own personal use. Further reproduction, or any copying of machinereadable files (including this one) to any servercomputer, is strictly prohibited.
To order Numerical Recipes books,diskettes, or CDROMsvisit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to trade@cup.cam.ac.uk (outside North America).for (j=1;j<=MAXIT;j++) {xm=0.5*(xl+xh);fm=(*func)(xm);First of two function evaluations per its=sqrt(fm*fm-fl*fh);eration.if (s == 0.0) return ans;xnew=xm+(xm-xl)*((fl >= fh ? 1.0 : -1.0)*fm/s);Updating formula.if (fabs(xnew-ans) <= xacc) return ans;ans=xnew;fnew=(*func)(ans);Second of two function evaluations perif (fnew == 0.0) return ans;iteration.if (SIGN(fm,fnew) != fm) {Bookkeeping to keep the root bracketedxl=xm;on next iteration.fl=fm;xh=ans;fh=fnew;} else if (SIGN(fl,fnew) != fl) {xh=ans;fh=fnew;} else if (SIGN(fh,fnew) != fh) {xl=ans;fl=fnew;} else nrerror("never get here.");if (fabs(xh-xl) <= xacc) return ans;}nrerror("zriddr exceed maximum iterations");.















