Professional Documents
Culture Documents
MTHC02C02
Lecture 7
dy = f ( x, y ) dx
1 y dy = 2 x dx Ln y = x 2 + c y=e
x2 +c
=e
x2 c
y = Ae x
Now, at
x = 1 , y = 25
Then 25 = Ae 1
A = 67.957
y = 67.957e
x2
y = 67.957e 4 = 1.2446759
Now we will study some numerical methods of solving first order differential equations
Euler Method
Consider the first order differential equation on the form
dy = f ( x, y ) dx
We know that
, y ( x0 ) = y0
dy y ( x + h) y ( x ) = lim = f ( x, y ) h 0 dx h
Then one take the approximation
y ( x + h) y ( x ) f ( x, y ) h
or
y ( x + h ) y ( x ) + h f ( x, y )
yn+1 = yn + h f ( xn , yn )
Example 1 Use Euler method to solve the differential equation = x + y to find y at x = 2 by using step length h = 0.25 dx Solution We have h = 0.25
dy
, y (1) = 4
f ( x, y ) = x + y
yn+1 = yn + h f ( xn , yn )
Then at
xn
1
yn
4
f ( xn , yn )
3 3.5 4.125 4.90625
h f ( xn , yn )
0.75 0.875 1.03125 1.2265625
x=2
y = 7.8828125
1.25
1.5
1.75 2
______
______
Example 2 Solve the following initial value problem over the interval t = 0 to t = 0.5 using a step size h = 0.1
dy = (1 + 2t ) y dt tn
0 0.1
0.2
, y (0) = 1 yn
1 1.1
Solution We have
f (tn , yn )
1 1.258571 1.550058 1.880162 2.254588
h f (tn , yn )
0.1 0.125857 0.155006 0.188016 0.2254589
h = 0.1 f (t , y ) = (1 + 2t ) y
yn+1 = yn + h f (tn , yn )
Then at
t = 0.5
y = 1.794338
______
______
dy = f ( x, y ) dx
We have that
, y ( x0 ) = y0
k1 = f ( xn , yn ) k2 = f ( xn + h, yn + h k1 )
yn+1 = yn +
h ( k1 + k2 ) 2
Then by using a suitable step size h we can then get the solution y at some give value of x
Example 3 Solve the following differential equation by using the second order Runge-Kutta (Heuns) method over the interval from t = 0 to t = 1 using a step size of h = 0.25 where .
dy = (1 + 2t ) y dt
Solution We have
, y (0) = 1
h = 0.25 , f (t , y ) = (1 + 2t ) y
k1 = f (tn , yn ) k2 = f (tn + h, yn + h k1 ) h yn+1 = yn + ( k1 + k2 ) 2
tn
0 0.25
0.5
yn
1 1.3346 1.8836 2.7277
k1 = f (tn , yn )
1 1.7329 2.7449 4.1289
tn + h
0.25 0.5 0.75
yn + hk1
1.25 1.7679 2.5699
k2 = f (tn + h, yn + h k1 )
1.677 2.6592 4.0077
0.75 1
1
______
3.7599
______
5.8171
____________
3.9709
______
dy = f ( x, y ) dx
We have that
, y ( x0 ) = y0
k1 = f ( xn , yn ) 1 1 k2 = f ( xn + h, yn + h k1 ) 2 2 k3 = f ( xn + h, yn h k1 + 2hk2 )
h yn+1 = yn + ( k1 + 4k2 + k3 ) 6
Then by using a suitable step size h we can then get the solution y at some give value of x
dy = f ( x, y ) dx
We have that
, y ( x0 ) = y0
k1 = f ( xn , yn ) 1 1 k2 = f ( xn + h, yn + h k1 ) 2 2 1 1 k3 = f ( xn + h, yn + h k2 ) 2 2 k4 = f ( xn + h, yn + h k3 )
yn+1 = yn +
h ( k1 + 2k2 + 2k3 + k4 ) 6
Then by using a suitable step size h we can then get the solution y at some give value of x
Formoredetailsaboutthislectureyoumayusethefollowing: