0% found this document useful (0 votes)
32 views45 pages

Pertemuan 2 Euler

This document discusses Euler's method, a numerical method for solving differential equations. Euler's method approximates the solution of a differential equation at discrete points by calculating the tangent line at each point. The method is explained step-by-step and examples are provided to demonstrate its application and analyze the error compared to the exact solution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
32 views45 pages

Pertemuan 2 Euler

This document discusses Euler's method, a numerical method for solving differential equations. Euler's method approximates the solution of a differential equation at discrete points by calculating the tangent line at each point. The method is explained step-by-step and examples are provided to demonstrate its application and analyze the error compared to the exact solution.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 45

EULER’S METHOD

Penyelesaian persamaan diferensial adalah suatu


fungsi yang memenuhi persamaan diferensial dan
juga memenuhi kondisi awal yang diberikan pada
persamaan tersebut.
Di dalam penyelesaian persamaan diferensial
secara analitis, biasanya dicari penyelesaian
umum yang mengandung konstanta sembarang
dan kemudian mengevaluasi konstanta tersebut
sedemikian sehingga hasilnya sesuai dengan
kondisi awal.
Solusi PDB :
solusi analitik : salah satunya dengan teknik
integral
solusi numerik : menggunakan metode hampiran.
Solusi Numerik :
mencari nilai fungsi di xr+1, dimana r menunjukkan
jumlah langkah atau iterasi.
Langkah/iterasi memiliki jarak yang sama (h)
xr = x0 +rh; r = 0,1,2,…,n

h
x
x0 x1 x2 x3 xr-1 xr xr+1
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

If f and f /y are continuous, then this IVP has a unique solution
y = (t) in some interval about t0.
When the differential equation is linear, separable or exact,
we can find the solution by symbolic manipulations.
However, the solutions for most differential equations of this
form cannot be found by analytical means.
Therefore it is important to be able to approach the problem in
other ways.
For our first order initial value problem
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.
In this section, we examine the tangent line method, which is also
called Euler’s Method.
EULER, LÉONARD

Euler, Léonard
1707-1783
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). The line tangent to solution at initial point is thus
y  y0  f t0 , y0 t  t0 

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 

where fn = f(tn,yn).
For a uniform step size h = tn – tn-1, Euler’s formula becomes
yn 1  yn  f n h, n  0,1, 2, 
EULER APPROXIMATION
To graph an Euler approximation, we plot the points
(t0, y0), (t1, y1),…, (tn, yn), and then connect these points with
line segments.
yn 1  yn  f n  t n 1  t n , where f n  f t n , yn 
EULER METHOD: INTEGRAL EQUATION
We could write problem as an integral equation. That is, since y
= (t) is a solution of y' = f(t,y), y(t0) = y0, we have
f t ,  (t ) dt
t n1 t n 1
 tn
 (t )dt  
tn
or
 (t n1 )   (t n )   t n 1 f t ,  (t ) dt
t
n

Approximating the above integral


we obtain
 (t n 1 )   (t n )  f t n ,  (t n )  t n 1  t n 

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  t n , 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 )   (t n )   (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)  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 below.
y1  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
EXAMPLE 1: EXACT SOLUTION
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   eC
y (0)  1  k  49

 y  49 1  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

t Exact y Approx y Error % Rel Error


0.00 0 0.00 0.00 0.00
0.10 0.97 0.98 -0.01 -1.03
0.20 1.92 1.94 -0.02 -1.04
0.30 2.85 2.88 -0.03 -1.05
0.40 3.77 3.8 -0.03 -0.80
EXAMPLE 2: EULER’S METHOD
For the initial value problem
y  4  t  2 y, y (0)  1
we can use Euler’s method with h = 0.1 to approximate the solution
at t = 1, 2, 3, and 4, as shown below.

y1  y0  f 0  h  1  4  0  (2)(1) (0.1)  1.6


y2  y1  f1  h  1.6  4  0.1  (2)(1.6) (0.1)  2.31
y3  y2  f 2  h  2.31  4  0.2  (2)(2.31) (0.1)  3.15
y4  y3  f 3  h  3.15  4  0.3  (2)(3.15) (0.1)  4.15

