Applied Numerical Analysis Using MATLAB® Second Edition Laurene V. Fausett Texas A&M University-Commerce PEARSON Prentice Hall Upper Saddle River, NJ 07458 Contents Preface 1 Foundations 1.1 Introductory Examples 1.1.1 Nonlinear Equations 1.1.2 Linear Systems 1.1.3 Numerical Integration 1.2 Useful Background 1.2.1 Results from Calculus 1.2.2 Results from Linear Algebra 1.2.3 A Little Information about Computers 1.3 Some Basic Issues 1.3.1 Error 1.3.2 Convergence 1.3.3 Getting Better Results 1.4 UsingMATLAB 1.4.1 Command Window Computations 1.4.2 M-Files 1.4.3 Programming in MATLAB 1.4.4 Matrix Multiplication 1.5 Chapter Wrap-Up 2 Functions of One Variable 2.1 Bisection Method 2.2 Secant-Type Methods 2.2.1 Regula Falsi 2.2.2 Secant Method 2.2.3 Analysis 2.3 Newton's Method 2.4 Muller's Method 2.5 Minimization 2.5.1 Golden-Section Search 2.5.2 Brent's Method 2.6 Beyond the Basics 2.6.1 Using MATLAB's Functions 2.6.2 Laguerre's Method 2.6.3 Zeros of a Nonlinear Function 2.7 Chapter Wrap-Up xi 1 4 4 6 8 10 10 11 13 '. . . 16 16 22 26 31 31 35 37 39 41 47 50 54 55 58 61 64 71 76 76 79 80 80 82 85 88 v 1 vi 3 Solving Linear Systems: Direct Methods 3.1 Gaussian Elimination 3.1.1 Basic Method 3.1.2 Row Pivoting 3.2 Gauss-Jordan 3.2.1 Inverse of a Matrix 3.3 Tridiagonal Systems 3.4 Further Topics 3.4.1 MATLAB's Methods 3.4.2 Condition of a Matrix 3.4.3 Iterative Refinement 3.5 Chapter Wrap-Up 95 98 98 107 112 113 114 119 119 121 123 125 4 LU and QR Factorization 4.1 LU Factorization 4.1.1 Using Gaussian Elimination 4.1.2 Direct LU Factorization 4.1.3 Applications 4.2 Matrix Transformations 4.2.1 Householder Transformation 4.2.2 Givens Rotations 4.3 QR Factorization 4.3.1 Using Householder Transformations 4.3.2 Using Givens Rotations 4.4 Beyond the Basics 4.4.1 LU Factorization with Implicit Row Pivoting 4.4.2 EfRcient Conversion to Hessenberg Form 4.4.3 Using MATLAB's Functions 4.5 Chapter Wrap-Up 135 138 138 146 150 154 155 162 164 164 166 168 168 170 171 172 5 Eigenvalues and Eigenvectors 5.1 Power Method 5.1.1 Basic Power Method 5.1.2 Rayleigh Quotient 5.1.3 Shifted Power Method 5.1.4 Accelerating Convergence 5.2 Inverse Power Method 5.2.1 General Inverse Power Method 5.2.2 Convergence 5.3 QR Method 5.3.1 Basic QR Method 5.3.2 Better QR Method 5.3.3 Finding Eigenvectors 5.3.4 Accelerating Convergence 5.4 Further Topics 5.4.1 Singular Value Decomposition 5.4.2 MATLAB's Methods 5.5 Chapter Wrap-Up 179 182 183 186 188 189 190 192 193 194 194 196 198 199 202 202 203 204 VII 6 Solving Linear Systems: Iterative Methods 6.1 Jacobi Method 6.2 Gauss-Seidel Method 6.3 Successive Over-Relaxation 6.4 Beyond the Basics 6.4.1 MATLAB's Built-In Functions 6.4.2 Conjugate Gradient Methods 6.4.3 GMRES 6.4.4 Simplex Method 6.5 Chapter Wrap-Up 213 217 224 228 232 232 234 238 240 243 7 Nonlinear Functions of Several Variables 7.1 Nonlinear Systems 7.1.1 Newton's Method 7.1.2 Secant Methods 7.1.3 Fixed-Point Iteration 7.2 Minimization 7.2.1 Descent Methods 7.2.2 Quasi-Newton Methods 7.3 Further Topics 7.3.1 Levenberg-Marquardt Method 7.3.2 Nelder-Mead Simplex Search 7.4 Chapter Wrap-Up 251 254 254 260 262 264 264 266 268 268 269 270 8 Interpolation 8.1 Polynomial Interpolation 8.1.1 Lagrange Form 8.1.2 Newton Form 8.1.3 Difficulties 8.2 Hermite Interpolation 8.3 Piecewise Polynomial Interpolation 8.3.1 Piecewise Linear Interpolation 8.3.2 Piecewise Quadratic Interpolation 8.3.3 Piecewise Cubic Hermite Interpolation 8.3.4 Cubic Spline Interpolation 8.4 Beyond the Basics 8.4.1 Rational-Function Interpolation 8.4.2 Using MATLAB's Functions 8.5 Chapter Wrap-Up 275 278 278 284 290 294 299 300 301 304 305 312 312 316 323 9 Approximation 9.1 Least-Squares Approximation 9.1.1 Approximation by a Straight Line 9.1.2 Approximation by a Parabola 9.1.3 General Least-Squares Approximation 9.1.4 Approximation for Other Functional Forms 333 336 336 342 346 348 K viii 9.2 Continuous Least-Squares Approximation 9.2.1 Approximation Using Powers of x 9.2.2 Orthogonal Polynomials 9.2.3 Legendre Polynomials 9.2.4 Chebyshev Polynomials Function Approximation at a Point 9.3.1 Pade Approximation 9.3.2 Taylor Approximation Further Topics 9.4.1 Bezier Curves 9.4.2 Using MATLAB's Functions Chapter Wrap-Up 350 350 352 354 356 358 358 361 362 362 364 366 10 Fourier Methods 10.1 Fourier Approximation and Interpolation 10.1.1 Derivation 10.1.2 Data on Other Intervals 10.2 Radix-2 Fourier Transforms 10.2.1 Discrete Fourier Transform 10.2.2 Fast Fourier Transform 10.2.3 Matrix Form of FFT 10.2.4 Algebraic Form of FFT 10.3 Mixed-Radix FFT 10.4 Using MATLAB's Functions 10.5 Chapter Wrap-Up 373 376 381 384 386 386 387 388 389 392 396 400 11 Numerical Differentiation and Integration 11.1 Differentiation 11.1.1 First Derivatives 11.1.2 Higher Derivatives 11.1.3 Partial Derivatives 11.1.4 Richardson Extrapolation 11.2 Numerical Integration 11.2.1 Trapezoid Rule 11.2.2 Simpson's Rule 11.2.3 Newton-Cotes Open Formulas . . . 11.2.4 Extrapolation Methods 11.3 Quadrature 11.3.1 Gaussian Quadrature 11.3.2 Other Gauss-Type Quadratures 11.4 MATLAB's Methods 11.4.1 Differentiation 11.4.2 Integration 11.5 Chapter Wrap-Up 405 408 408 412 413 414 416 417 420 426 428 431 431 435 437 437 437 438 9.3 9.4 9.5 IX 12 Ordinary Differential Equations: Fundamentals 12.1 Euler's Method 12.1.1 Geometrie Introduction 12.1.2 Approximating the Derivative 12.1.3 Approximating the Integral 12.1.4 Using Taylor Series 12.2 Runge-Kutta Methods 12.2.1 Second-Order Runge-Kutta Methods 12.2.2 Third-Order Runge-Kutta Methods 12.2.3 Classic Runge-Kutta Method 12.2.4 Fourth-Order Runge-Kutta Methods 12.2.5 Fifth-Order Runge-Kutta Methods 12.2.6 Runge-Kutta-Fehlberg Methods 12.3 Multistep Methods 12.3.1 Adams-Bashforth Methods 12.3.2 Adams-Moulton Methods 12.3.3 Adams Predictor-Corrector Methods 12.3.4 Other Predictor-Corrector Methods 12.4 Further Topics 12.4.1 MATLAB's Methods 12.4.2 Consistency and Convergence 12.5 Chapter Wrap-Up 13 ODE: Systems, Stiffhess, Stability 13.1 Systems 13.1.1 Systems of Two ODE 13.1.2 Euler's Method for Systems 13.1.3 Runge-Kutta Methods for Systems 13.1.4 Multistep Methods for Systems 13.1.5 Second-Order ODE 13.2 StifFODE 13.2.1 BDF Methods 13.2.2 Implicit Runge-Kutta Methods 13.3 Stability 13.3.1 A-Stable and Stiffly Stable Methods 13.3.2 Stability in the Limit 13.4 Further Topics 13.4.1 MATLAB's Methods for Stiff ODE 13.4.2 Extrapolation Methods 13.4.3 Rosenbrock Methods 13.4.4 Multivalue Methods 13.5 Chapter Wrap-Up 445 447 447 448 449 451 452 452 457 459 462 464 465 474 476 479 480 485 : . . 487 487 488 490 499 502 504 510 512 516 522 526 527 529 530 532 533 536 536 537 539 539 552 1 ^ 14 ODE: Boundary-Value Problems 14.1 Shooting Method 14.1.1 Linear ODE 14.1.2 Nonlinear ODE 14.2 Finite-Difference Method 14.2.1 Linear ODE 14.2.2 Nonlinear ODE 14.3 Function Space Methods 14.3.1 Collocation 14.3.2 Rayleigh-Ritz 14.4 Chapter Wrap-Up 561 565 565 570 576 576 580 582 582 586 588 15 Partial Differential Equations 15.1 Heat Equation: Parabolic PDE 15.1.1 Explicit Method 15.1.2 Implicit Method 15.1.3 Crank-Nicolson Method 15.1.4 Insulated Boundary 15.2 Wave Equation: Hyperbolic PDE 15.2.1 Explicit Method 15.2.2 Implicit Method 15.3 Poisson Equation: Elliptic PDE 15.4 Finite-Element Method for Elliptic PDE 15.4.1 Defining the Subregions 15.4.2 Defining the Basis Functions 15.4.3 Computing the Coefncients 15.4.4 UsingMATLAB 15.5 Chapter Wrap-Up 593 598 599 604 608 611 612 614 616 618 622 623 624 626 629 634 Bibliography 643 Ans wer s 653 Index 667