0% found this document useful (0 votes)
10 views

CH 9 OrdinaryDifferentialEquations Fall 24 25

This document discusses numerical methods for solving ordinary differential equations (ODEs), focusing on initial value problems (I.V.P.) and boundary value problems (B.V.P.). It covers various methods including Taylor series, Euler's method, modified Euler's formula, and the Runge-Kutta methods, providing formulas and examples for each. Additionally, it explains how to extend these methods to systems of equations and higher-order differential equations.
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)
10 views

CH 9 OrdinaryDifferentialEquations Fall 24 25

This document discusses numerical methods for solving ordinary differential equations (ODEs), focusing on initial value problems (I.V.P.) and boundary value problems (B.V.P.). It covers various methods including Taylor series, Euler's method, modified Euler's formula, and the Runge-Kutta methods, providing formulas and examples for each. Additionally, it explains how to extend these methods to systems of equations and higher-order differential equations.
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/ 13

Fall 2024-2025

Numerical Methods for Science and Engineering


Lecture Note 9
Ordinary Differential Equations

9.1 Introduction

We shall consider the solution of ordinary differential equations satisfying certain conditions.
Problems in which all the initial conditions are specified at one point only are called initial
value problems (I.V.P.). On the other hand, problems involving second and higher order
differential equations, we may prescribe the conditions at two or more points. Such problems
are called boundary value problems (B.V.P.).

Any higher order differential equation can be expressed as a system of first order equations
and the method of solution for first order equation can extended for the system.

To describe various numerical methods for the solution of ordinary differential equations, we
consider the general first order differential equation.
dy
= f ( x, y ) (1)
dx
with the initial condition
y ( x0 ) = y 0 .

9.2 Taylor Series Solution

Consider the Taylor series solution of the of the initial value problem
dy
= f ( x, y ) with y ( x0 ) = y 0
dx
The solution of the equation is a function of x. The Taylor series expansion of y (x) about x 0
is
h2 h3 h 4 (iv)
y( x0 + h) = y0 + h y0 + y0 + y0 + y0 +   
2! 3! 3!
dny
where y 0( n) is the value of at x = x0 .
dx n
The values of the derivatives can be found by differentiating repeatedly and substituting
x = x0 and y = y 0 .
The method can also be used for higher order differential equations.

1
Fall 2024-2025

9.3 Euler Method

Consider the solution of the initial value problem


dy
= f ( x, y ) with y ( x0 ) = y 0 (1)
dx
From Taylor series expansion of y ( x0 + h) and neglecting terms containing h 2 and higher
powers of h we have
y ( x0 + h)  y ( x0 ) + hy ( x0 )
or equivalently
y1 = y 0 + hf ( x0 , y 0 )
This is Euler’s formula, and the order of the error is (h 2 ) .

Alternatively, integrating (1) from 𝑥0 to 𝑥1 with respect to 𝑥, we have


x1
y ( x1 ) = y ( x0 ) + 
x0
f ( x, y )dx
x1
or y1 = y 0 +  f ( x, y )dx
x0
Assuming that f ( x, y ) = f ( x0 , y 0 ) in x0  x  x1 , we have
y1 = y 0 + hf ( x0 , y 0 ) where h = x1 − x0
The process can be continued for the next interval by taking x1 and y1 as the starting values.
In general , we have the iteration formula
y n+1 = y n + hf ( x n , y n ) n = 0,1,2,  

9.4 The Modified Euler’s Formula and Predictor-Corrector Method

Integrating the DE (1) from 𝑥0 to 𝑥1 , we have


x1
y1 = y 0 +  f ( x, y )dx
x0
Using trapezoidal rule to the integration we obtain the modified Euler’s formula
y1 = y0 +  f ( x0 , y0 ) + f ( x1 , y1 )
h
2
An iterative formula to the above equation can be taken as
h
 
y1( n+1) = y n + f ( x0 , y 0 ) + f ( x1 , y1( n) )
2
( 0)
The iteration can be started by choosing y1 from the Euler’s formula
y1(0)  y1 = y 0 + hf ( x0 , y 0 )
This procedure is known as the one-step predictor-corrector method.

2
Fall 2024-2025

9.5 The Runge-Kutta Method

9.5.1 Second Order Runge-Kutta Method (RK-2 Method)

