Solved Exercises on Euler's Method in Differential Equations

Master Euler's method: numerical approximation of differential equations, step-by-step solutions, and error analysis through these 5 detailed exercises.

Solution: Exercises 1 to 3
1 Basic Euler's method
Exercise 1
Use Euler's method with step size h = 0.2 to approximate y(0.6) for the differential equation \(\frac{dy}{dx} = x + y\) with initial condition y(0) = 1.
Definition:

Euler's method: A numerical technique for approximating solutions to differential equations using tangent line approximations. The formula is: \(y_{n+1} = y_n + h \cdot f(x_n, y_n)\)

Euler's method procedure:
  1. Identify the differential equation \(\frac{dy}{dx} = f(x,y)\) and initial condition
  2. Choose step size h and determine number of steps needed
  3. Apply the iterative formula: \(y_{n+1} = y_n + h \cdot f(x_n, y_n)\)
  4. Update x: \(x_{n+1} = x_n + h\)
  5. Repeat until reaching the desired x-value
Given
\(\frac{dy}{dx} = x + y\), y(0)=1
Step Size
h = 0.2
Goal
y(0.6)
Step 1: Set up the iteration table

Starting point: \(x_0 = 0, y_0 = 1\)

Function: \(f(x,y) = x + y\)

Step size: \(h = 0.2\)

n x_n y_n f(x_n, y_n) y_{n+1}
0 0.0 1.0 0.0 + 1.0 = 1.0 1.0 + 0.2(1.0) = 1.2
1 0.2 1.2 0.2 + 1.2 = 1.4 1.2 + 0.2(1.4) = 1.48
2 0.4 1.48 0.4 + 1.48 = 1.88 1.48 + 0.2(1.88) = 1.856
3 0.6 1.856 - -
Step 2: Calculate each iteration

Iteration 0: \(y_1 = y_0 + h \cdot f(x_0, y_0) = 1 + 0.2(0 + 1) = 1.2\)

Iteration 1: \(y_2 = y_1 + h \cdot f(x_1, y_1) = 1.2 + 0.2(0.2 + 1.2) = 1.48\)

Iteration 2: \(y_3 = y_2 + h \cdot f(x_2, y_2) = 1.48 + 0.2(0.4 + 1.48) = 1.856\)

y(0.6) ≈ 1.856 using Euler's method with h = 0.2
Final answer:

Using Euler's method with step size h = 0.2, y(0.6) ≈ 1.856

Applied rules:

• Iterative formula: \(y_{n+1} = y_n + h \cdot f(x_n, y_n)\)

• Step progression: \(x_{n+1} = x_n + h\)

• Function evaluation: Substitute current x and y values into f(x,y)

2 Step size comparison
Exercise 2
Compare Euler's method approximations for \(\frac{dy}{dx} = y\) with y(0) = 1 using step sizes h = 0.5 and h = 0.25 to find y(1). The exact solution is y = e^x.
Definition:

Step size effect: Smaller step sizes generally yield more accurate approximations but require more computations. The global error is proportional to the step size.

Equation
\(\frac{dy}{dx} = y\)
Exact Solution
y = e^x
True Value
y(1) = e ≈ 2.718
Step 1: Calculate with h = 0.5

Need 2 steps to reach x = 1 from x = 0

\(f(x,y) = y\), so \(y_{n+1} = y_n + h \cdot y_n = y_n(1 + h)\)

Step 0: \(y_1 = 1(1 + 0.5) = 1.5\)

Step 1: \(y_2 = 1.5(1 + 0.5) = 2.25\)

So y(1) ≈ 2.25

Step 2: Calculate with h = 0.25

Need 4 steps to reach x = 1 from x = 0

\(y_{n+1} = y_n(1 + 0.25) = 1.25y_n\)

Step 0: \(y_1 = 1 \times 1.25 = 1.25\)

Step 1: \(y_2 = 1.25 \times 1.25 = 1.5625\)

Step 2: \(y_3 = 1.5625 \times 1.25 = 1.953125\)

Step 3: \(y_4 = 1.953125 \times 1.25 = 2.44140625\)

So y(1) ≈ 2.441

Step 3: Compare results

h = 0.5: y(1) ≈ 2.25, Error = |2.718 - 2.25| = 0.468

h = 0.25: y(1) ≈ 2.441, Error = |2.718 - 2.441| = 0.277

Smaller step size reduces error

h = 0.5: y(1) ≈ 2.25, h = 0.25: y(1) ≈ 2.441, Exact: y(1) = e ≈ 2.718
Final answer:

With h = 0.5: y(1) ≈ 2.25; With h = 0.25: y(1) ≈ 2.441. Smaller step sizes provide better approximations.

