Phil Lucht Math & Physics Archive
Home / Math and Physics Files / Math / Scheid and numerical / Numerical Recipes in Fortran

f0-2

PDF · 8 pages · 40.5 KB
Open PDF file

Sample pages from the book Numerical Recipes in Fortran 77: The Art of Scientific Computing (Cambridge University Press, 1986-1992), not Phil's own writing. It is the index of Fortran routines by chapter and section, from chapter 1 to at least chapter 9. Routines cover linear algebra, interpolation, quadrature, special functions, random numbers, sorting and root finding.

AI-written summary; may contain errors.

Extracted text (machine-read; may contain errors)
Sample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X) Copyright (C) 1986-1992 by Cambridge University Press.Programs Copyright (C) 1986-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 copyin g of machine- readable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes booksor CDROMs, v isit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to [email protected] (outside North Amer ica).Computer Programs by Chapter and Section 1.0 flmoon calculate phases of the moon by date 1.1 julday Julian Day number from calendar date 1.1 badluk Friday the 13th when the moon is full 1.1 caldat calendar date from Julian day number 2.1 gaussj Gauss-Jordan matrix inversion and linear equation solution 2.3 ludcmp linear equation solution, LUdecomposition 2.3 lubksb linear equation solution, backsubstitution 2.4 tridag solution of tridiagonal systems 2.4 banmul multiply vector by band diagonal matrix 2.4 bandec band diagonal systems, decomposition 2.4 banbks band diagonal systems, backsubstitution 2.5 mprove linear equation solution, iterative improvement 2.6 svbksb singular value backsubstitution 2.6 svdcmp singular value decomposition of a matrix 2.6 pythag calculate (a2+b2)1/2without overflow 2.7 cyclic solution of cyclic tridiagonal systems 2.7 sprsin convert matrix to sparse format 2.7 sprsax product of sparse matrix and vector 2.7 sprstx product of transpose sparse matrix and vector 2.7 sprstp transpose of sparse matrix 2.7 sprspm pattern multiply two sparse matrices 2.7 sprstm threshold multiply two sparse matrices 2.7 linbcg biconjugategradient solution of sparse systems 2.7 snrm used by linbcgfor vector norm 2.7 atimes used by linbcgfor sparse multiplication 2.7 asolve used by linbcgfor preconditioner 2.8 vander solve Vandermonde systems 2.8 toeplz solve Toeplitz systems 2.9 choldc Cholesky decomposition 2.9 cholsl Cholesky backsubstitution 2.10 qrdcmp QR decomposition 2.10 qrsolv QR backsubstitution 2.10 rsolv right triangular backsubstitution 2.10 qrupdt update a QR decomposition 2.10 rotate Jacobi rotation used by qrupdt 3.1 polint polynomial interpolation 3.2 ratint rational function interpolation 3.3 spline construct a cubic spline 3.3 splint cubic spline interpolation 3.4 locate search an ordered table by bisection xxiv ComputerProgramsbyChapterandSection xxvSample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X) Copyright (C) 1986-1992 by Cambridge University Press.Programs Copyright (C) 1986-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 copyin g of machine- readable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes booksor CDROMs, v isit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to [email protected] (outside North Amer ica).3.4 hunt search a table when calls are correlated 3.5 polcoe polynomial coefficients from table of values 3.5 polcof polynomial coefficients from table of values 3.6 polin2 two-dimensional polynomial interpolation 3.6 bcucof construct two-dimensional bicubic 3.6 bcuint two-dimensional bicubic interpolation 3.6 splie2 construct two-dimensional spline 3.6 splin2 two-dimensional spline interpolation 4.2 trapzd trapezoidal rule 4.2 qtrap integrate using trapezoidal rule 4.2 qsimp integrate using Simpson’s rule 4.3 qromb integrate using Romberg adaptive method 4.4 midpnt extended midpoint rule 4.4 qromo integrate using open Rombergadaptive method 4.4 midinf integrate a function on a semi-infinite interval 4.4 midsql integratea functionwith lower square-rootsingularity 4.4 midsqu integratea functionwith uppersquare-rootsingularity 4.4 midexp integrate a functionthat decreases exponentially 4.5 qgaus integrate a function by Gaussian quadratures 4.5 gauleg Gauss-Legendre weights and abscissas 4.5 gaulag Gauss-Laguerre weights and abscissas 4.5 gauher Gauss-Hermite weights and abscissas 4.5 gaujac Gauss-Jacobi weights and abscissas 4.5 gaucof quadratureweights from orthogonalpolynomials 4.5 orthog construct nonclassical orthogonalpolynomials 4.6 quad3d integrate a functionovera three-dimensionalspace 5.1 eulsum sum a series by Euler–vanWijngaardenalgorithm 5.3 ddpoly evaluate a polynomial and its derivatives 5.3 poldiv divide one polynomial by another 5.3 ratval evaluate a rational function 5.7 dfridr numerical derivative by Ridders’ method 5.8 chebft fit a Chebyshev polynomial to a function 5.8 chebev Chebyshev polynomial evaluation 5.9 chder derivativeof a functionalready Chebyshevfitted 5.9 chint integrate a function already Chebyshev fitted 5.10 chebpc polynomial coefficients from a Chebyshev fit 5.10 pcshft polynomialcoefficients of a shifted polynomial 5.11 pccheb inverse of chebpc; use to economizepower series 5.12 pade Pad´e approximantfrom power series coefficients 5.13 ratlsq rational fit by least-squares method 6.1 gammln logarithm of gamma function 6.1 factrl factorial function 6.1 bico binomial coefficients function 6.1 factln logarithm of factorial function xxvi ComputerProgramsby ChapterandSectionSample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X) Copyright (C) 1986-1992 by Cambridge University Press.Programs Copyright (C) 1986-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 copyin g of machine- readable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes booksor CDROMs, v isit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to [email protected] (outside North Amer ica).6.1 beta beta function 6.2 gammp incomplete gamma function 6.2 gammq complement of incomplete gamma function 6.2 gser series used by gammpandgammq 6.2 gcf continued fraction used by gammpandgammq 6.2 erf error function 6.2 erfc complementary error function 6.2 erfcc complementaryerror function, concise routine 6.3 expint exponential integral En 6.3 ei exponential integral Ei 6.4 betai incomplete beta function 6.4 betacf continued fraction used by betai 6.5 bessj0 Bessel function J0 6.5 bessy0 Bessel function Y0 6.5 bessj1 Bessel function J1 6.5 bessy1 Bessel function Y1 6.5 bessy Bessel function Yof general integer order 6.5 bessj Bessel function Jof general integer order 6.6 bessi0 modified Bessel function I0 6.6 bessk0 modified Bessel function K0 6.6 bessi1 modified Bessel function I1 6.6 bessk1 modified Bessel function K1 6.6 bessk modified Bessel function Kof integer order 6.6 bessi modified Bessel function Iof integer order 6.7 bessjy Bessel functions of fractional order 6.7 beschb Chebyshev expansion used by bessjy 6.7 bessik modified Bessel functions of fractional order 6.7 airy Airy functions 6.7 sphbes spherical Bessel functions jnandyn 6.8 plgndr Legendrepolynomials,associated(sphericalharmonics) 6.9 frenel Fresnel integrals S(x)andC(x) 6.9 cisi cosine and sine integrals Ci and Si 6.10 dawson Dawson’s integral 6.11 rf Carlson’s elliptic integral of the first kind 6.11 rd Carlson’s elliptic integral of the second kind 6.11 rj Carlson’s elliptic integral of the third kind 6.11 rc Carlson’s degenerate elliptic integral 6.11 ellf Legendre elliptic integral of the first kind 6.11 elle Legendre elliptic integral of the second kind 6.11 ellpi Legendre elliptic integral of the third kind 6.11 sncndn Jacobian elliptic functions 6.12 hypgeo complex hypergeometric function 6.12 hypser complexhypergeometricfunction,series evaluation 6.12 hypdrv complex hypergeometricfunction, derivativeof 7.1 ran0 randomdeviateby Parkand Miller minimalstandard 7.1 ran1 random deviate, minimal standard plus shuffle ComputerProgramsbyChapterandSection xxviiSample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X) Copyright (C) 1986-1992 by Cambridge University Press.Programs Copyright (C) 1986-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 copyin g of machine- readable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes booksor CDROMs, v isit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to [email protected] (outside North Amer ica).7.1 ran2 randomdeviateby L’Ecuyerlong periodplus shuffle 7.1 ran3 random deviate by Knuth subtractive method 7.2 expdev exponential random deviates 7.2 gasdev normally distributed random deviates 7.3 gamdev gamma-law distribution random deviates 7.3 poidev Poisson distributed random deviates 7.3 bnldev binomial distributed random deviates 7.4 irbit1 random bit sequence 7.4 irbit2 random bit sequence 7.5 psdes “pseudo-DES” hashing of 64 bits 7.5 ran4 random deviates from DES-like hashing 7.7 sobseq Sobol’s quasi-random sequence 7.8 vegas adaptivemultidimensionalMonteCarlo integration 7.8 rebin sample rebinning used by vegas 7.8 miser recursivemultidimensionalMonte Carlo integration 7.8 ranpt get random point, used by miser 8.1 piksrt sort an array by straight insertion 8.1 piksr2 sort two arrays by straight insertion 8.1 shell sort an array by Shell’s method 8.2 sort sort an array by quicksort method 8.2 sort2 sort two arrays by quicksort method 8.3 hpsort sort an array by heapsort method 8.4 indexx construct an index for an array 8.4 sort3 sort, use an index to sort 3 or more arrays 8.4 rank construct a rank table for an array 8.5 select find the Nth largest in an array 8.5 selip find the Nth largest, without altering an array 8.5 hpsel findMlargest values, without altering an array 8.6 eclass determine equivalence classes from list 8.6 eclazz determine equivalence classes from procedure 9.0 scrsho graph a function to search for roots 9.1 zbrac outward search for brackets on roots 9.1 zbrak inward search for brackets on roots 9.1 rtbis find root of a function by bisection 9.2 rtflsp find root of a function by false-position 9.2 rtsec find root of a function by secant method 9.2 zriddr find root of a function by Ridders’ method 9.3 zbrent find root of a function by Brent’s method 9.4 rtnewt find root of a function by Newton-Raphson 9.4 rtsafe findrootofa functionbyNewton-Raphsonandbisection 9.5 laguer find a root of a polynomialby Laguerre’s method 9.5 zroots roots of a polynomial by Laguerre’s method with deflation 9.5 zrhqr roots of a polynomialby eigenvaluemethods 9.5 qroot complexor doubleroot of a polynomial,Bairstow xxviii ComputerProgramsby ChapterandSectionSample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X) Copyright (C) 1986-1992 by Cambridge University Press.Programs Copyright (C) 1986-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 copyin g of machine- readable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes booksor CDROMs, v isit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to [email protected] (outside North Amer ica).9.6 mnewt Newton’s method for systems of equations 9.7 lnsrch search along a line, used by newt 9.7 newt globallyconvergentmulti-dimensionalNewton’smethod 9.7 fdjac finite-difference Jacobian, used by newt 9.7 fmin norm of a vector function, used by newt 9.7 broydn secant method for systems of equations 10.1 mnbrak bracket the minimum of a function 10.1 golden find minimumofa functionby goldensectionsearch 10.2 brent find minimum of a function by Brent’s method 10.3 dbrent findminimumofa functionusingderivativeinformation 10.4 amoeba minimizein N-dimensionsbydownhillsimplexmethod 10.4 amotry evaluate a trial point, used by amoeba 10.5 powell minimize in N-dimensions by Powell’s method 10.5 linmin minimumof a functionalonga rayin N-dimensions 10.5 f1dim function used by linmin 10.6 frprmn minimize in N-dimensionsby conjugategradient 10.6 df1dim alternative function used by linmin 10.7 dfpmin minimizein N-dimensionsby variablemetricmethod 10.8 simplx linear programmingmaximizationof a linearfunction 10.8 simp1 linear programming, used by simplx 10.8 simp2 linear programming, used by simplx 10.8 simp3 linear programming, used by simplx 10.9 anneal travelingsalesman problemby simulatedannealing 10.9 revcst cost of a reversal, used by anneal 10.9 revers do a reversal, used by anneal 10.9 trncst cost of a transposition, used by anneal 10.9 trnspt do a transposition, used by anneal 10.9 metrop Metropolis algorithm, used by anneal 10.9 amebsa simulated annealing in continuous spaces 10.9 amotsa evaluate a trial point, used by amebsa 11.1 jacobi eigenvaluesandeigenvectorsof a symmetric matrix 11.1 eigsrt eigenvectors, sorts into order by eigenvalue 11.2 tred2 Householderreductionof a real, symmetric matrix 11.3 tqli eigensolutionof a symmetric tridiagonal matrix 11.5 balanc balance a nonsymmetric matrix 11.5 elmhes reduce a general matrix to Hessenberg form 11.6 hqr eigenvalues of a Hessenberg matrix 12.2 four1 fast Fourier transform (FFT) in one dimension 12.3 twofft fast Fourier transform of two real functions 12.3 realft fast Fourier transform of a single real function 12.3 sinft fast sine transform 12.3 cosft1 fast cosine transform with endpoints 12.3 cosft2 “staggered” fast cosine transform 12.4 fourn fast Fourier transform in multidimensions ComputerProgramsby ChapterandSection xxixSample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X) Copyright (C) 1986-1992 by Cambridge University Press.Programs Copyright (C) 1986-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 copyin g of machine- readable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes booksor CDROMs, v isit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to [email protected] (outside North Amer ica).12.5 rlft3 FFT of real data in two or three dimensions 12.6 fourfs FFT for huge data sets on external media 12.6 fourew rewind and permute files, used by fourfs 13.1 convlv convolutionor deconvolutionof data using FFT 13.2 correl correlation or autocorrelationof data using FFT 13.4 spctrm power spectrum estimation using FFT 13.6 memcof evaluate maximumentropy (MEM) coefficients 13.6 fixrts reflect roots of a polynomialinto unit circle 13.6 predic linear prediction using MEM coefficients 13.7 evlmem power spectral estimation from MEM coefficients 13.8 period power spectrum of unevenly sampled data 13.8 fasper powerspectrumof unevenlysampledlargerdata sets 13.8 spread extirpolate value into array, used by fasper 13.9 dftcor computeendpointcorrectionsfor Fourier integrals 13.9 dftint high-accuracy Fourier integrals 13.10 wt1 one-dimensionaldiscrete wavelet transform 13.10 daub4 Daubechies 4-coefficient wavelet filter 13.10 pwtset initialize coefficients for pwt 13.10 pwt partial wavelet transform 13.10 wtn multidimensional discrete wavelet transform 14.1 moment calculate moments of a data set 14.2 ttest Student’s t-test for difference of means 14.2 avevar calculate mean and variance of a data set 14.2 tutest Student’s t-test formeans, case of unequalvariances 14.2 tptest Student’s t-test for means, case of paired data 14.2 ftest F-test for difference of variances 14.3 chsone chi-squaretest for differencebetweendata andmodel 14.3 chstwo chi-squaretest for differencebetweentwo data sets 14.3 ksone Kolmogorov-Smirnovtest of data against model 14.3 kstwo Kolmogorov-Smirnovtest between two data sets 14.3 probks Kolmogorov-Smirnovprobability function 14.4 cntab1 contingency table analysis using chi-square 14.4 cntab2 contingencytable analysis using entropymeasure 14.5 pearsn Pearson’s correlation between two data sets 14.6 spear Spearman’s rankcorrelationbetween two data sets 14.6 crank replaces array elements by their rank 14.6 kendl1 correlation between two data sets, Kendall’s tau 14.6 kendl2 contingencytable analysis using Kendall’s tau 14.7 ks2d1s K–S test in two dimensions, data vs. model 14.7 quadct count points by quadrants, used by ks2d1s 14.7 quadvl quadrant probabilities, used by ks2d1s 14.7 ks2d2s K–S test in two dimensions, data vs. data 14.8 savgol Savitzky-Golay smoothing coefficients 15.2 fit least-squares fit data to a straight line xxx ComputerProgramsbyChapterandSectionSample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X) Copyright (C) 1986-1992 by Cambridge University Press.Programs Copyright (C) 1986-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 copyin g of machine- readable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes booksor CDROMs, v isit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to [email protected] (outside North Amer ica).15.3 fitexy fit data to a straight line, errors in both xandy 15.3 chixy used by fitexyto calculate a χ2 15.4 lfit general linear least-squares fit by normalequations 15.4 covsrt rearrange covariance matrix, used by lfit 15.4 svdfit linearleast-squaresfit bysingularvaluedecomposition 15.4 svdvar variances from singular value decomposition 15.4 fpoly fit a polynomial using lfitorsvdfit 15.4 fleg fit a Legendrepolynomialusing lfitorsvdfit 15.5 mrqmin nonlinear least-squares fit, Marquardt’s method 15.5 mrqcof used by mrqminto evaluate coefficients 15.5 fgauss fit a sum of Gaussians using mrqmin 15.7 medfit fit datato astraightlinerobustly,least absolutedeviation 15.7 rofunc fit data robustly, used by medfit 16.1 rk4 integrateonestep of ODEs, fourth-orderRunge-Kutta 16.1 rkdumb integrate ODEs by fourth-orderRunge-Kutta 16.2 rkqs integrateone step of ODEs with accuracymonitoring 16.2 rkck Cash-Karp-Runge-Kuttastep used by rkqs 16.2 odeint integrate ODEs with accuracy monitoring 16.3 mmid integrate ODEs by modified midpoint method 16.4 bsstep integrate ODEs, Bulirsch-Stoer step 16.4 pzextr polynomial extrapolation, used by bsstep 16.4 rzextr rational functionextrapolation,used by bsstep 16.5 stoerm integrate conservative second-orderODEs 16.6 stiff integrate stiff ODEs by fourth-orderRosenbrock 16.6 jacobn sample Jacobian routine for stiff 16.6 derivs sample derivatives routine for stiff 16.6 simpr integrate stiff ODEs by semi-implicit midpointrule 16.6 stifbs integrate stiff ODEs, Bulirsch-Stoer step 17.1 shoot solve two point boundaryvalueproblemby shooting 17.2 shootf ditto, by shooting to a fitting point 17.3 solvde two pointboundaryvalueproblem,solvebyrelaxation 17.3 bksub backsubstitution, used by solvde 17.3 pinvs diagonalize a sub-block, used by solvde 17.3 red reduce columns of a matrix, used by solvde 17.4 sfroid spheroidal functions by method of solvde 17.4 difeq spheroidal matrix coefficients, used by sfroid 17.4 sphoot spheroidal functions by method of shoot 17.4 sphfpt spheroidal functions by method of shootf 18.1 fred2 solve linear Fredholmequations of the second kind 18.1 fredin interpolate solutions obtained with fred2 18.2 voltra linear Volterra equations of the second kind 18.3 wwghts quadratureweights for an arbitrarilysingular kernel 18.3 kermom sample routine for moments of a singular kernel 18.3 quadmx sample routine for a quadrature matrix ComputerProgramsby ChapterandSection xxxiSample page from NUMERICAL RECIPES IN FORTRAN 77: THE ART OF SCIENTIFIC COMPUTING (ISBN 0-521-43064-X) Copyright (C) 1986-1992 by Cambridge University Press.Programs Copyright (C) 1986-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 copyin g of machine- readable files (including this one) to any servercomputer, is strictly prohibited. To order Numerical Recipes booksor CDROMs, v isit website http://www.nr.com or call 1-800-872-7423 (North America only),or send email to [email protected] (outside North Amer ica).18.3 fredex example of solving a singular Fredholmequation 19.5 sor elliptic PDEsolvedbysuccessiveoverrelaxationmethod 19.6 mglin linear elliptic PDE solved by multigrid method 19.6 rstrct half-weightingrestriction, used by mglin,mgfas 19.6 interp bilinear prolongation,used by mglin,mgfas 19.6 addint interpolate and add, used by mglin 19.6 slvsml solve on coarsest grid, used by mglin 19.6 relax Gauss-Seidel relaxation, used by mglin 19.6 resid calculate residual, used by mglin 19.6 copy utility used by mglin,mgfas 19.6 fill0 utility used by mglin 19.6 maloc memory allocation utility used by mglin,mgfas 19.6 mgfas nonlinearelliptic PDE solvedby multigridmethod 19.6 relax2 Gauss-Seidel relaxation, used by mgfas 19.6 slvsm2 solve on coarsest grid, used by mgfas 19.6 lop applies nonlinear operator, used by mgfas 19.6 matadd utility used by mgfas 19.6 matsub utility used by mgfas 19.6 anorm2 utility used by mgfas 20.1 machar diagnose computer’s floating arithmetic 20.2 igray Gray code and its inverse 20.3 icrc1 cyclic redundancychecksum, used by icrc 20.3 icrc cyclic redundancy checksum 20.3 decchk decimal check digit calculation or verification 20.4 hufmak construct a Huffman code 20.4 hufapp append bits to a Huffmancode, used by hufmak 20.4 hufenc use Huffmancodeto encodeandcompressa character 20.4 hufdec use Huffmancodetodecodeanddecompressacharacter 20.5 arcmak construct an arithmetic code 20.5 arcode encodeor decodea characterusingarithmeticcoding 20.5 arcsum add integer to byte string, used by arcode 20.6 mpops multiple precision arithmetic, simpler operations 20.6 mpmul multiple precision multiply, using FFT methods 20.6 mpinv multiple precision reciprocal 20.6 mpdiv multiple precision divide and remainder 20.6 mpsqrt multiple precision square root 20.6 mp2dfr multiple precision conversionto decimal base 20.6 mppi multipleprecisionexample,computemanydigits of π