If we use y1 = y 0 + hf ( x0 , y 0 ) on the right side of the modified Euler’s formula, we have

y1 = y 0 +  f ( x0 , y 0 ) + f ( x1 , y0 + hf ( x0 , y 0 )
h
2
Setting
k1 = hf ( x0 , y 0 )
k 2 = hf ( x0 + h, y 0 + k1 )
1
we have y1 = y0 + [k1 + k 2 ]
2
This is known as the second order Runge-Kutta formula.
It can be shown that RK-2 method is equivalent to Taylor series of order two and the order
of the error is ( h 3 ).

9.5.2 Fourth Order Runge-Kutta Method (RK-4 Method)

The fourth order Runge-Kutta formula, the most commonly used one in practice, is stated
without proof.
y1 = y 0 + k1 + 2k 2 + 2k 3 + k 4 
1
6
where,
k1 = hf ( x0 , y 0 )
k1
k 2 = hf ( x0 + h2 , y 0 + 2
)
k2
k 3 = hf ( x0 + h2 , y 0 + 2
)
k 4 = hf ( x0 + h, y 0 + k 3 )
Note that the process is not unique, and many other variations are possible. In fact, the
fourth order process is very accurate and most frequently used. This formula is equivalent to
Taylor series of order four and the order of the error is (h 5 ) .

9.6 System of Equations

So far, we have considered the method for a single differential equation but those methods
can be extended for system of first order equation.
Consider a system of pair of equations
y  = f1 (t , y, z )
z  = f 2 (t , y, z )
subject to initial conditions y (t0 ) = y0 and z (t 0 ) = z0 .

(a) Euler’s Method for a System

Euler’s method to the above system can be written as


y1 = y0 + hf1 (t0 , y0 , z0 )
𝑧1 = 𝑧0 + ℎ𝑓2 (𝑡0 , 𝑦0 , 𝑧0 )
3
Fall 2024-2025

(b)Rk-2 Method for a System

The second order Runge-Kutta (RK-2) method to the above system can be written in the
form
k1 = hf1 (t 0 , y0 , z0 ) m1 = hf 2 (t0 , y0 , z0 )
k 2 = hf1 (t 0 + h, y0 + k1 , z0 + m1 ) m2 = hf 2 (t 0 + h, y0 + k1 , z0 + m1 )
and y1 = y 0 + 1 k1 + k 2 
2
z1 = z 0 + m1 + m2 
1
2

In a similar way the RK-4 method can be extended for system of equations.

An ordinary differential equation of order higher than 1 can be solved numerically by


changing it into a system of first order equations.

9.7 Higher Order Differential Equations

The Taylor series solution for higher order differential equations is straightforward and like
first order equation.
An ordinary differential equation of order higher than 1 can be solved numerically by
changing it into a system of first order equations. Consider, for example, a second order initial
value problem
y  = f ( x, y, y ) with y ( x0 ) = c0 and y ( x0 ) = c1
Defining the new variable
y = z
the above initial value problem can be written as
y = z
z  = f ( x, y , z )
with y ( x0 ) = c0 and z ( x0 ) = c1 .

Example9.1: Given that 𝑦 ′ = 2𝑥𝑦 2 − 𝑦, where 𝑦 = 1 at 𝑥 = 0.


(a) Estimate the values of 𝑦(0.2) using Euler’s method with step size ℎ = 0.1.
(b) Estimate the values of 𝑦(0.2) using the Runge-Kutta method of order two.
(c) Estimate a value of 𝑦(0.2) using theRunge-Kutta method of order four.
(d) (i) Use three-point central difference formula for derivative to derive a recurrence
relation for the above IVP.
(ii) Estimate the values of y at 𝑥 = 0.4 and 0.6 using this recurrence relation.
(e) Use MATLAB function “[x1, y1] =ode23(f, [x0, xn], y0)”
(i) to estimate the values of y in 0 ≤ 𝑥 ≤ 1.4 using ℎ = 0.2.
(ii) to plot the solution curve in [0, 1.4].

Solution (a) Here 𝑓(𝑥, 𝑦) = 2𝑥𝑦 2 − 𝑦 and 𝑥0 = 0, 𝑦0 = 1.


Taking ℎ = 0.1, we have
𝑦(0.1, 0.1) = 1 + 0.1𝑓(0, 1) = 1 + 0.1(−1) = 0.9.
𝑦(0.2, 0.1) = 0.9 + 0.1𝑓(0.1, 0.9 ) = 0.9 + 0.1[2(0.1)(0. 92 ) − 0.9] = 0.8262.

4
Fall 2024-2025

(b) Taking f ( x, y ) = 2 xy 2 − y and x0 = 0 , y 0 = 1 , h = 0.2 , we have


k1 = 0.2 f (0,1) = −0.2
k2 = 0.2 f (0.1, 0.8) = −0.1088
y (0.2, 0.2) = 1 + 12 (−0.2 − 0.1088 ) = 0.8456

(c) Taking f ( x, y ) = 2 xy 2 − y and x0 = 0 , y 0 = 1 , h = 0.2 , we have


k1 = 0.2 f (0,1) = −0.2
k2 = 0.2 f (0 + 02.2 , 1 + −02.2 ) = 0.2 f (0.1, 0.9) = −0.1476
k3 = 0.2 f (0 + 02.2 , 1 + −0.1476
2
) = 0.2 f (0.1, 0.9262 ) = −0.1509
k4 = 0.2 f (0 + 0.2, 1 − 0.1121) = 0.2 f (0.1, 0.8491) = −0.1121
y (0.2, 0.2) = y1= 1 + 16 (−0.2 − 0.1376 − 0.1579 − 1121) = 0.8485
(d) (i) Using three point central difference formula for derivatives with the differential
equation at (𝑥𝑛 , 𝑦𝑛 ) we have
𝑦𝑛+1 − 𝑦𝑛−1
𝑦𝑛′ ≈ = 2𝑥𝑛 𝑦𝑛2 − 𝑦𝑛
2ℎ
𝑦𝑛+1 = 𝑦𝑛−1 + 2ℎ(2𝑥𝑛 𝑦𝑛2 − 𝑦𝑛 )
(ii) For ℎ = 0.2 with the starting values 𝑥0 = 0, 𝑦0 = 1 and 𝑥1 = 0.2, 𝑦1 = 0.8485,
we get
Taking 𝑛 = 1,
𝑦(0.4) ≈ 𝑦2 = 𝑦0 + 2(0.2)(2𝑥1 𝑦12 − 𝑦1 )
= 1 + 0.4[2(0.2)(0.84852 ) − 0.8485] = 0.7758
Taking 𝑛 = 2,
𝑦(0.6) ≈ 𝑦3 = 𝑦1 + 2(0.2)(2𝑥2 𝑦22 − 𝑦2 )
= 0.8485 + 0.4[2(0.4)(0.77582 ) − 0.7758] = 0.6099

(e) (i) >> clear all


>> f=@(x,y) 2*x*y^2-y;
>> [x1, y1]= ode23(f, [0:0.2:1.4], 1);
>> Solution = [x1,y1]

Solution =

0 1.0000
0.2000 0.8484
0.4000 0.7644
0.6000 0.7257
5
Fall 2024-2025

0.8000 0.7275
1.0000 0.7799
1.2000 0.9253
1.4000 1.3401
(ii)
>> xin=0:0.02:1.4; % generate points with sm
>> [x2, y2]=ode23(f, xin,1);
>> plot(x2,y2)

Exercise 9.2
Given the initiaal value problem
dy dz
= x + y2 − z , = x 2 − 3 y + z 2 with y (1) = 2 and z (1) = 2.5 .
dx dx
(a) Estimate y (1.2) and z (1.2) using the RK-2 method with step size h = 0.1 .
(b) Use MATLAB function “[x1, y1]=ode45(F, [x0, xn], y0)”
(i) to estimate the values of y in 1 ≤ 𝑥 ≤ 1.4 using ℎ = 0.1.
(ii) to plot the solution curve in [1, 1.4].

Solution
(a) Taking f ( x, y, z ) = x + y 2 − z , g ( x, y, z ) = x 2 − 3 y + z 2 and, 𝑥0 = 1, 𝑦𝑜 = 2, 𝑧0 =
2.5, with h = 0.1 , we have

k1 = 0.1 f (1, 2, 2.5) = 0.25 m1 = 0.1g (1, 2, 2.5) = 0.125


k 2 = 0.1 f (1.1, 2.25, 2.625 ) = 0.3538 m2 = 0.1g (1.1, 2.25, 2.625 ) = 0.1351
y1 = 2 + 12 (0.25 + 0.3538 ) = 2.3019 z1 = 2.5 + 12 (0.125 + 0.1351) = 2.6301

Now starting with x1 = 1.1 , y1 = 2.3019 , z1 = 2.6301 and h = 0.1 , we have

k1 = 0.1 f (1.1, 2.3019 , 2.6301) = 0.3769 m1 = 0.1g (1.1, 2.3019 , 2.6301) = 0.1222
k 2 = 0.1 f (1.2, 2.6788 , 2.7523 ) = 0.5624 m2 = 0.1g (1.2, 2.6788 , 2.7523 ) = 0.0979
y2 = 2.3019 + 12 (0.3769 + 0.5624 ) z 2 = 2.6301 + 12 (0.1222 + 0.0979 )
=2.7716 = 2.7402

Thus
y (1.2)  y 2 = 2.7716 and z (1.2)  z 2 = 2.7402 .

(b) Using 𝑦1 = 𝑦 and 𝑦2 = 𝑧, we can write the system as follows:

𝑦1′ 𝑥 + 𝑦12 − 𝑦2 𝑦1 (0) 2


[ ]=[ 2 ] with [ ] = [ ].
𝑦2 ′ 𝑥 − 3𝑦1 + 𝑦22 𝑦2 (0) 2.5

Entry in command window;

6
Fall 2024-2025

(i) >> clear


>> F=@(x,y) [x+y(1)^2-y(2); x^2-3*y(1)+y(2)^2];
>> [x1,y1]=ode45(F, [1:0.1:1.4], [2, 2.5]);
>> Sxyz = [x1,y1]

Sxyz =

1.0000 2.0000 2.5000


1.1000 2.3091 2.6241
1.2000 2.8009 2.7112
1.3000 3.6825 2.6368
1.4000 5.6417 2.0508

(ii)
>> [x2,y2]=ode45(F, [1:0.01:1.4], [2, 2.5]);
>> plot(x2,y2)

Example 9.3

An LCR circuit can be described by the system of differential equations

𝑑𝐼 1 𝑑𝑉 1 1
= 𝑉, =− 𝐼− 𝑉.
𝑑𝑡 𝐿 𝑑𝑡 𝐶 𝑅𝐶

where I is the current through the inductance and V is the voltage drop across the capacitor.
1
Suppose that R= 1 ohm, 𝐶 = 2 farad and 𝐿 = 1 henry.
Use MATLAB command “[x1, y1] =ode45(F, [x0, xn], y0)” to find the numerical solution
for 𝑡 ∈ [0, 5] if 𝐼(0) = 2 amperes and V(0) = 3 volts.
Plot your results 𝐼(𝑡) and 𝑉(𝑡) separately for distributions.

Solution:

Using 𝑦1 = 𝐼 and 𝑦2 = 𝑉, we can write the system as follows:

𝑦1′ 𝑦2 𝑦1 (0) 2
[ ] = [−𝑦 − 𝑦 ] with [ ] = [ ].
𝑦2 ′ 1 2 𝑦2 (0) 3

7
Fall 2024-2025

Entry in command window;

>> clear
>> F=@(t,y) [y(2); -y(1)-y(2)]

F = @(t,y)[y(2);-y(1)-y(2)]

>> [t,y]=ode45(F,[0,5],[2,3]);

>> plot(t,y(:,1))
>> xlabel('t'); ylabel('I(t)');
>> title('Distribution of I(t)');

>> plot(t,y(:,2))
>> xlabel('t'); ylabel('V(t)');
>> title('Distribution of V(t)');

Example 9.4: Consider the boundary value problem


𝑦 ′′ − 𝑦 ′ = 1, 𝑦(0) = 1, 𝑦(1) = 2(𝑒 − 1)
(a) Derive a recurrence relation using three points central difference approximations
with ℎ = 1⁄3.
(b) Using the above finite difference formula solve the above BVP.
(c) Express the above initial value problem as a system of first order equations.
(d) Use MATLAB function “sol=bvp4c(odefun, bcfun, solinit)” to the BVP.
(i) Estimate the values of y at 𝑥 =. 1/3, 2/3, 0.4 and 0.9.
(ii) Plot the solution curve.y.

Solution
(a) Using central difference formulas, we have
1 1
(𝑦𝑛+1 − 2𝑦𝑛 + 𝑦𝑛−1 ) − (𝑦 − 𝑦𝑛−1 ) = 1
ℎ2 2ℎ 𝑛+1
1 3
Taking ℎ = 3 , we get 9(𝑦𝑛+1 − 2𝑦𝑛 + 𝑦𝑛−1 ) − 2 (𝑦𝑛+1 − 𝑦𝑛−1 ) = 1

On simplification, 21𝑦𝑛−1 − 36𝑦𝑛 + 15𝑦𝑛+1 = 2


8
Fall 2024-2025

1 2
(b) With ℎ = 1⁄3, the nodal points are 𝑥0 = 0, 𝑥1 = 3 , 𝑥2 = 3 , 𝑥3 = 1.
1
For 𝑛 = 1, 𝑥1 = 3 , 𝑦0 = 1,

−36𝑦1 + 15𝑦2 = 2 − 21 = −19, (1)


2
For 𝑛 = 2, 𝑥2 = 3 , 𝑦3 = 2(𝑒 − 1) ,

21𝑦1 − 36𝑦2 = 2 − 30(𝑒 − 1) = −49.5485, (2)


Solving the equations (1) and (2), we have
𝑦1 = 1.4548 and𝑦2 = 2.2250
(c) Using 𝑦1 = 𝑦 and 𝑦2 = 𝑦′, we can write the system as follows:

𝑦1′ 𝑦2 𝑦1 (0) 1
[ ] = [1 + 𝑦 ] with [ ]=[ ].
𝑦2 ′ 2 𝑦1 (1) 2(𝑒 − 1)
(d)
>> clear
>> F=@(x,y) [y(2); 1+y(2)]; % dy/dx = F(x, y)
>> bc=@(ya,yb) [ya(1)-1; yb(1)-2*(exp(1)-1)]; % format boundary values
>> yinit=@(x) [1; 4]; % initial guess value supplied
>> solinit=bvpinit(linspace(0,1,3), [1,2]); % generates starting values
>> sol=bvp4c(F, bc, solinit); % solution

(i) % Extracting values from solution “sol”


>> xint=[0, 1/3, 2/3, 1];
>> sxint=deval(sol,xint)
Val_xy =

0 1.0000
0.3333 1.4579
0.6667 2.2283
1.0000 3.4366

(ii) % Plotting of 𝑦(𝑥).


>> xval=linspace(0,1);
>> yval=deval(sol,xval);
>> plot(xval, yval(1,:))

9
Fall 2024-2025

Exercise 9

1. Given the initial value problem 𝑦 ′ = 2𝑥 2 − 𝑦 + 3𝑦 2 with 𝑦(2) = 0.5.


(a) Estimate the values of 𝑦(2.2) using Euler’s method with step size ℎ = 0.2.
(b) Estimate the values of 𝑦(2.6) using the Runge-Kutta method of order two.
(c) Estimate a value of 𝑦(2.8) using theRunge-Kutta method of order four.
(d) (i) Use three point central difference formula for derivative to derive a recurrence
relation for the above IVP.
(ii) Estimate the values of y at 𝑥 = 3.0 and 3.2 using this recurrence relation.
(e) Use MATLAB function “[x1, y1] =ode23(f, [x0, xn], y0)”
(i) to estimate the values of y in 1≤ 𝑥 ≤ 4 using ℎ = 0.2.
(ii) to plot the solution curve in [1, 4].

2. Given the initial value problem


𝑦 ′ = 2𝑥 + 𝑥 2 𝑦 with 𝑦(0) = −1.
(a) Estimate the values of 𝑦(0.2) using the Runge-Kutta method of order two.
(b) Estimate a value of 𝑦(0.2) using theRunge-Kutta method of order four.
(c) (i) Use three point central difference formula for derivative to derive a recurrence
relation for the above IVP.
(ii) Estimate the values of y at 𝑥 = 0.4 and 0.6 using this recurrence relation.
(d) Use MATLAB function “[x1, y1]=ode45(f, [x0, xn], y0)”
(i) to estimate the values of y in 0 ≤ 𝑥 ≤ 1.5 using ℎ = 0.1.
(ii) to plot the solution curve in [0, 1.5].

3. Given the system


dy dz
= y 2 + xz + x 2 and = y + 2 x + yz
dx dx
with the initial conditions 𝑦(1) = −1 and 𝑧(1) = 1.
(a) Estimate 𝑦(1.1) and 𝑧(1.1) using Runge-Kutta method of order two.
(b) Use central difference formula to derive a recuurence formula and estimate the
values of 𝑦(1.2) and 𝑧(1.2).
(c) Use MATLAB function “[x1, y1] =ode45(F, [x0, xn], y0)”
(i) to estimate the values of y in 1 ≤ 𝑥 ≤ 1.5 using ℎ = 0.1.
(ii) to plot the solution curve in [1, 1.5].

4. The equation for a 𝐿𝐶𝑅 circuit with applied voltage 𝐸 is


𝑑2𝑞 𝑑𝑞 1
𝐿 2 +𝑅 + 𝑞=𝐸
𝑑𝑡 𝑑𝑡 𝐶
𝑑𝑞
where 𝐿 = 1𝐻, 𝑅 = 10Ω, 𝐶 = 5𝐹 and 𝐸 = 20 𝑉 given that 𝑞 = 1 and = 2 at 𝑡 = 1.
𝑑𝑡

(a) Use three-point central difference formula for derivatives to derive a recurrence
relation for the above IVP.
(b) Express the above initial value problem as a system of first order differential
equations.
(c) Use (a) and (b) to estimate the values of y at t= 1.4 and 1.6.
(d) Estimate a value of q (1.2) using the Runge-Kutta mehod of order two.
(e) Use MATLAB function “[x1, y1]=ode45(F, [x0, xn], y0)”
(i) to estimate the values of y in 1 ≤ 𝑡 ≤ 2 using ℎ = 0.2.

10
Fall 2024-2025

(ii) to plot the solution curve in [1, 2].

5. Consider the boundary value problem


𝑦 ′′ − 2𝑦 ′ + 2𝑦 = 𝑥, 𝑦(0) = 1, 𝑦(1) = 2.
(a) Derive a recurrence relation for the above differential equation using three-point central
difference formula for derivative with ℎ = 1⁄3.
(b) Using the above finite difference formula, solve the above boundary value problem.
(c) Express the above initial value problem as a system of first order differential
equations.
(d) Use MATLAB function “sol = bvp4c(odefun, bcfun,solinit)” to solve the BVP.
(i) Estimate the values of 𝑦 at 𝑥 = 1⁄3 and 2⁄3.
(ii) Plot the solution curve 𝑦(𝑥)’

6. Consider the following boundary value problems


(i) 𝑦 ′′ + 5𝑦 ′ + 3𝑦 = 1, 𝑦(0) = 1, 𝑦(1) = 0 .
(ii) 𝑦 ′′ − 3𝑥𝑦 ′ = 1, 𝑦(0) = 1, 𝑦(1) = 1.
1
(iii) (2 + 2𝑥 2 )𝑦 ′′ + 6𝑥𝑦 ′ + 4𝑦 = 4, 𝑦(0) = 0, 𝑦(1) = 2 .
Find the solution to the problem using following steps.
(a) Derive a recurrence relation for the above differential equation using three-point central
difference formula for derivative with ℎ = 1⁄3.
(b) Using the above finite difference formula, solve the above boundary value problem.
(c) Express the above initial value problem as a system of first order differential
equations.
(d) Use MATLAB function “sol = bvp4c(odefun, bcfun, solinit)” to solve the BVP.
(i) Estimate the values of 𝑦 at 𝑥 = 1⁄3 and 2⁄3.
(ii) Plot the solution curve 𝑦(𝑥)’

7. Solve the following boundary value problems using the finite difference method and
central difference approximations.
1
(a) 𝑦 ′′ − 𝑦 = 4𝑥𝑒 𝑥 𝑦(0) = 0, 𝑦(1) = 1 with ℎ = 4 .
(b) 𝑦 ′′ = 𝑥𝑦 𝑦(0) = 0, 𝑦(1) = 1 with ℎ = 0.25 .

8. Consider the following first order ODE:


𝑑𝑦 𝑥2
= from 𝑥 = 0 to 𝑥 = 2.1 with 𝑦(0) = 2.
𝑑𝑥 𝑦
(a) Solve with Euler’s explicit method using ℎ = 0.7.
(b) Solve with second-order Runge-Kutta method using ℎ = 0.7.
2𝑥 3
(c) The analytic solution of ODE is 𝑦 = √ + 4. In each part, calculate the error
3

between the true solution and the numerical solution at the points where the
numerical solution is determined.
[Ref. Numerical Methods for engineers and Scientists – Amos Gilat, Vish Subramaniam,
Problem # 10.1, Page # 457]
11
Fall 2024-2025

9. Consider the following first order ODE:


𝑑𝑦 𝑥𝑦
= 𝑥 − 2 from 𝑥 = 1 to 𝑥 = 3.4 with 𝑦(1) = 1.
𝑑𝑥
(a) Solve with Euler’s explicit method using ℎ = 0.8.
(b) Solve with second-order Runge-Kutta method using ℎ = 0.8.
1−𝑥2
(c) The analytic solution of ODE is 𝑦 = 2 − 𝑒 4 . In each part, calculate the error
between the true solution and the numerical solution at the points where the
numerical solution is determined.
[Ref. Numerical Methods for engineers and Scientists – Amos Gilat, Vish Subramaniam,
Problem # 10.2, Page # 457]

10. Consider the following system of two ODEs:


𝑑𝑥 𝑑𝑦
= 2𝑥 + 2𝑦, = 2𝑥 − 𝑦 from 𝑡 = 0 to 𝑡 = 1.2 with 𝑥(0) = 1, and 𝑦(0) = 2.
𝑑𝑡 𝑑𝑡

(a) Solve with Euler’s explicit method using ℎ = 0.4.


𝑒 −2𝑡 (8𝑒 5𝑡 −3) 2𝑒 −2𝑡 (2𝑒 5𝑡 +3)
(b) The analytic solution of ODE is 𝑥 = ,𝑦 = . In each part,
5 5

calculate the error between the true solution and the numerical solution at the points
where the numerical solution is determined.
[Ref. Numerical Methods for engineers and Scientists – Amos Gilat, Vish Subramaniam,
Problem # 10.5, Page # 458]

11. Consider the following system of two ODEs:


𝑑𝑥 𝑑𝑦
= 𝑥 − 𝑦𝑡, 𝑑𝑡 = 𝑡 + 𝑦 from 𝑡 = 0 to 𝑡 = 1.2 with 𝑥(0) = 1, and 𝑦(0) = 1.
𝑑𝑡

(a) Solve with Euler’s explicit method using ℎ = 0.4.


(b) The analytic solution of ODE is 𝑥 = 4𝑒 𝑡 − 𝑡 2 𝑒 𝑡 − 𝑡 2 − 3𝑡 − 3, 𝑦 = 2𝑒 𝑡 − 𝑡 − 1. In
each part, calculate the error between the true solution and the numerical solution at
the points where the numerical solution is determined.
[Ref. Numerical Methods for engineers and Scientists – Amos Gilat, Vish Subramaniam,
Problem # 10.6, Page # 458]

12. Consider the following second order ODE:


𝑑2 𝑦 𝑑𝑦
+ 𝑥 𝑑𝑥 + 𝑦 = 2𝑥𝑦 for 0 ≤ 𝑥 ≤ 1, with 𝑦(0) = 1, and 𝑦(1) = 1.
𝑑𝑥 2
(a) Using the central difference formulas for approximating the derivatives, discretize
the ODE (rewrite the equation in a form suitable for solution with the finite
difference method).
(b) Solve the BVP using step size ℎ = 1/3.
[Ref. Numerical Methods for engineers and Scientists – Amos Gilat, Vish Subramaniam,
Problem # 11.3, Page # 499]
12
Fall 2024-2025

13. Consider the following boundary value problem:


𝑑2𝑢 2
− 𝑢 = −𝑒 −𝑥 sin(𝜋𝑥) for 0 ≤ 𝑥 ≤ 1, with the boundary conditions: 𝑢(0) = 1, and 𝑢(1) = −1.
𝑑𝑥 2

(a) Using the central difference formulas for approximating the derivatives, discretize
the ODE (rewrite the equation in a form suitable for solution with the finite
difference method).
(b) Solve the BVP using step size ℎ = 1/4.
[Ref. Numerical Methods for engineers and Scientists – Amos Gilat, Vish Subramaniam,
Problem # 11.7, Page # 500]

13

You might also like