• No results found

Engineers. Using MATLAB. Numerical Methods for. and Scientists. Second Edition. Ramin S. Esfandiari, PhD CJI*' CRC Press

N/A
N/A
Protected

Academic year: 2021

Share "Engineers. Using MATLAB. Numerical Methods for. and Scientists. Second Edition. Ramin S. Esfandiari, PhD CJI*' CRC Press"

Copied!
9
0
0

Loading.... (view fulltext now)

Full text

(1)

Numerical Methods for

Engineers

and Scientists

Using

MATLAB®

Second

Edition

Ramin

S.

Esfandiari,

PhD

CRC Press

CJI*'

J Taylor&.FrancisGroup Boca Raton London New York CRC Press isanimprintof the
(2)

Contents

Preface xv

Acknowledgments

X1X

Author xxi

1.

Background

and Introduction 1

Part 1:

Background

1

1.1 Differential

Equations

1

1.1.1 Linear,First-Order ODEs 1 1.1.2 Second-Order ODEswithConstantCoefficients 2 1.1.2.1

Homogeneous

Solution 2 1.1.2.2 Particular Solution 3 1.1.3 Method ofUndeterminedCoefficients 3

1.2 Matrix

Analysis

4 1.2.1 Matrix

Operations

5 1.2.2 Matrix

Transpose

5 1.2.3

Special

Matrices 6 1.2.4 Determinant ofaMatrix 6 1.2.5

Properties

of Determinant 6 1.2.5.1 Cramer's Rule .-. 7 1.2.6 Inverse ofaMatrix 8 1.2.7

Properties

of Inverse 9 1.2.8

Solving

aLinear

System

of

Equations

9

1.3 Matrix

Eigenvalue

Problem 9 1.3.1

Solving

the

Eigenvalue

Problem 10 1.3.2

Similarity

Transformation 11 1.3.3 Matrix

Diagonalization

11 1.3.4

Eigenvalue Properties

of Matrices 12 Part 2: IntroductiontoNumericalMethods 12 1.4 Errors and

Approximations

12 1.4.1 Sources of

Computational

Error 12 1.4.2

Binary

andHexadecimalNumbers 13 1.4.3

Floating

Point and

Rounding

Errors 13 1.4.4 Round-Off:

Chopping

and

Rounding

14 1.4.5 Absolute and RelativeErrors 15

1.4.6 Error Bound 16

1.4.7 Transmission ofErrorfromaSourceto

J:he

Final Result 16 1.4.8 Subtraction of

Nearly Equal

Numbers 17

1.5 Iterative Methods 19

1.5.1 FundamentalIterativeMethod 20 1.5.2 Rate of

Convergence

ofanIterativeMethod 21

ProblemSet

(Chapter

1)

22

2. IntroductiontoMATLAB® 27

2.1 MATLAB Built-in Functions 27 vii

(3)

viii Contents

2.1.1

Rounding

Commands 27

2.1.2 Relational

Operators

28

2.1.3 Format

Options

28

2.2 Vectors and Matrices 29

2.2.1

Linspace

30

2.2.2 Matrices 30

2.2.3 Determinant,

Transpose,

and Inverse 32

2.2.4 Slash

Operators

33

2.2.5

Element-by-Element

Operations

33 2.2.6

Diagonal

Matrices and

Diagonals

ofaMatrix 34

2.3

Symbolic

MathToolbox 36 2.3.1

Anonymous

Functions 38

2.3.2 MATLABFunction 38

2.3.3 Differentiation 39

2.3.4 Partial Derivatives 40

2.3.5

Integration

40

2.4

Program

Flow Control 41

2.4.1 for

Loop

41

2.4.2 The ifCommand 42

2.4.3 while

Loop

43

2.5

Displaying

FormattedData 43

2.5.1 Differential

Equations

44

2.6

Plotting

45

2.6.1

subplot

45

2.6.2

Plotting Analytical Expressions

46

2.6.3

Multiple

Plots 46

2.7 User-Defined Functions and

Script

Files 47 2.7.1

Setting

DefaultValues for

Input

Variables 49 2.7.2

Creating Script

Files 50

ProblemSet

(Chapter 2)

51

3. Numerical Solution of

Equations

ofa

Single

Variable 55

3.1 Numerical Solution of

Equations

55

3.2 Bisection Method 55