Applied rules:

• Error reduction: Halving the step size approximately halves the global error

• Computational trade-off: More accurate results require more calculations

• Convergence: As h → 0, Euler's method converges to the true solution

3 Error analysis
Exercise 3
For the equation \(\frac{dy}{dx} = -2y\) with y(0) = 3, find the exact solution and compare with Euler's method using h = 0.1 to estimate y(0.3).
Definition:

Local truncation error: Error introduced in a single step of the numerical method. For Euler's method, it's proportional to h². Global error: Cumulative error over multiple steps, proportional to h.

Differential Equation
\(\frac{dy}{dx} = -2y\)
Exact Solution
y = 3e^{-2x}
True Value
y(0.3) = 3e^{-0.6} ≈ 1.646
Step 1: Find exact solution

\(\frac{dy}{dx} = -2y\) is separable: \(\frac{dy}{y} = -2dx\)

Integrating: \(\ln|y| = -2x + C\), so \(y = Ae^{-2x}\)

Using y(0) = 3: \(3 = Ae^0\), so A = 3

Therefore: \(y = 3e^{-2x}\)

Exact value: \(y(0.3) = 3e^{-0.6} ≈ 1.646\)

Step 2: Apply Euler's method with h = 0.1

Function: \(f(x,y) = -2y\)

Starting: \(x_0 = 0, y_0 = 3\)

Formula: \(y_{n+1} = y_n + h(-2y_n) = y_n(1 - 2h) = y_n(1 - 0.2) = 0.8y_n\)

n x_n y_n y_{n+1}
0 0.0 3.0 0.8 × 3.0 = 2.4
1 0.1 2.4 0.8 × 2.4 = 1.92
2 0.2 1.92 0.8 × 1.92 = 1.536
3 0.3 1.536 -
Step 3: Calculate error

Euler's approximation: y(0.3) ≈ 1.536

Exact value: y(0.3) ≈ 1.646

Absolute error: |1.646 - 1.536| = 0.110

Relative error: (0.110/1.646) × 100% ≈ 6.7%

Exact: y(0.3) ≈ 1.646, Euler: y(0.3) ≈ 1.536, Error: 0.110
Final answer:

The exact solution is y = 3e^{-2x}. Using Euler's method with h = 0.1, y(0.3) ≈ 1.536 with an error of 0.110 compared to the exact value of 1.646.

Applied rules:

• Error estimation: Compare numerical result with known exact solution

• Linear convergence: Global error typically decreases linearly with step size

• Method accuracy: Euler's method is first-order accurate (error ∝ h)

Rules and methods, laws,...
\(y_{n+1} = y_n + h \cdot f(x_n, y_n)\)
Euler's Method Formula
Euler's Method
\(y_{n+1} = y_n + h \cdot f(x_n, y_n)\)
Iterative approximation formula
Step Update
\(x_{n+1} = x_n + h\)
Update x-coordinate
Error Bound
Global error ∝ h
First-order accuracy
Key definitions:

Euler's method: A first-order numerical procedure for solving ordinary differential equations with a given initial value

Step size (h): The increment used to move from one x-value to the next

Local truncation error: Error made in a single step, typically O(h²)

Global error: Accumulated error over all steps, typically O(h)

Complete methodology:
  1. Identify the problem: Write the differential equation and initial condition
  2. Set parameters: Choose step size h and determine the range of computation
  3. Initialize: Set starting values \(x_0, y_0\)
  4. Iterate: Apply \(y_{n+1} = y_n + h \cdot f(x_n, y_n)\) and \(x_{n+1} = x_n + h\)
  5. Continue: Repeat until reaching the desired x-value
  6. Analyze: Compare with exact solutions when available
Tip 1: Smaller step sizes generally produce more accurate results but require more computational work.
Tip 2: Keep track of intermediate calculations using a table to avoid errors.
Tip 3: The method works best for equations with slowly varying solutions.
Tip 4: Always consider the trade-off between accuracy and computational efficiency.
Common errors: Incorrect function evaluation, arithmetic mistakes, miscounting steps, using wrong step size in calculations.
Applications: Solving differential equations when analytical solutions are difficult or impossible to obtain.
Formulas to know by heart:

• Euler's method: \(y_{n+1} = y_n + h \cdot f(x_n, y_n)\)

• Step update: \(x_{n+1} = x_n + h\)

• Local error: \(O(h^2)\)

• Global error: \(O(h)\)

• Accuracy improvement: Reducing h by half roughly halves the error

Solution: Exercises 4 to 5
4 Physical application
Exercise 4
Newton's law of cooling: \(\frac{dT}{dt} = -k(T - T_a)\) where k = 0.1, T_a = 20°C. If T(0) = 100°C, use Euler's method with h = 0.5 to approximate T(2)°C.
Definition:

Newton's law of cooling: The rate of change of temperature of an object is proportional to the difference between its temperature and the ambient temperature.

Given
\(\frac{dT}{dt} = -0.1(T - 20)\)
Initial
T(0) = 100°C
Step Size
h = 0.5
Step 1: Set up the iteration

Function: \(f(t,T) = -0.1(T - 20)\)

Starting: \(t_0 = 0, T_0 = 100\)

Number of steps: (2-0)/0.5 = 4 steps

Step 2: Calculate each iteration

Iteration 0: \(T_1 = T_0 + h \cdot f(t_0, T_0) = 100 + 0.5 \cdot (-0.1)(100-20) = 100 + 0.5(-8) = 96\)

Iteration 1: \(T_2 = 96 + 0.5 \cdot (-0.1)(96-20) = 96 + 0.5(-7.6) = 92.2\)

Iteration 2: \(T_3 = 92.2 + 0.5 \cdot (-0.1)(92.2-20) = 92.2 + 0.5(-7.22) = 88.59\)

Iteration 3: \(T_4 = 88.59 + 0.5 \cdot (-0.1)(88.59-20) = 88.59 + 0.5(-6.859) = 85.16\)

n t_n T_n f(t_n, T_n) T_{n+1}
0 0.0 100.0 -0.1(80) = -8.0 100 + 0.5(-8) = 96.0
1 0.5 96.0 -0.1(76) = -7.6 96 + 0.5(-7.6) = 92.2
2 1.0 92.2 -0.1(72.2) = -7.22 92.2 + 0.5(-7.22) = 88.59
3 1.5 88.59 -0.1(68.59) = -6.859 88.59 + 0.5(-6.859) = 85.16
4 2.0 85.16 - -
Step 3: Interpret the result

After 2 units of time, the temperature drops from 100°C to approximately 85.16°C

This shows the object cooling toward the ambient temperature of 20°C

T(2) ≈ 85.16°C according to Euler's method
Final answer:

Using Euler's method with step size h = 0.5, the temperature after 2 units of time is approximately 85.16°C.

Applied rules:

• Physical modeling: Convert real-world problems into differential equations

• Parameter identification: Extract constants and initial conditions from problem statement

• Interpretation: Relate numerical results back to the physical situation

5 Population growth model
Exercise 5
The population P(t) follows \(\frac{dP}{dt} = 0.03P(1 - \frac{P}{1000})\) with P(0) = 100. Use Euler's method with h = 1 to estimate P(5) and analyze the behavior.
Definition:

Logistic growth model: A differential equation that describes population growth with a carrying capacity limiting factor.

Equation
\(\frac{dP}{dt} = 0.03P(1 - \frac{P}{1000})\)
Initial
P(0) = 100
Carrying Capacity
K = 1000
Step 1: Set up the iteration

Function: \(f(t,P) = 0.03P(1 - \frac{P}{1000}) = 0.03P - 0.00003P^2\)

Starting: \(t_0 = 0, P_0 = 100\)

Step size: \(h = 1\)

Number of steps: 5

Step 2: Calculate each iteration

Iteration 0: \(P_1 = 100 + 1 \cdot [0.03(100) - 0.00003(100)^2] = 100 + [3 - 0.3] = 102.7\)

Iteration 1: \(P_2 = 102.7 + 1 \cdot [0.03(102.7) - 0.00003(102.7)^2] = 102.7 + [3.081 - 0.316] = 105.465\)

Iteration 2: \(P_3 = 105.465 + 1 \cdot [0.03(105.465) - 0.00003(105.465)^2] = 105.465 + [3.164 - 0.333] = 108.296\)

Iteration 3: \(P_4 = 108.296 + 1 \cdot [0.03(108.296) - 0.00003(108.296)^2] = 108.296 + [3.249 - 0.351] = 111.194\)

Iteration 4: \(P_5 = 111.194 + 1 \cdot [0.03(111.194) - 0.00003(111.194)^2] = 111.194 + [3.336 - 0.370] = 114.160\)

n t_n P_n f(t_n, P_n) P_{n+1}
0 0 100.000 2.700 102.700
1 1 102.700 2.765 105.465
2 2 105.465 2.831 108.296
3 3 108.296 2.898 111.194
4 4 111.194 2.966 114.160
5 5 114.160 - -
Step 3: Analyze the behavior

The population is growing but at a decreasing rate

Initially: P(0) = 100, P(5) ≈ 114.16

