Euler method is a numerical technique used to approximate solutions to ordinary differential equations (ODEs). It is particularly useful when exact solutions are difficult or impossible to find. The method is named after the Swiss mathematician Leonhard Euler, who developed it in the 18th century.
In this article, we will understand what Euler's method is, and solve problems related to it.
Table of Content
What is Euler's Method?
The Euler method is a fundamental numerical technique used for approximating solutions to ordinary differential equations (ODEs). It is one of the simplest and oldest methods for solving initial value problems where an exact analytical solution might be difficult or impossible.
The Euler method provides an iterative process to approximate the solution of a first-order ODE of the form:
\frac{dy}{dt} = f(t, y)
with an initial condition y(t0) = y0.
Example of Euler method
Consider the differential equation:
with the initial condition:
y(0)=1
We want to approximate the solution at t=0.2 using the Euler method with a step size h=0.1.
Important formulas
yn+1 = yn+h⋅f(tn,yn)
where:
- yn+1is the approximated value of y at tn+1,
- yn is the value of y at tnt_ntn,
- h is the step size,
f(t_n, y_n) is the derivative\frac{dy}{dt} evaluated at(t_n, y_n) .
Step Size: The step size h determines the increment in ttt for each step and is typically chosen based on desired accuracy and stability.
For a system of ODEs, such as:
The Euler method is applied to each equation individually:
General Steps
The general steps include:
- Initialisation: Set t0, y0, and choose a step size h.
- Iteration: For each step n from 0 to N−1 (where tN=t0+N⋅h)
3. Error Analysis: Note that the Euler method introduces truncation errors, and its accuracy depends on the step size hhh. Smaller hhh generally results in more accurate results but requires more computations.
Eulers Method: Practice Problems with solutions
P1. ODE:
Initial Condition: y(0)=0.5
Step Size (h): 0.2
Solution:
Calculate the value at t=0.2:
y_{n+1} = y_n + h \cdot f(t_n, y_n) Where
f(t,y) = y - t^2 + 1 . For t0=0 and y0=0.5:f(0,0.5)=0.5−02+1=1.5
So,
y_1 = y_0 + h \cdot f(0, 0.5) = 0.5 + 0.2 \cdot 1.5 = 0.5 + 0.3 = 0.8 Thus,
y(0.2) \approx 0.8 .Calculate the value at t=0.4:
For t1=0.2 and y1=0.8:
f(0.2,0.8)=0.8−0.22+1=0.8−0.04+1=1.76
y_2 = y_1 + h \cdot f(0.2, 0.8) = 0.8 + 0.2 \cdot 1.76 = 0.8 + 0.352 = 1.152 Thus,
y(0.4) \approx 1.152 .
P2. ODE:
Initial Condition: y(0)=1
Step Size (h): 0.1
Solution:
Calculate the value at t=0.1:
For t0=0 and y0=1:
f(0,1)= \cdot \sin(0) = 0
y_1 = y_0 + h \cdot f(0, 1) = 1 + 0.1 \cdot 0 = 1 Thus,
y(0.1) \approx 1 .Calculate the value at t=0.2:
For t1=0.1 and y1=1:
f(0.1, 1) = 1 \cdot \sin(0.1) \approx 0.0998
y_2 = y_1 + h \cdot f(0.1, 1) = 1 + 0.1 \cdot 0.0998 \approx 1 + 0.00998 = 1.00998 Thus,
y(0.2) \approx 1.00998 .
P3. ODE:
Initial Condition: y(1)=2
Step Size (h): 0.5
Solution:
Calculate the value at t=1.5:
For t0=1 and y0=2:
f(1,2)=1−2=−1
y_1 = y_0 + h \cdot f(1, 2) = 2 + 0.5 \cdot (-1) = 2 - 0.5 = 1.5 Thus,
y(1.5) \approx 1.5 .Calculate the value at t=2.0:
For t1=1.5 and y1=1.5:
f(1.5, 1.5) = 1.5 - 1.5 = 0
y_2 = y_1 + h \cdot f(1.5, 1.5) = 1.5 + 0.5 \cdot 0 = 1.5 Thus,
y(2.0) \approx 1.5 .
P4. ODE:
Initial Condition: y(0)=0
Step Size (h): 0.2
Solution:
Calculate the value at t=0.2:
For t0=0 and y0=0:
f(0, 0) = e0 - 0 = 1
y_1 = y_0 + h \cdot f(0, 0) = 0 + 0.2 \cdot 1 = 0.2 Thus,
y(0.2) \approx 0.2 .Calculate the value at t=0.4:
For t1=0.2 and y1=0.2:
f(0.2, 0.2) = e^{0.2} - 0.2 \approx 1.2214 - 0.2 = 1.0214
y_2 = y_1 + h \cdot f(0.2, 0.2) = 0.2 + 0.2 \cdot 1.0214 = 0.2 + 0.20428 = 0.40428 Thus,
y(0.4) \approx 0.40428 .
P5. ODE:
Initial Condition: y(0)=1
Step Size (h): 0.1
Solution:
Calculate the value at t=0.1:
For t0=0 and y0=1:
f(0, 1) = 0^2 - 1^2 = -1
y_1 = y_0 + h \cdot f(0, 1) = 1 + 0.1 \cdot (-1) = 1 - 0.1 = 0.9 Thus,
y(0.1) \approx 0.9 .Calculate the value at t=0.2:
For t1=0.1 and y1=0.9:
f(0.1, 0.9) = 0.12 - 0.92 = 0.01 - 0.81 = -0.8
y_2 = y_1 + h \cdot f(0.1, 0.9) = 0.9 + 0.1 \cdot (-0.8) = 0.9 - 0.08 = 0.82 Thus,
y(0.2) \approx 0.82 .
P6. ODE: \frac{dy}{dt} = 2t - y
Initial Condition: y(0)=1
Step Size (h): 0.1
Solution:
Calculate the value at t=0.1:
For t0=0 and y0=1:
f(0, 1) = 2 \cdot 0 - 1 = -1
y_1 = y_0 + h \cdot f(0, 1) = 1 + 0.1 \cdot (-1) = 1 - 0.1 = 0.9 Thus,
y(0.1) \approx 0.9 .Calculate the value at t=0.2:
For t1=0.1 and y1=0.9:
f(0.1, 0.9) = 2 \cdot 0.1 - 0.9 = 0.2 - 0.9 = -0.7 y_2 = y_1 + h \cdot f(0.1, 0.9) = 0.9 + 0.1 \cdot (-0.7) = 0.9 - 0.07 = 0.83 Thus,y(0.2) \approx 0.83 .
P7. ODE:
Initial Condition: y(0)=2
Step Size (h): 0.2
Solution:
Calculate the value at t=0.2:
For t0=0 and y0=2:
f(0, 2) = -3 \cdot 2 + 4 \cdot 0 = -6
y_1 = y_0 + h \cdot f(0, 2) = 2 + 0.2 \cdot (-6) = 2 - 1.2 = 0.8 Thus,
y(0.2) \approx 0.8 .Calculate the value at t=0.4:
For t1=0.2 and y1=0.8:
f(0.2, 0.8) = -3 \cdot 0.8 + 4 \cdot 0.2 = -2.4 + 0.8 = -1.6
y_2 = y_1 + h \cdot f(0.2, 0.8) = 0.8 + 0.2 \cdot (-1.6) = 0.8 - 0.32 = 0.48 Thus,
y(0.4) \approx 0.48 .
P8. ODE:
Initial Condition: y(1)=0
Step Size (h): 0.5
Solution:
Calculate the value at t=1.5:
For t0=1 and y0=0:
f(1, 0) = 12 + 0 = 1
y_1 = y_0 + h \cdot f(1, 0) = 0 + 0.5 \cdot 1 = 0.5 Thus,
y(1.5) \approx 0.5 .Calculate the value at t=2.0:
For t1=1.5 and y1=0.5:
f(1.5, 0.5) = 1.52 + 0.5 = 2.25 + 0.5 = 2.75
y_2 = y_1 + h \cdot f(1.5, 0.5) = 0.5 + 0.5 \cdot 2.75 = 0.5 + 1.375 = 1.875 Thus,
y(2.0) \approx 1.875 .
P9. ODE:
Initial Condition: y(0)=0
Step Size (h): 0.1
Solution:
Calculate the value at t=0.1:
For t0=0 and y0=0:
f(0,0)=cos(0)−0=1
y_1 = y_0 + h \cdot f(0, 0) = 0 + 0.1 \cdot 1 = 0.1 Thus,
y(0.1) \approx 0.1 .Calculate the value at t=0.2:
For t1=0.1 and y1=0.1:
f(0.1, 0.1) = \cos(0.1) - 0.1 \approx 0.995 - 0.1 = 0.895
y_2 = y_1 + h \cdot f(0.1, 0.1) = 0.1 + 0.1 \cdot 0.895 = 0.1 + 0.0895 = 0.1895 Thus,
y(0.2) \approx 0.1895 .
P10. ODE: \frac{dy}{dt} = -y^2 + t
Initial Condition: y(0)=2
Step Size (h): 0.3
Solution:
Calculate the value at t=0.3t = 0.3t=0.3:
For t0=0 and y0=2:
f(0, 2) = -22 + 0 = -4
y_1 = y_0 + h \cdot f(0, 2) = 2 + 0.3 \cdot (-4) = 2 - 1.2 = 0.8 Thus,
y(0.3) \approx 0.8 .Calculate the value at t=0.6:
For t1=0.3 and y1=0.8:
f(0.3, 0.8) = -0.82 + 0.3 = -0.64 + 0.3 = -0.34
Read More,
Eulers Method Practice Questions
Q1. Use the Euler method with a step size of h=0.1 to approximate the solution of the initial value problem
Q2. Use the Euler method to approximate the solution of
Q3. Approximate the solution of
Q4. Use the Euler method to solve the system:
with initial conditions x(0)=1, y(0)=0, and h=0.1 at t=0.2.
Q5. Approximate the solution of
Q6. ODE:
Initial Condition: y(0)=1
Step Size (h): 0.1
Q7. ODE:
Initial Condition: y(0)=1
Step Size (h): 0.1
Q8. ODE:
Initial Condition: y(0)=2
Step Size (h): 0.3
Q9. ODE:
Initial Condition: y(0)=0
Step Size (h): 0.01
Q10. ODE:
Initial Condition: y(0)=2
Step Size (h): 0.3