3.2.1 MATLAB Built-inFunction fzero 60

3.3

Regula

Falsi Method

(Method

ofFalse

Position)

61 3.3.1 Modified

Regula

FalsiMethod 64

3.4 Fixed-PointMethod 65

3.4.1 Selection ofaSuitable IterationFunction 66

3.4.2 A Note on

Convergence

67 3.4.3 Rate of

Convergence

of the Fixed-Point Iteration 71 3.5 Newton's Method

(Newton-Raphson

Method)

72 3.5.1 Rate of

Convergence

of Newton's Method 76 3.5.2 AFew NotesonNewton's Method 77 3.5.3 Modified Newton's Method for Roots with

Multiplicity

2 or

Higher

78

3.6 Secant Method 81

3.6.1 Rate of

Convergence

of Secant Method 83 3.6.2 AFew NotesonSecant Method 83
(4)

Contents 1X

3.7

Equations

with Several Roots 83

3.7.1

Finding

Rootstothe

Right

ofa

Specified

Point 83

3.7.2

Finding

Several Roots inanInterval

Using

fzero 84

ProblemSet

(Chapter

3)

88

4. Numerical Solution of

Systems

of

Equations

95

4.1 Linear

Systems

of

Equations

95

4.2 Numerical Solution of Linear

Systems

96

4.3 Gauss Elimination Method 96

4.3.1

Choosing

thePivot Row: Partial

Pivoting

with Row

Scaling

98 4.3.2 PermutationMatrices 99 4.3.3

Counting

the Numberof

Operations

102

4.3.3.1 Elimination 102

4.3.3.2 BackSubstitution 103 4.3.4

Tridiagonal Systems

103 4.3.4.1 ThomasMethod 104 4.3.4.2 MATLABBuilt-in Function

«\«

106 4.4 LU Factorization Methods 107 4.4.1 DoolittleFactorization 107 4.4.2

Finding

L and U

Using Steps

of Gauss Elimination 108 4.4.3

Finding

L and U

Directly

108 4.4.3.1 Doolittle's MethodtoSolve aLinear

System

110

4.4.3.2

Operations

Count 112 4.4.4

Cholesky

Factorization 112 4.4.4.1

Cholesky's

Method toSolveaLinear

System

113

4.4.4.2

Operations

Count 115 4.4.4.3 MATLAB Built-inFunctionsluand chol 115 4.5 Iterative Solution ofLinear

Systems

116

4.5.1 Vector Norms 116

4.5.2 Matrix Norms 118

4.5.2.1

Compatibility

of Vector and Matrix Norms 119 4.5.3 General Iterative Method 120 4.5.3.1

Convergence

of the General IterativeMethod 120 4.5.4

Jacobi

Iteration Method 121 4.5.4.1

Convergence

of the

Jacobi

Iteration Method 122 4.5.5 Gauss-Seidel Iteration Method 125

4.5.5.1

Convergence

of theGauss-Seidel Iteration Method 127 4.5.6 Indirect MethodsversusDirectMethods for

Large Systems

130

4.6

Ill-Conditioning

and Error

Analysis

131

4.6.1 Condition Number 131 4.6.2

Ill-Conditioning

132

4.6.2.1 Indicatorsof

Ill-Conditioning

133

4.6.3

Computational

Error 133 4.6.3.1

Consequences

of

Ill-Conditioning

135

4.6.4 Effectsof Parameter

Changes

onthe Solution 136

4.7

Systems

of Nonlinear

Equations

138

4.7.1 Newton'sMethod fora

System

of Nonlinear

Equations

138

4.7.1.1 Newton'sMethodfor

Solving

a

System

of
(5)

X Contents

4.7.1.2 Newton's Method for

Solving

a

System

ofnNonlinear

Equations

142

4.7.1.3

Convergence

of Newton's Method 142 4.7.2 Fixed-PointIterationMethod fora

System

of Nonlinear

Equations....

143

4.7.2.1

Convergence

of the Fixed-Point Iteration Method 143

ProblemSet

(Chapter

4)

146

5. Curve

Fitting

and

Interpolation

161

5.1

Least-Squares Regression

161

5.2 Linear

Regression

162

5.2.1

Deciding

a"Best" FitCriterion 163

5.2.2 Linear

Least-Squares Regression

164

5.3 Linearization of Nonlinear Data 167 5.3.1

