Metode Euler
Metode Euler
Metode Numerik
Genap 2022/2023
Euler’s Method: Tangent Line Approximation
• Recall that a first order initial value problem has the form
dy
f (t , y ), y (t0 ) y0
dt
y f (t , y ), y (t0 ) y0 ,
an alternative is to compute approximate values
of the solution y = (t) at a selected set of t-
values.
› Ideally, the approximate solution values will be
accompanied by error bounds that ensure the
level of accuracy.
› There are many numerical methods that
produce numerical approximations to solutions
of differential equations. Euler, Léonard
› In this section, we examine the tangent line 1707-1783
method, which is also called Euler’s Method.
Euler’s Method: Tangent Line Approximation
• For the initial value problem y f (t , y ), y (t0 ) y0 ,
we begin by approximating solution y = (t) at initial point t0.
• The solution passes through initial point (t0, y0) with slope
f (t0, y0).
y y0 f t0 , y0 t t0
• The line tangent to solution at initial point is thus
• The tangent line is a good approximation to solution curve on an
interval short enough.
• Thus if t1 is close enough to t0,
we can approximate (t1) by
y1 y0 f t0 , y0 t1 t0
Euler’s Formula
› For a point t2 close to t1, we approximate (t2) using the line
passing through (t1, y1) with slope f (t1, y1):
y2 y1 f t1 , y1 t 2 t1
› Thus we create a sequence yn of approximations to (tn):
y1 y0 f 0 t1 t0
y2 y1 f1 t 2 t1
yn 1 yn f n t n 1 t n
or
f t , (t ) dt
t n 1
(t n 1 ) (t n )
tn
› Replacing (tn+1) and (tn) by their approximate values yn+1 and yn,
we obtain Euler’s formula:
yn 1 yn f (t n , yn ) t n 1 tn , n 0,1, 2,
(t n 1 ) (t n ) f t n , (t n ) t n 1 t n
yn 1 yn f (t n , yn ) t n 1 t n , n 0,1, 2,
Euler Methods: Taylor Series
› A third approach is to assume the solution y = (t) has a Taylor
series about t = tn. Then
1
(t ) (tn ) (t n ) t t n (t n ) t t n 2
2!
› Since h = tn+1 – tn and ' = f (t, ), it follows that
1
(t n 1 ) (t n ) f t n , (t n ) h (t n )h 2
2!
› If the series is terminated after the first two terms, and if we replace
(tn+1) and (tn) by their approximations yn+1 and yn, then once again
we obtain Euler’s formula:
yn 1 yn f (t n , yn ) t n 1 t n , n 0,1, 2,
› Further, using a Taylor series with remainder, we can estimate the
magnitude of error in this formula (later in this section).
Example 1: Euler’s Method
› For the initial value problem
y 9.8 0.2 y, y (0) 0
we can use Euler’s method with h = 0.1 to
approximate the solution at t = 0.1, 0.2, 0.3, 0.4, as
shown
y1 below.
y0 f 0 h 0 9.8(0.1) .98
y2 y1 f1 h .98 9.8 0.2 .98(0.1) 1.94
y3 y2 f 2 h 1.94 9.8 0.2 1.94(0.1) 2.88
y4 y3 f 3 h 2.88 9.8 0.2 2.88(0.1) 3.80
We can find the exact solution to our IVP
y 9.8 0.2 y, y (0) 0
y 0.2 y 49
dy
0.2dt
y 49
ln y 49 0.2t C
y 49 ke 0.2t , k e C
y (0) 1 k 49
y 491 e 0.2t
Example 1: Error Analysis
› From table below, we see that the errors are small.
› This is most likely due to round-off error and the fact that the exact
solution is approximately linear on [0, 0.4].
› Note: yexact yapprox
Percent Relative Error 100
yexact
› Exact solution 7 1 11
y t e 2t
4 2 4
Example 2: Error Analysis
› The first ten Euler approxs are given in table below on left. A table of
approximations for t = 0, 1, 2, 3 is given on right. (Find for numerical
results with h = 0.05, 0.025, 0.01).
› The errors are small initially, but quickly reach an unacceptable level.
This suggests a nonlinear solution.
t Exact y Approx y Error % Rel Error t Exact y Approx y Error % Rel Error
0.00 1.00 1.00 0.00 0.00 0.00 1.00 1.00 0.00 0.00
0.10 1.66 1.60 0.06 3.55 1.00 19.07 15.78 3.29 17.27
0.20 2.45 2.31 0.14 5.81 2.00 149.39 104.68 44.72 29.93
0.30 3.41 3.15 0.26 7.59 3.00 1109.18 652.53 456.64 41.17
0.40 4.57 4.15 0.42 9.14 4.00 8197.88 4042.12 4155.76 50.69
0.50 5.98 5.34 0.63 10.58
0.60 7.68 6.76 0.92 11.96
0.70 9.75 8.45 1.30 13.31 Exact Solution :
0.80 12.27 10.47 1.80 14.64 7 1 11
0.90 15.34 12.89 2.45 15.96 y t e 2t
1.00 19.07 15.78 3.29 17.27
4 2 4
Example 2: Error Analysis & Graphs
7 1 11 2t
Exact Solution : y t e
4 2 4
Example 2: Error Analysis & Graphs
The exact solution (red) plotted together with the Euler
approximation (blue).
exact
solution
exact
solution
Euler app.
Euler app.
Example 3:
dy
x y; y (0) 0
dx
a) Tentukan y(0.1) dengan langkah h = 0.02 dan h = 0.05 .
b) Jika diketahui
langkah mana yang lebih teliti ?
y ( x) e x x 1
19
h = 0.05
x=0 y(0) = 0
x = 0.05 y(0.05) = 0 + 0.05(0+0) = 0
x = 0.1 y(0.1) = 0 + 0.05(0.05+0) = 0.0025
h = 0.02
x=0 y(0) = 0
x = 0.02 y(0.02) = 0 + 0.02(0+0) = 0
x = 0.04 y(0.04) = 0 + 0.02(0.02+0) = 0.0004
x = 0.06 y(0.06) = 0.004 +0.02(0.04+0.004) = 0.001208
x = 0.08 y(0.08) = 0.001208 +0.02(0.06+0.001208) = 0.00243216
x = 0.1 y(0.1) = 0.00243216 + 0.02(0.08+0.00243216)
= 0.0040808032
y(0.1) = e0.1-0.1-1 = 0.00517091807564762
Langkah h = 0.02 lebih teliti
20
Nilai hanya bergantung pada nilai-nilai
dan nilai . Dengan menggunakan syarat awal
nilai-nilai fungsi untuk
i = 1,2,3,… dapat ditentukan.
kesalahan pemotongan
2
lokal orde keduaO(h )
kesalahan pemotongan global O(h)
21
Besar dan sifat kesalahan pemotongan pada metode Euler dapat dijelaskan
dari deret Taylor.
y1 y0 f ( x0 , y0 )x
Think in
terms of
Taylor’s If the true solution were a straight line, then
expansion Euler is exact
24
Error Analysis
(From Taylor’s Expansion)
y ( x ) f ( x , y ) x d
dx f ( x, y ) x 2
2
Euler’s
Euler’s truncation error
O(x2) per step
25
Cumulative Error
y
x
Remark:
x=0 x Error
x=T
But computation time
2 1 1 1
3 2 2 2
5
dan seterusnya.
28
Euler kesalahan
t eksak
eksplisit mutlak -1
0.0 -2.000 -2.000 0.000
0.1 -1.900 -1.900 0.000 -1.2
0.2 -1.801 -1.803 0.002 -1.4
0.3 -1.705 -1.709 0.004
y
0.4 -1.614 -1.620 0.006 -1.6
0.5 -1.529 -1.538 0.009
-1.8
0.6 -1.451 -1.463 0.012
0.7 -1.381 -1.396 0.015 -2
0.8 -1.319 -1.336 0.017 0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
t
0.9 -1.266 -1.284 0.018
1.0 -1.220 -1.238 0.019
0.02
1.1 -1.180 -1.200 0.019
1.2 -1.148 -1.166 0.019
0.015
1.3 -1.120 -1.138 0.018
1.4 -1.098 -1.115 0.017
0.01
e rro r
1.5 -1.079 -1.095 0.016
1.6 -1.064 -1.078 0.014
1.7 -1.052 -1.065 0.013 0.005
1.8 -1.041 -1.053 0.012
1.9 -1.033 -1.044 0.010 0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
2.0 -1.027 -1.036 0.009 t
Backward Euler Formula
• The backward Euler formula is derived as follows. Let y = (t) be the
solution of y' = f (t, y). At t = tn, we have
f t n , (t n )
• Using a backward difference quotient for ', it follows that
(tn ) (t n 1 )
f t n , (t n )
t n t n 1
• Replacing (tn) and (tn -1) by their approximations yn and yn-1, and solving
for yn, we obtain the backward Euler formula
yn yn 1 f (t n , yn ) h yn 1 yn f (t n 1 , yn 1 ) h
• Note that this equation implicitly defines yn+1, and must be solved in
order to determine the value of yn+1.
Metode Euler implisit juga dapat diturunkan melalui deret Taylor
:
2
′ ′′
𝑖−1 𝑖 𝑖 𝑖
′
(suku orde kedua
dihilangkan)
, dengan i = 1,2,3,.......
31
Skema yang implisit :
nilai bergantung pada nilai-nilai dan
nilai
32
Metode Euler implisit diturunkan dari deret Taylor
dengan membuang suku orde dua
33
0.02
0.018
0.016
0.014
0.012
0.01
0.008
0.006
0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
t