Professional Documents
Culture Documents
Forelesn Kap4
Forelesn Kap4
v − ∆t g(v) = c, (3)
where c is given.
Lectures INF2320 – p. 2/88
Nonlinear algebraic equations
First consider the case of g(u) = u, which corresponds to
the differential equation
u0 = u, u(0) = u0 . (4)
v − ∆t v = c, (5)
g(v) = α + βv (8)
c + α∆t
v = . (9)
1 − β∆t
u0 = u2 , (10)
g(v) = v2 . (11)
v − ∆t v2 = c. (12)
v − ∆t g(v) = c (18)
g(v) = v (19)
or
g(v) = v2 . (20)
f (x) = 0, (23)
f (x) = 2 + x − ex (24)
f (x∗ ) = 0
x* x=3
0
−5 f(x)
y
−10
−15
−20
0 0.5 1 1.5 2 2.5 3 3.5
x
x0 = 0 and x1 = 3
• Note that f (x0 ) = f (0) > 0 and f (x1 ) = f (3) < 0, and
therefore x0 < x∗ < x1 , provided that f is continuous
• We now define the mean value of x0 and x1
1 3
x2 = (x0 + x1 ) =
2 2
Lectures INF2320 – p. 13/88
5
x2=1.5 x1=3
0
x =0
0
−5
y
−10
−15
−20
0 0.5 1 1.5 2 2.5 3 3.5
x
0.5
x2=1.5
0
x =0.75
3
−0.5
y
−1
−1.5
−2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
x
f (x) = 2 + x − ex
f (x0 ) + h f 0 (x0 ) = 0
f (x0 )
h=− 0
f (x0 )
• We therefore define
def f (x0 )
x1 = x0 + h = x0 − 0 (27)
f (x0 )
f 0 (x) = 1 − ex
• Therefore
f (x0 ) 5 − e3
x1 = x0 − 0 = 3− 3
= 2.2096
f (x0 ) 1−e
• We see that
def f (x1 )
x2 = x1 − 0 , (28)
f (x1 )
f (x) = x2 − 2,
xk2 − 2
xk+1 = xk −
2xk
• or
xk2 + 2
xk+1 =
2xk
Lectures INF2320 – p. 28/88
Example 12
If we choose x0 = 1, we get
x1 = 1.5,
x2 = 1.41667,
x3 = 1.41422.
f (x0 )
x1 = x0 − 0 ,
f (x0 )
f (x1 )
x2 = x1 − 0
f (x1 )
Lectures INF2320 – p. 31/88
An alternative derivation
• Generally we get
f (xk )
xk+1 = xk − 0
f (xk )
• This process is illustrated in Figure 4
f (x1 ) − f (x0 )
F0 (x) = f (x1 ) + (x − x1 )
x1 − x0
• F0 (x) is called the linear interpolant of f
F(x2 ) = 0
f (x1 )(x1 − x0 )
x2 = x1 −
f (x1 ) − f (x0 )
x
x x x
f x
Figure 5: The figure shows a function f = f (x) and its linear in-
terpolant F between x0 and x1 .
f (x) = 2 + x − ex = 0,
f (x) = x2 − 2,
∗
√
which has a solution x = 2.
• The general step of the secant method is in this case
xk − xk−1
xk+1 =xk − f (xk )
f (xk ) − f (xk−1 )
2 xk − xk−1
=xk − (xk − 2) 2 2
xk − xk−1
xk2 − 2
=xk −
xk + xk−1
xk xk−1 + 2
=
xk + xk−1
Lectures INF2320 – p. 40/88
Example 14
• By choosing x0 = 1 and x1 = 2 we get
x2 = 1.33333
x3 = 1.40000
x4 = 1.41463
un+1 − ∆t g(un+1 ) = un ,
v − ∆t g(v) = c.
v = h(v), (29)
where
v∗ = h(v∗ ).
vk+1 = h(vk ),
x = sin(x/10),
x1 = 0.09983,
x2 = 0.00998,
x3 = 0.00099,
y = sin(x/10)
−10π 10π-x
sin(x/10) ≈ x/10.
xk+1 ≈ xk /10,
and therefore
xk ≈ (1/10)k .
vk+1 = h(vk )
x = sin(x/10)
and
ek+1 = |vk+1 − v∗ |
= |h(vk ) − h(v∗ )|
≤δ |vk − v∗ |
=δ ek .
ek ≤ δk e0 .
lim vk = v∗ .
k→∞
v∗ = h(v∗ )?
b) If so, is v∗ unique?
c) How can we compute v∗ ?
We assume that h is a contractive mapping on a closed
interval I such that
for all v, w.
Lectures INF2320 – p. 53/88
Uniqueness
Assume that we have two solutions v∗ and w∗ of the
problem, i.e.
|v∗ − w∗ | ≤ δ |v∗ − w∗ |
h(v) = v (35)
|vn+1 − vn | ≤ δn |v1 − v0 |
• In order to show that {vn } is a Cauchy sequence, we
need to bind |vm − vn |
• We may assume that m > n, and we see that
δ
m−1
+δ
m−2
+...+δ n
= δ n−1
δ+δ +...+δ
2 m−n
∞
≤ δn−1 ∑ δk
k=1
1
= δ n−1
1−δ
• So
δn−1
|vm − vn | ≤ |v1 − v0 |
1−δ
• δn−1 can be as small as you like, if you choose n big
enough
Lectures INF2320 – p. 59/88
Existence
This means that for any ε > 0, we can find an integer M
such that
|vm − vn | < ε
un+1 + ∆t vn+1 = un ,
(39)
−∆t un+1 + vn+1 = vn .
Lectures INF2320 – p. 61/88
Systems of linear equations
We can write this system on the form
Awn+1 = wn , (40)
where
! !
1 ∆t un
A = and wn = . (41)
−∆t 1 vn
Therefore we get
! ! !
un+1 1 1 −∆t un
= (44)
vn+1 1 + ∆t 2 ∆t 1 vn
!
1 un − ∆t vn
= . (45)
1 + ∆t 2 ∆t un + vn
1+∆t 2 (un − ∆t vn ),
1
un+1 =
(46)
1+∆t 2 (vn + ∆t un ).
1
vn+1 =
0.8
0.6
0.4
0.2
−0.2
−0.4
−0.6
−0.8
−1
0 1 2 3 4 5 6
t
u0 = −v3 , u(0) = u0 ,
(48)
v0 = u3 , v(0) = v0 .
un+1 + ∆t v3n+1 − un = 0,
(50)
vn+1 − ∆t u3n+1 − vn = 0.
f (x, y) = 0,
(51)
g(x, y) = 0.
f (x, y) = x + ∆t y3 − α,
(52)
g(x, y) = y − ∆t x3 − β,
α = un and β = vn .
Lectures INF2320 – p. 67/88
Newton’s method
When deriving Newton’s method for solving a scalar
equation
p(x) = 0 (53)
p(xk )
xk+1 = xk − 0 . (55)
p (xk )
f (x, y) = 0,
(56)
g(x, y) = 0.
∂F ∂F
F(x + ∆x, y + ∆y) = F(x, y) + ∆x (x, y) + ∆y (x, y)
∂x ∂y
+O (∆x2 , ∆x∆y, ∆y2). (57)
∂f ∂f
f (x0 + ∆x, y0 + ∆y) = f (x0 , y0 ) + ∆x (x0 , y0 ) + ∆y (x0 , y0 )
∂x ∂y
+O (∆x2 , ∆x∆y, ∆y2), (58)
and
∂g ∂g
g(x0 + ∆x, y0 + ∆y) = g(x0 , y0 ) + ∆x (x0 , y0 ) + ∆y (x0 , y0 )
∂x ∂y
+O (∆x2 , ∆x∆y, ∆y2). (59)
∂ f0 ∂f
where f0 = f (x0 , y0 ), g0 = g(x0 , y0 ), ∂x = ∂x (x0 , y0 ), etc. If the
matrix
∂ f0 ∂ f0
!
∂x ∂y
A = ∂g0 ∂g0 (63)
∂x ∂y
is nonsingular. Then
!−1
∂ f0 ∂ f0
! !
∆x ∂x ∂y f0
= − ∂g0 ∂g0 . (64)
∆y ∂x ∂y
g0
Lectures INF2320 – p. 72/88
Newton’s method
We can now define
!−1
∂ f0 ∂ f0
! ! ! ! !
x1 x0 ∆x x0 ∂x ∂y f0
= + = − ∂g0 ∂g0 .
y1 y0 ∆y y0 ∂x ∂y
g0
ex − ey = 0,
(66)
ln(1 + x + y) = 0.
f (x, y) = ex − ey ,
g(x, y) = ln(1 + x + y).
f (x, y) = 0,
(68)
g(x, y) = 0,
where
f (x, y) = x + ∆t y3 − α,
(69)
g(x, y) = y − ∆t x3 − β.
where
fk = f (xk , yk ), gk = g(xk , yk ),
∂ fk ∂ f ∂ fk ∂ f
= (xk , yk ) = 1, = (xk , yk ) = 3∆t y2k ,
∂x ∂x ∂y ∂y
∂gk ∂g ∂gk ∂g
= (xk , yk ) = −3∆t xk2 , = (xk , yk ) = 1.
∂x ∂x ∂y ∂y
has its determinant given by: det(A) = 1 + 9∆t 2 xk2 y2k > 0. So
A−1 is well defined and is given by
!
2
1 1 −3∆t y
A−1 = 2 2 2 2
k
. (72)
1 + 9∆t xk yk 3∆t xk 1
0.9
0.8
0.7
0.6
0.5
0.4
0.3
0.2
0.1
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
t
Figure 8: The numerical solutions u(t) and v(t) (in dashed line) of
(48) produced by the implicit Euler scheme (49) using u0 = 1, v0 = 0
and ∆t = 1/100.
Lectures INF2320 – p. 80/88
0.8
0.6
0.4
0.2
0
0.8 0.9 1
u
2.5
1.5
0.5
0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
t