Exponential

Function 167

5.3.2 PowerFunction 167

5.3.3 SaturationFunction 168

5.4

Polynomial Regression

172

5.4.1

Quadratic

Least-Squares Regression

174

5.4.2 Cubic

Least-Squares Regression

176

5.4.3 MATLAB Built-in Functions Polyfit and

Polyval

178

5.5

Polynomial

Interpolation

179

5.5.1

Lagrange Interpolating Polynomials

180 5.5.2 Drawbacks of

Lagrange

Interpolation

183 5.5.3 NewtonDivided-Difference

Interpolating

Polynomials

184

5.5.4

Special

Case:

Equally-Spaced

Data 190

5.5.5 NewtonForward-Difference

Interpolating Polynomials

191

5.6

Spline Interpolation

193

5.6.1 Linear

Splines

194

5.6.2

Quadratic

Splines

195

5.6.2.1 Function Valuesatthe

Endpoints

(2

Equations)

195

5.6.2.2 FunctionValuesattheInterior Knots

(2n

-2

Equations)

196

5.6.2.3 FirstDerivativesatthe Interior Knots

(n

- 1

Equations)

196

5.6.2.4 Second Derivativeatthe Left

Endpoint

is Zero

(1

Equation)....

196

5.6.3 Cubic

Splines

198

5.6.3.1

Clamped Boundary

Conditions 199 5.6.3.2 Free

Boundary

Conditions 199 5.6.4 Construction of Cubic

Splines: Clamped Boundary

Conditions 199 5.6.5 Constructionof Cubic

Splines:

Free

Boundary

Conditions 204 5.6.6 MATLABBuilt-in Functions interpland spline 205 5.6.7

Boundary

Conditions 207

5.6.8 Interactive Curve

Fitting

and

Interpolation

inMATLAB 208 5.7 Fourier

Approximation

and

Interpolation

209 5.7.1 Sinusoidal Curve

Fitting

209 5.7.1.1 Fourier

Approximation

210 5.7.1.2 Fourier

Interpolation

210 5.7.2 Linear Transformationof Data 210 5.7.3 Discrete FourierTransform 215

5.7.4 Fast FourierTransform 216 5.7.4.1

Sande-Tukey Algorithm

(N

=

2?,

p=

integer)

217
(6)

Contents xl

5.7.4.2 Case

Study:

N=23=8 218

5.7.4.3

Cooley-Tukey Algorithm

(N

=

2v,p

=

integer)

219

5.7.5 MATLABBuilt-inFunctionf f t 220 5.7.5.1

Interpolation Using

f f t 220

Problem Set

(Chapter

5)

223

6. NumericalDifferentiationand

Integration

249 6.1 Numerical Differentiation 249 6.2 Finite-DifferenceFormulas for Numerical Differentiation 249 6.2.1 Finite-Difference Formulas for the First Derivative 250 6.2.1.1 Two-PointBackward DifferenceFormula 250

6.2.1.2 Two-Point Forward Difference Formula 251

6.2.1.3 Two-Point Central Difference Formula 251 6.2.1.4 Three-Point BackwardDifference Formula 252

6.2.1.5 Three-Point Forward DifferenceFormula 253

6.2.2 Finite-Difference FormulasfortheSecondDerivative 254

6.2.2.1 Three-Point BackwardDifference Formula 254

6.2.2.2 Three-PointForward Difference Formula 254

6.2.2.3 Three-Point CentralDifference Formula 255

6.2.2.4

Summary

ofFinite-Difference Formulas for Firstto

FourthDerivatives 256

6.2.3 Estimate

Improvement:

Richardson's

Extrapolation

256

6.2.4 Richardson's

Extrapolation

for Discrete Sets of Data 259

6.2.5 Derivative Estimatesfor

Non-Evenly Spaced

Data 259

6.2.6 MATLAB Built-in Functions dif f andpolyder 260

6.3 Numerical

Integration:

Newton-Cotes Formulas 261 6.3.1 Newton-Cotes Formulas 262

6.3.2

Rectangular

Rule 262

6.3.2.1

Composite Rectangular

Rule 262 6.3.3 Error Estimate for

Composite Rectangular

Rule 264 6.3.4

Trapezoidal

Rule 266 6.3.4.1

Composite Trapezoidal