As P approaches the carrying capacity K = 1000, the growth rate will decrease

Step 4: Discuss limitations

Euler's method may not capture the full complexity of logistic growth with larger step sizes

For better accuracy with this equation, smaller step sizes would be preferable

P(5) ≈ 114.16 with continued growth toward carrying capacity K = 1000
Final answer:

Using Euler's method with h = 1, P(5) ≈ 114.16. The population is growing but will eventually approach the carrying capacity of 1000 as t increases.

Applied rules:

• Model validation: Check if numerical results make sense in context

• Growth behavior: Logistic model should show decreasing growth rate as population approaches carrying capacity

• Method limitations: Consider accuracy of numerical method for given problem type

Key Concepts: Euler's Method, Numerical Approximation, Error Analysis
\(y_{n+1} = y_n + h \cdot f(x_n, y_n)\)
Euler's Method Formula
Key definitions:

Euler's method: A first-order numerical procedure for solving ordinary differential equations with a given initial value

Step size (h): The increment used to move from one x-value to the next

Local truncation error: Error made in a single step, typically O(h²)

Global error: Accumulated error over all steps, typically O(h)

First-order accuracy: The error is proportional to the step size

Complete methodology:
  1. Problem identification: Recognize the differential equation and initial condition
  2. Step size selection: Choose appropriate h balancing accuracy and computation
  3. Initialization: Set initial values x₀ and y₀
  4. Iteration setup: Prepare to apply the Euler formula repeatedly
  5. Sequential calculation: Apply \(y_{n+1} = y_n + h \cdot f(x_n, y_n)\) and update x
  6. Termination: Stop when reaching the target x-value
  7. Validation: Compare with known solutions or analyze reasonableness
Tip 1: For better accuracy, reduce step size, but remember this increases computational effort.
Tip 2: Use a table to organize calculations and prevent arithmetic errors.
Tip 3: Be cautious with stiff equations where Euler's method may produce unstable results.
Tip 4: Always verify if your numerical solution makes physical or mathematical sense.
Common applications: Engineering, physics, biology, economics - wherever differential equations model real phenomena.
Method characteristics: Simple to implement, first-order accuracy, can be unstable for some problems.
Essential formulas and concepts:

• Euler's method: \(y_{n+1} = y_n + h \cdot f(x_n, y_n)\)

• Step update: \(x_{n+1} = x_n + h\)

• Local error: \(O(h^2)\)

• Global error: \(O(h)\)

• Accuracy improvement: Reducing h by factor of k roughly reduces error by factor of k

Questions & Answers

Question: How do I choose an appropriate step size h for Euler's method? What factors should I consider?

Answer: Choosing the right step size involves balancing accuracy and computational efficiency:

  • Accuracy requirements: Smaller h gives better accuracy (error ∝ h) but requires more steps
  • Computation constraints: Larger h means fewer calculations but less precision
  • Solution behavior: Rapidly changing solutions need smaller h to capture details
  • Stability considerations: Some equations become unstable with large h

A practical approach is to start with a reasonable h and then halve it to see if the solution changes significantly. If the change is small, your original h was probably adequate.

For engineering applications, aim for h that produces results within acceptable tolerance while minimizing computation time.

Question: Why does Euler's method have a local truncation error of O(h²) and a global error of O(h)? Can you explain this intuitively?

Answer: This comes from the underlying Taylor series expansion:

Local truncation error: At each step, Euler's method uses the tangent line approximation, which neglects terms of O(h²) from the Taylor series: \(y(x+h) = y(x) + hy'(x) + \frac{h^2}{2}y''(x) + O(h^3)\)

Global error: Since we take n = (b-a)/h steps over an interval of length (b-a), and each step contributes O(h²) error, the total accumulated error is approximately n × O(h²) = (b-a)/h × O(h²) = O(h).

Think of it like compounding: small errors in each step accumulate over the entire solution process.

Question: How does Euler's method relate to the concept of tangent line approximations? I want to understand the geometric intuition.

Answer: Euler's method is fundamentally based on tangent line approximations:

  • At each point (xₙ, yₙ): We know the slope from the differential equation: \(m = f(x_n, y_n)\)
  • Tangent line equation: \(y - y_n = m(x - x_n)\)
  • Move distance h: From xₙ to xₙ₊₁ = xₙ + h
  • Approximate next y: \(y_{n+1} = y_n + m \cdot h = y_n + h \cdot f(x_n, y_n)\)

Geometrically, we're taking small steps along the tangent line at each point, which approximates the actual solution curve. The smaller the step h, the closer our polygonal path follows the true curve.

It's like navigating by taking short straight-line segments in the direction indicated by a compass (the slope) at each location.