Chapter 2 A Survey of Simple Methods and Tools
2.1 Horner’s Rule and Nested Multiplication For example
Horner’s rule for polynomial evaluation 多項式最高次項的係數 多項式的係數
Horner’s rule for polynomial derivative evaluation Polynomial first derivative: For example:
Horner’s rule for polynomial derivative evaluation
A more efficient implementation of Horner’s rule If the intermediate values in the computation of p (x) are saved, then the subsequent computation of the derivative can be done more cheaply. Define So that Then and, in particular, Define Therefore Since 注意bk亦為x的函數
2.2 Difference Approximations to the Derivative—one-side difference The definition of the derivative: Taylor’s Theorem: So that we have Thus the error is roughly proportional to h. Can we do better?
2.2 Difference Approximations to the Derivative—centered difference Consider the two Taylor expansions:
Example 2.1
Further illustrate these differences in accuracy Let’s continue computing with the same example, but take more and smaller values of h. Let with the corresponding errors
Nearly 4 Error increase. why?
Rounding Error Let denote the function computation as actually done on the computer. Define as the error between the function as computed in infinite precision and as actually computed on the machine. The approximate derivative that we compute is constructed with , not f. Define
Rounding Error We have which we write as
Rounding Error
Nearly 4
2.3 Application: Euler’s Method for Initial Value Problems General form: One-side difference (Eq. 2.1) Euler’s method
Example 2.2
2.4 Linear Interpolation Given a set of nodes xk, if for all k, then we say the function p interpolates the function f at these nodes. Linear interpolation: using a straight line to approximate a given function For example: the equation of a straight line that passes through the two points
The accuracy of linear interpolation
Example 2.3 f (0.2) f (0.1)
Piecewise linear interpolation Example 4.2
2.5 Application: the trapezoid rule Define the integration of interest as I(f ):
Error analysis Apply the Integral Mean Value Theorem thus
The n-subinterval trapezoid rule
This theorem tells us: The numerical approximation will converge to the exact value How fast this convergence occurs h 2
Example 2.5
Example 2.6
The stability of the trapezoid rule We conclude that the trapezoid rule is a stable numerical method. In fact, almost all methods for numerically approximating integrals are stable.
2.6 Solution of tri-diagonal linear systems
If A is tri-diagonal, then For example:
Make a notational simplification: where Then the augmented matrix corresponding to the system is
Gaussian elimination The elimination step where The backward solution step
Example 2.7
After a single pass through the first loop: We cannot continue the process, for we would have to divide by zero in the next step. However, the solution of the system indeed exist:
Diagonal dominance for tri-diagonal matrices For example
2.7 Application: Simple Two-point Boundary Value Problems Two-point boundary value problem (BVP)
Use Taylor expansions similar to (2. 2) and (2 Use Taylor expansions similar to (2.2) and (2.3) (just take more terms) to derive an approximation to the second derivative, by adding them. Then we get This is a tri-diagonal system of linear equations.
In matrix-vector form It is diagonally dominant, so we can apply the algorithm developed in the precious section to produce solutions.
Example 2.8