Rule 267 6.3.4.2 Error Estimate for

Composite Trapezoidal

Rule 267

6.3.5

Simpson's

Rules 269

6.3.5.1

Simpson's

1/3 Rule 269 6.3.5.2

Composite Simpson's

1/3Rule 270 6.3.5.3 Error Estimate for

Composite Simpson's

1/3

Rule 270 6.3.5.4

Simpson's

3/8Rule 271 6.3.5.5

Composite

Simpson's

3/8Rule 272 6.3.5.6 Error Estimate for

Composite Simpson's

3/8

Rule 273 6.3.6 MATLAB Built-in Functionsquad andtrapz 273 6.4 Numerical

Integration

of

Analytical

Functions:

Romberg Integration,

Gaussian

Quadrature

275 6.4.1

Romberg Integration

275 6.4.1.1 Richardson's

Extrapolation

275 6.4.1.2

Romberg Integration

278 6.4.2 Gaussian

Quadrature

280 6.5

Improper Integrals

285
(7)

xii Contents

7. Numerical SolutionofInitial-Value Problems 301

7.1 Introduction 301

7.2

One-Step

Methods 301

7.3 Euler'sMethod 302

7.3.1 Error

Analysis

for Euler's Method 305 7.3.2 Calculation of Local and Global Truncation Errors 305

7.3.3

Higher-Order

Taylor

Methods 307

7.4

Runge-Kutta

Methods 309

7.4.1 Second-Order

Runge-Kutta

(RK2)

Methods 310

7.4.1.1

Improved

Euler's Method 311

7.4.1.2 Heun's Method 311

7.4.1.3 Ralston's Method 312 7.4.1.4

Graphical Representation

ofHeun'sMethod 312 7.4.2 Third-Order

Runge-Kutta (RK3)

Methods 315 7.4.2.1 The Classical RK3 Method 315 7.4.2.2 Heun's RK3 Method 315 7.4.3 Fourth-Order

Runge-Kutta

(RK4)

Methods 316 7.4.3.1 The ClassicalRK4 Method 317

7.4.4

Higher-Order Runge-Kutta

Methods 319 7.4.5 Selection of

Optimal Step

Size:

Runge-Kutta Fehlberg (RKF)

Method 320

7.4.5.1

Adjustment

of

Step

Size 321

7.5

Multistep

Methods 322

7.5.1 Adams-Bashforth Method 323

7.5.1.1 Second-Order Adams-Bashforth Formula 324 7.5.1.2 Third-Order Adams-Bashforth Formula 324 7.5.1.3 Fourth-Order Adams-Bashforth Formula 324 7.5.2 Adams-MoultonMethod 325 7.5.2.1 Second-Order Adams-Moulton Formula 326 7.5.2.2 Third-Order Adams-Moulton Formula 326 7.5.2.3 Fourth-OrderAdams-Moulton Formula 326

7.5.3 Predictor-CorrectorMethods 326

7.5.3.1 Heun'sPredictor-Corrector Method 327 7.5.3.2 Adams-Bashforth-Moulton

(ABM)

Predictor-Corrector Method 327

7.6

Systems

of

Ordinary

Differential

Equations

330 7.6.1 Transformation into a

System

ofFirst-OrderODEs 330

7.6.1.1 State Variables 330

7.6.1.2 Notation 330

7.6.1.3 State-Variable

Equations

330 7.6.2 Numerical Solution ofa

System

of First-Order ODEs 332

7.6.2.1 Euler's Method for

Systems

332

7.6.2.2 Heun's Method for

Systems

335

7.6.2.3 Classical RK4 Method for

Systems

336

7.7

Stability

340

7.7.1 Euler's Method 341

7.7.2 Euler's

Implicit

Method 341 7.8 StiffDifferential

Equations

343 7.9 MATLABBuilt-inFunctionsfor

Solving

Initial-ValueProblems 345
(8)

Contents xm

7.9.1 Non-Stiff

Equations

345

7.9.2 A

Single

First-Order IVP 345 7.9.3

Setting

ODESolver

Options

347 7.9.4 A

System

of First-Order IVPs 348

7.9.5 Stiff

Equations

349

Problem Set

(Chapter

7)

350

8. Numerical Solution of

Boundary-Value

Problems 367

8.1 Second-OrderBVP 367

8.2

Boundary

Conditions 367

8.3

