Professional Documents
Culture Documents
Chapter 1
Chapter 1
INTRODUCTION
Differentiation (I)
• Product rule
(fg )0 = f 0 g + g 0 f .
so
(fgh)0 = f 0 (gh) + (gh)0 f = f 0 gh + g 0 hf + h0 gf .
Example
d
(x − x1 )(x − x2 )(x − x3 ) = (x − x2 )(x − x3 ) + (x − x1 )(x − x3 )
dx
+(x − x1 )(x − x2 ).
Differentiation (II)
n
Y
(x − xi ) = (x − x1 )(x − x2 ) . . . (x − xn ).
i=1
Then
n
d Y
(x − xi ) = (x − x2 )(x − x3 ) . . . (x − xn ) +
dx
i=1
(x − x1 )(x − x3 ) . . . (x − xn ) + . . . +
(x − x1 )(x − x2 ) . . . (x − xi−1 )(x − xi+1 ) . . . (x − xn ) + . . .
+(x − x1 )(x − x2 ) . . . (x − xn−1 ).
O notation (I)
|p| ≤ C |h|.
Examples: 2h = O(h).
If |h| < 1 then |h2 | < |h|, |h3 | < |h2 |, ....Then
so ah + bh2 is O(h).
Taylor expansion (I)
x2 x3
ln(1 + x) = x − + − ...;
2 3
this holds for |x| < 1 i.e. a = 1.
There are tests to determine the radius of convergence, but this is
beyond the scope of this course.
Taylor expansion (III)
f (x0 ), f (x0 )+f 0 (x0 )(x−x0 ), f (x0 )+f 0 (x0 )(x−x0 )+(f 00 (x0 )/2)(x−x0 )2 , . . .
Definition of integration:
• Example:
Z 1 1
x x
e dx = e = e − 1 = 1.718281828.
0 0
But for Z 1
2
e x dx,
0
we cannot find it exactly. We will need to find approximations.
Dividing [0, 1] into three intervals [0, 1/3], [1/3, 2/3] and [2/3, 1],
and pick up ξ1 = 1/6, ξ2 = 1/2 and ξ3 = 5/6, then
Z 1
2
e x ≈ 1.43826
0
About numerical analysis (III)
The more points we take, the better. To illustrate this, consider
another simple example
Z 1
x 2 dx = 1/3 = 0.333333.
0
Later on, we will see that it is better that these lengths are not
equal, and we have special ways to choose ξi .
if we only know f (x) and f 0 (x) and nothing else, we can say that
f (x) + f 0 (x)h approximates f (x + h) with the error
e = f (x + h) − [f (x) + f 0 (x)h],
Floating point number: for chopping we just take the first k digits:
0.d1 d2 . . . dk × 10n .
• Solve ax 2 + bx + c = 0, a = 1, b = 62.1, c = 1.
The exact roots are
√ √
−b + b 2 − 4ac −b − b 2 − 4ac
x1 = , x2 = ,
2a 2a
i.e. x1 = −0.01610723, x2 = −62.08390.
√ √
• Taking 4 digits: b 2 − 4ac = 3852 = 62.06.
so
−62.1 + 62.06
x1 = = −0.0200.
2
We have lost some accuracy.
√ √
If we take 6 digits, i.e. b 2 − 4ac = 3852.41 = 62.0678, then
x1 = (−62.1 + 62.0678)/2 = −0.016100.
Reformulate to avoid loss of accuracy due to rounding off
We can rewrite x1 √
as (by multiplying both the denominator and
numerator by b + b 2 − 4ac)
−2c
x1 = √ .
b + b 2 − 4ac
√ √
Then if we only take 4 digits: b 2 − 4ac = 3852 = 62.06, then
−2.000
x1 = = −0.01611.
62.10 + 62.06
Algorithm
• Algorithm:
Step 1: INPUT N, x1 , x2 ,. . . , xN .
Step 2: Set SUM = 0.
Step 3: For i = 1, 2, . . . , N
Set SUM = SUM + xi .
Step 4: OUTPUT SUM.
|αn − α| ≤ K |βn |,
Consider
n2 + n + 1
αn = .
n2
Then αn → 1 as n → ∞.
n+1 1 1 2
|αn − 1| = 2
= + 2 ≤ ,
n n n n
so |αn − 1| = O(1/n) – the rate of convergence is O(1/n).
Consider
n3 + n + 1
α̂n = .
n3
Then
n+1 1 1 2
|α̂n − 1| = 3
= 2 + 3 ≤ 2.
n n n n
The rate of convergence is O(1/n2 ).
Rate of convergence (III)
For functions: Suppose that limh→0 G (h) = 0 and
limh→0 F (h) = L. If there is a positive constant K such that
|F (h) − L| ≤ K |G (h)|,
then we say that F (h) converges to L with the rate O(G (h)).
f 00 (0) 2 K
|f (h) − [f (0) + f 0 (0)h + h ]| ≤ |h3 |.
2 6
so f (h) − f 0 (0)h − (f 00 (0)/2)h2 converges to f (0) with the rate
O(h3 ).