Exact solution
7 1 11 2t
y  t e
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
Exact Solution :
0.70 9.75 8.45 1.30 13.31
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
t Exact y Approx y Error % Rel Error
0.00 1.00 1.00 0.00 0.00
0.10 1.66 1.60 0.06 3.55
0.20 2.45 2.31 0.14 5.81
0.30 3.41 3.15 0.26 7.59
0.40 4.57 4.15 0.42 9.14
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
0.80 12.27 10.47 1.80 14.64
0.90 15.34 12.89 2.45 15.96
1.00 19.07 15.78 3.29 17.27
t Exact y Approx y Error % Rel Error
0.00 1.00 1.00 0.00 0.00
1.00 19.07 15.78 3.29 17.27
2.00 149.39 104.68 44.72 29.93
3.00 1109.18 652.53 456.64 41.17
4.00 8197.88 4042.12 4155.76 50.69
EXAMPLE 2: ERROR ANALYSIS & GRAPHS

t Exact y Approx y Error % Rel Error


0.00 1.00 1.00 0.00 0.00
1.00 19.07 15.78 3.29 17.27
2.00 149.39 104.68 44.72 29.93
3.00 1109.18 652.53 456.64 41.17
4.00 8197.88 4042.12 4155.76 50.69

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 .
x
b) Jika diketahui y ( x )  e  x 1
langkah mana yang lebih teliti ?

25
dy
h = 0.05  x  y; y (0)  0
x=0 y(0) = 0
dx
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 26
Nilai yi+1 hanya bergantung pada nilai-nilai xi dan
nilai yi . Dengan menggunakan syarat awal y(0)= y0
nilai-nilai fungsi yi untuk i = 1,2,3,… dapat
ditentukan.

Metode Euler eksplisit diturunkan dari deret


Taylor dengan membuang suku orde dua

kesalahan pemotongan
lokal orde kedua O(h 2 )
kesalahan pemotongan global O(h)

27
Besar dan sifat kesalahan pemotongan pada metode Euler
dapat dijelaskan dari deret Taylor.

LOCAL TRUNCATION ERROR FOR EULER METHOD (1 OF 2)


Assume that y = (t) is a solution to ' = f (t, ), y(t0) = y0 and that
f, ft and fy are continuous. Then '' is continuous, where
 (t )  f t t ,  ( t )   f y t ,  ( t )  f t ,  ( t ) 
Using a Taylor polynomial with a remainder to expand (t) about
t = tn, we have
1
 ( t )   ( t n )   ( t n )  t  t n    ( n )  t  t n 2
2!
where n is some point in the interval tn < n < tn+1.
Since h = tn+1 – tn and ' = f (t, ), it follows that
1
 (t n 1 )   (t n )  f t n , (t n ) h   ( n )h 2
2!
LOCAL TRUNCATION ERROR FOR EULER METHOD (2 OF 2)

From the previous slide, we have


1
 (t n 1 )   (t n )  f t n ,  (t n ) h   ( n )h 2
2!
Recalling the Euler formula
yn 1  yn  f (t n , yn )h,
it follows that
1
 (t n 1 )  yn 1   (t n )  yn    f t n ,  (t n )   f (t n , yn )h   ( n )h 2
2!
To compute the local truncation error en+1 , we take yn = (tn) and
hence 1
en 1   (t n 1 )  yn 1 
 2
 ( n )h
2!
ERROR ANALYSIS
(GEOMETRIC INTERPRETATION)
dy
 f ( x, y ), y ( x0 )  y0
dx
y dy
  f ( x, y )
x dx
y  f ( x , y ) x
y1  y0  y  f ( x0 , y0 )x

 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 30
ERROR ANALYSIS
(FROM TAYLOR’S EXPANSION)

y ( x  x)  y ( x)  y( x)x  y( x) x 2


2  y( x) x 3
6 
 y ( x)  f ( x, y )x  d
