|
Preface |
7 |
|
|
Why Do We Need Numerical Methods? |
8 |
|
|
The Structure of This Text |
8 |
|
|
Contents |
11 |
|
|
1 Simple Calculations with MATLAB |
16 |
|
|
1.1 Introduction and a Word of Warning |
16 |
|
|
1.2 Scalar Quantities and Variables |
17 |
|
|
1.2.1 Rules for Naming of Variables |
19 |
|
|
1.2.2 Precedence: The Order in Which Calculations Are Performed |
20 |
|
|
1.2.3 Mathematical Functions |
23 |
|
|
1.3 Format: The Way in Which Numbers Appear |
27 |
|
|
1.4 Vectors in MATLAB |
28 |
|
|
1.4.1 Initialising Vector Objects |
28 |
|
|
1.4.2 Manipulating Vectors and Dot Arithmetic |
29 |
|
|
1.5 Setting Up Mathematical Functions |
32 |
|
|
1.6 Some MATLAB Speci.c Commands |
35 |
|
|
1.6.1 Looking at Variables and Their Sizes |
37 |
|
|
1.7 Accessing Elements of Arrays |
38 |
|
|
1.8 Tasks |
39 |
|
|
2 Writing Scripts and Functions |
42 |
|
|
2.1 Creating Scripts and Functions |
42 |
|
|
2.1.1 Functions |
45 |
|
|
2.1.2 Brief Aside |
50 |
|
|
2.2 Plotting Simple Functions |
51 |
|
|
2.2.1 Evaluating Polynomials and Plotting Curves |
56 |
|
|
2.2.2 More on Plotting |
59 |
|
|
2.3 Functions of Functions |
64 |
|
|
2.4 Errors |
66 |
|
|
2.4.1 Numerical Errors |
66 |
|
|
2.4.2 User Error |
69 |
|
|
2.5 Tasks |
72 |
|
|
3 Loops and Conditional Statements |
78 |
|
|
3.1 Introduction |
78 |
|
|
3.2 Loops Structures |
78 |
|
|
3.3 Summing Series |
83 |
|
|
3.3.1 Sums of Series of the Form |
88 |
|
|
3.3.2 Summing In.nite Series |
91 |
|
|
3.3.3 Summing Series Using MATLAB Speci.c Commands |
94 |
|
|
3.3.4 Loops Within Loops (Nested) |
97 |
|
|
3.4 Conditional Statements |
98 |
|
|
3.4.1 Constructing Logical Statements |
100 |
|
|
3.4.2 The MATLAB Command |
103 |
|
|
3.5 Conditional loops |
105 |
|
|
3.5.1 The break Command |
107 |
|
|
3.6 MATLAB Speci.c Commands |
107 |
|
|
3.7 Error Checking |
109 |
|
|
3.8 Tasks |
112 |
|
|
4 Root Finding |
118 |
|
|
4.1 Introduction |
118 |
|
|
4.2 Initial Estimates |
119 |
|
|
4.3 Fixed Point Iteration |
124 |
|
|
4.4 Bisection |
128 |
|
|
4.5 Newton–Raphson and Secant Methods |
132 |
|
|
4.5.1 Derivation of the Newton–Raphson Method |
132 |
|
|
4.6 Repeated Roots of Functions |
138 |
|
|
4.7 Zeros of Higher-Dimensional Functions(*) |
140 |
|
|
4.8 MATLAB Routines for Finding Zeros |
143 |
|
|
4.8.1 Roots of a Polynomial |
143 |
|
|
4.8.2 The Command |
143 |
|
|
4.9 Tasks |
145 |
|
|
5 Interpolation and Extrapolation |
148 |
|
|
5.1 Introduction |
148 |
|
|
5.2 Saving and Reading Data |
149 |
|
|
5.3 Which Points to Use? |
154 |
|
|
5.4 Newton Forward Differences and Lagrange Polynomials |
156 |
|
|
5.4.1 Linear Interpolation/Extrapolation |
162 |
|
|
5.5 Calculating Interpolated and Extrapolated Values |
163 |
|
|
5.6 Splines |
165 |
|
|
5.7 Curves of Best Fit |
167 |
|
|
5.8 Interpolation of Non-Smooth Data |
170 |
|
|
5.8.1 Insufficient Data Points |
173 |
|
|
5.9 Minimisation of Functions and Parameter Retrieval |
176 |
|
|
5.9.1 Parameter Retrieval |
178 |
|
|
5.9.2 Using fmins for Parameter Retrieval |
179 |
|
|
5.10 Tasks |
181 |
|
|
6 Matrices |
184 |
|
|
6.1 Introduction |
184 |
|
|
6.1.1 Initialising Matrices Within MATLAB |
184 |
|
|
6.1.2 Matrix Operations |
189 |
|
|
6.1.3 Operations on Elements of Matrices |
195 |
|
|
6.1.4 More on Special Matrices |
197 |
|
|
6.1.5 Matrices Containing Strings |
200 |
|
|
6.2 Properties of Matrices and Systems of Equations |
201 |
|
|
6.2.1 Determinants of Matrices |
205 |
|
|
6.3 Elementary Row Operations |
206 |
|
|
6.3.1 Solving Many Equations at Once |
213 |
|
|
6.4 Matrix Decomposition |
214 |
|
|
6.5 Eigenvalues and Eigenvectors |
219 |
|
|
6.6 Speci.c MATLAB Commands |
223 |
|
|
6.7 Characteristic Polynomials |
227 |
|
|
6.8 Exponentials of Matrices |
229 |
|
|
6.9 Tasks |
232 |
|
|
7 Numerical Integration |
240 |
|
|
7.1 Introduction |
240 |
|
|
7.2 Integration Using Straight Lines |
241 |
|
|
7.2.1 Errors in the Trapezium Method |
244 |
|
|
7.3 Integration Using Quadratics |
245 |
|
|
7.4 Integration Using Cubic Polynomials |
250 |
|
|
7.5 Integrating Using MATLAB Commands |
252 |
|
|
7.6 Speci.c Examples of Integrals |
253 |
|
|
7.6.1 Infinite Integrals and Removable Singularities |
253 |
|
|
7.6.2 Indefinite Integrals |
255 |
|
|
7.7 Tasks |
257 |
|
|
8 Solving Differential Equations |
262 |
|
|
8.1 Introduction |
262 |
|
|
8.2 Euler’s Method and Crank–Nicolson |
262 |
|
|
8.2.1 Analytical Comparisons |
268 |
|
|
8.3 Banded Matrices |
274 |
|
|
8.4 Runge–Kutta Methods |
278 |
|
|
8.5 Higher-Order Systems |
281 |
|
|
8.5.1 Second-Order Systems |
281 |
|
|
8.5.2 Bessel’s equation |
285 |
|
|
8.5.3 Airy’s Equation |
288 |
|
|
8.5.4 Shooting Methods |
289 |
|
|
8.6 Boundary-Value Problems |
293 |
|
|
8.7 Population Dynamics |
297 |
|
|
8.8 Eigenvalues of Di.erential Systems |
300 |
|
|
8.9 Tasks |
301 |
|
|
9 Simulations and Random Numbers |
306 |
|
|
9.1 Introduction |
306 |
|
|
9.2 Statistical quantities |
306 |
|
|
9.2.1 Averages |
306 |
|
|
9.2.2 Other Statistical Measures |
308 |
|
|
9.3 Random Numbers and Distributions |
310 |
|
|
9.3.1 Normal Distribution |
313 |
|
|
9.3.2 Calculating Probabilities |
314 |
|
|
9.3.3 Permutations |
315 |
|
|
9.4 Maps and White Noise |
315 |
|
|
9.4.1 Modelling Discrete Systems |
322 |
|
|
9.4.2 Periodicity and Chaos |
324 |
|
|
9.4.3 Random Motion |
331 |
|
|
9.5 Tasks |
334 |
|
|
A Mathematical Introduction to Matrices |
338 |
|
|
A.1 Special Matrices |
345 |
|
|
A.2 Inverses of Matrices |
346 |
|
|
B Glossary of Useful Terms |
350 |
|
|
B.1 Arithmetic and Logical Operators |
350 |
|
|
B.2 Symbols |
358 |
|
|
B.3 Plotting Commands |
362 |
|
|
B.4 General MATLAB Commands |
380 |
|
|
C Solutions to Tasks |
404 |
|
|
C.1 Solutions for Tasks from Chapter 1 |
404 |
|
|
C.2 Solutions for Tasks from Chapter 2 |
409 |
|
|
C.3 Solutions for Tasks from Chapter 3 |
415 |
|
|
C.4 Solutions for Tasks from Chapter 4 |
423 |
|
|
C.5 Solutions for Tasks from Chapter 5 |
429 |
|
|
C.6 Solutions for Tasks from Chapter 6 |
433 |
|
|
C.7 Solutions for Tasks from Chapter 7 |
444 |
|
|
C.8 Solutions for Tasks from Chapter 8 |
451 |
|
|
C.9 Solutions for Tasks from Chapter 9 |
469 |
|
|
Index |
474 |
|
|
More eBook at www.ciando.com |
0 |
|