Higher-Order

BVP 368

8.4

Shooting

Method 368

8.5 Finite-DifferenceMethod 374

8.5.1

Boundary-Value

Problemswith Mixed

Boundary

Conditions 379

8.6 MATLAB Built-in Functionbvp4cfor

Boundary-Value

Problems 381

8.6.1 Second-OrderBVP 382

Problem Set

(Chapter

8)

386

9. Matrix

Eigenvalue

Problem 393

9.1 Matrix

Eigenvalue

Problem 393

9.2 Power Method: Estimation of the Dominant

Eigenvalue

393

9.2.1 Different Cases of Dominant

Eigenvalue

395

9.2.2

Algorithm

for thePower Method 395

9.3 Inverse Power Method: Estimation of the Smallest

Eigenvalue

398

9.4 Shifted Inverse PowerMethod: Estimation of the

Eigenvalue

Nearesta

Specified

Value 399

9.4.1 NotesontheShifted Inverse PowerMethod 400

9.5 ShiftedPowerMethod 401

9.5.1

Strategy

to EstimateAll

Eigenvalues

ofaMatrix 401

9.6 MATLABBuilt-inFunction e

ig

403

9.7 Deflation Methods 403

9.7.1 Wielandt's Deflation Method 404

9.7.2 DeflationProcess 405 9.8 Householder

Tridiagonalization

and

QR

Factorization Methods 407

9.8.1 Householder's

Tridiagonalization

Method

(Symmetric

Matrices)

408

9.8.2 Determination of

Symmetric Orthogonal

Pk (k

=

1,2,... ,n-2)

409

9.8.3

QR

Factorization Method 411

9.8.4 Determinationof

Qk

and

Rfc

Matrices 412

9.8.5 Structure of

Lk (k

=

2,3,..n)

412

9.9 MATLAB Built-in Functionqr 413

9.10 ANote onthe

Terminating

Condition Usedin HouseholderQR 414 9.11 Transformationto

Hessenberg

Form

(Nonsymmetric

Matrices)

417

Problem Set

(Chapter 9)

418

10. Numerical Solution of Partial Differential

Equations

423

10.1 Introduction 423

10.2

Elliptic

Partial Differential

Equations

424 10.2.1 Dirichlet Problem 424
(9)

xiv Contents

10.2.2

Alternating

Direction

Implicit

(ADI)

Methods 428 10.2.2.1 Peaceman-Rachford

Alternating

Direction

Implicit

(PRADI)

Method 429

10.2.3 Neumann Problem 433 10.2.3.1 Existence ofaSolution for the NeumannProblem 435

10.2.4 Mixed Problem 436

10.2.5 More

Complex Regions

437

10.3 Parabolic Partial Differential

Equations

440 10.3.1 Finite-Difference Method 440

10.3.1.1

Stability

and

Convergence

of the Finite-Difference

Method 441

10.3.2 Crank-Nicolson Method 443

10.3.2.1 Crank-Nicolson

(CN)

MethodversusFinite-Difference

(FD)

Method 446

10.4

Hyperbolic

PartialDifferential

Equations

448

10.4.1

Starting

the Procedure 449 Problem Set

(Chapter

10)

452

References

Related documents

I used a water-soluble colored pencil on areas like the handrail and pathway to make sure they re- ally popped.” When working on a white sur- face, Averill uses the corner of a f

Join with DB Component joins records from the flow or flows connected to its in port with records read directly from a database, and outputs new records containing data based

University counsel pointed to the cost of the stamp and seal, the accuracy with which the items ordered resembled the official versions and the fact that Mar King reached out to

In the United States, adaptations of animated films and television series was a less of a phenomenon, with the notable exceptions of games based on Disney characters (of which

With standard fire interface, wing open for evacuation even power is not cut off when fire alarm triggered, memory can be set, swipe cards several times for group pass.. Fast

In the Warp Speed Fat Loss Nutrition Manual, Mike will go into more detail about how you can use diet to further guarantee that you do not lose one ounce of muscle while on the

Por lo tanto, es al mismo tiempo como el pensamiento re­ clama, ante el aspecto nuevo y sin embargo inasignable de los datos, la revelación de lazos específicos que nos digan en

• Although ordinary PN junction diodes exhibit the variable capacitance effect and these diodes can be used for this applications, special diodes optimized to give the required