dx f ( x, y ) x 2
2 
Euler’s
Euler’s truncation error
O(x2) per step

1st order method

31
CUMULATIVE ERROR
y
32




x
Remark:
x Error 
x=0 x=T
But computation time

Number of steps = T/x


Cumulative Err. = (T/x)  O(x2) = O(x)
EXAMPLE 4

dengan syarat awal

Penyelesaian eksak: −2𝑡


.

Interval dibagi menjadi N = 20


subinterval yang sama besar,
ambil .
Nilai-nilai fungsi , n = 1,2,3, …
dihitung menggunakan skema Euler:

, dengan i = 1,2,3,.....
33

 dan seterusnya.

34
Euler kesalahan
t eksak
eksplisit mutlak
0.0 -2.000 -2.000 0.000
0.1 -1.900 -1.900 0.000
0.2 -1.801 -1.803 0.002
0.3 -1.705 -1.709 0.004
0.4 -1.614 -1.620 0.006
0.5 -1.529 -1.538 0.009
0.6 -1.451 -1.463 0.012
0.7 -1.381 -1.396 0.015
0.8 -1.319 -1.336 0.017
0.9 -1.266 -1.284 0.018
1.0 -1.220 -1.238 0.019
1.1 -1.180 -1.200 0.019
1.2 -1.148 -1.166 0.019
1.3 -1.120 -1.138 0.018
1.4 -1.098 -1.115 0.017
1.5 -1.079 -1.095 0.016
1.6 -1.064 -1.078 0.014
1.7 -1.052 -1.065 0.013
1.8 -1.041 -1.053 0.012
1.9 -1.033 -1.044 0.010
2.0 -1.027 -1.036 0.009
-1

-1.2 app
eksak
y -1.4

-1.6

-1.8

-2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
t

0.02

0.015

0.01
e rr o r

0.005

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
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.
BACKWARD EULER FORMULA
(METODE EULER IMPLISIT)
Masalah nilai awal
Example 5

dengan syarat awal

Penyelesaian: .
Jika diasumsikan bilangan positif yang cukup besar
maka penyelesaian akan berubah dengan cepat
→ bagian eksponsial bernilai cukup dekat dengan nol.
→ penyelesaian akan berubah secara lambat mengikuti
.
38
1

0.9

0.8

0.7

0.6

0.5

0.4

0.3
y = exp(- t)
0.2 y = t2
y = y = exp(- t) + t2
0.1

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
t
39
1

0.9

0.8

0.7

0.6

0.5

0.4

0.3

0.2 Euler eksplisit; h = 0.05


Euler eksplisit; h = 0.01
0.1 Eksak

0
0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1
t 40
Metode Euler implisit juga dapat diturunkan melalui deret Taylor
:
′ ′′


(suku orde kedua
dihilangkan)

, dengan i = 1,2,3,.......

41
Skema yang implisit :
nilai bergantung pada nilai-nilai dan
nilai

Skema numerik Euler implisit persamaan nonlinear

penyelesaiannya memerlukan prosedur


untuk menyelesaikan persamaan
nonlinear, misalnya metode iterasi titik
tetap, metode bagi dua, metode Newton,
dll..

42
Metode Euler implisit diturunkan dari deret Taylor
dengan membuang suku orde dua

Kesalahan pemotongan metode Euler implisit


kesalahan pemotongan lokal: orde kedua:
kesalahan pemotongan global:orde pertama atau

43
-1

-1.1

-1.2

-1.3

-1.4

-1.5

-1.6

-1.7 Euler eksplisit; h = 0.1


Eksak
-1.8 Euler implisit h = 0.1

-1.9

-2
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
t 44
0.02

0.018

0.016

0.014

0.012

0.01

0.008

0.006

0.004 Euler eksplisit; h = 0.1


Euler implisit; h = 0.1
0.002

0
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
t

Gambar: Perbandingan kesalahan mutlak metode Euler eksplisit dan


implisit dalam menyelesaikan Example 4 dengan h = 0.1. 45

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy