CACS252 Numerical Method

Numerical MethodUnit 66 min read

Numerical ODEs: Euler, RK4, Multistep & Applications

Unit 6 of Numerical Method covers solving ordinary differential equations (ODEs) using Euler’s method, Runge-Kutta (RK4), multistep methods, and their applications in physics, finance, and real-world systems like loan interest calculations and traffic flow modeling.

TAKEAWAYS:

  • ODEs model real-world rates of change (e.g., population growth, heat transfer, bank interest).
  • Euler’s method approximates solutions iteratively but is less accurate; RK4 improves precision by averaging slopes.
  • Multistep methods (e.g., Adams-Bashforth) use past points for better accuracy but require initial conditions.
  • Stability and error depend on step size : smaller reduces truncation error but increases round-off error.
  • Applications in Nepal: Ncell’s network traffic modeling, Daraz’s inventory forecasting, and NTC’s power demand prediction.
  • Exam focus: Derive formulas, compute for given , and compare methods’ accuracy/errors.

1. Ordinary Differential Equations (ODEs): Definition and Types

ODEs describe how a quantity changes over time or space. They are fundamental in physics, engineering, and economics.

Types of ODEs

classDiagram
    class ODE {
        <<abstract>>
        +dy/dx = f(x, y)
    }
    class FirstOrder {
        +dy/dx = f(x, y)
        +Example: Population growth
    }
    class SecondOrder {
        +d²y/dx² = f(x, y, dy/dx)
        +Example: Spring-mass systems
    }
    ODE <|-- FirstOrder
    ODE <|-- SecondOrder

Example: Newton’s Law of Cooling (first-order ODE): where = temperature, = time, = cooling constant.


2. Euler’s Method: The Simplest Numerical Approach

Euler’s method approximates solutions by stepping forward using tangent lines.

Formula

Given with initial condition , the update rule is: where = step size.

Worked Example: Population Growth

Problem: Solve , for using .

Solution:

  1. Start at .
  2. Compute .
  3. Iterate:
    • Continue until .

Graph of Euler’s Approximation vs. Exact Solution:

Error Analysis:

  • Truncation Error: . Smaller → better accuracy but more computations.
  • Round-off Error: Accumulates with many steps.

3. Runge-Kutta 4th Order (RK4): Higher Accuracy

RK4 improves accuracy by averaging slopes at intermediate points.

Formula

Worked Example: Loan Interest Calculation (Nepal’s Banks)

Problem: Solve , for (year) using .

Solution:

  1. Compute for each step.
  2. After 4 steps ():
    • (vs. exact ).

Comparison Table:

Method Approx. Error vs. Exact Computational Cost
Euler 10500.0 12.7 Low
RK4 10511.4 1.3 High

4. Multistep Methods: Using Past Points

Methods like Adams-Bashforth use previous -values for better accuracy.

Adams-Bashforth 2nd Order

Worked Example: Traffic Flow (Kathmandu Roads)

Problem: Model car density , , .

Solution:

  1. Use Euler for first step: .
  2. Apply Adams-Bashforth:

Graph of Multistep vs. Euler:


5. Stability and Error Control

  • Stability: Small errors should not grow (e.g., Euler is unstable for stiff ODEs).
  • Error Types:
    • Truncation Error: Due to method approximation.
    • Round-off Error: Due to finite precision (e.g., floating-point arithmetic).

Rule of Thumb:

  • For non-stiff ODEs: RK4 is preferred.
  • For stiff ODEs: Use implicit methods (e.g., backward Euler).

6. Real-World Applications in Nepal

Example 1: Ncell’s Network Traffic

  • ODE Used: (M/M/1 queue model).
  • Purpose: Predict call drops during peak hours.
  • Method: RK4 for dynamic traffic simulation.

Example 2: Daraz’s Inventory Forecasting

  • ODE Used: (inventory decay + supply).
  • Purpose: Optimize stock levels to avoid shortages.
  • Method: Adams-Bashforth for long-term trends.

Example 3: NTC’s Power Demand

  • ODE Used: (logistic growth).
  • Purpose: Plan grid capacity for monsoon seasons.
  • Method: Euler for real-time monitoring.

7. Exam Tip: How to Score Full Marks

  1. Derive Formulas: Show all steps for Euler, RK4, or multistep methods.
  2. Compute Iteratively: For , list all intermediate values.
  3. Compare Methods: Discuss accuracy vs. computational cost (e.g., "RK4 is more accurate but slower than Euler").
  4. Real-World Link: Relate ODEs to Nepalese examples (e.g., "This ODE models Ncell’s call traffic").
  5. Error Analysis: Always mention truncation/round-off error for numerical methods.

Common Pitfalls:

  • Forgetting to update in iterations.
  • Misapplying in RK4’s intermediate steps.
  • Ignoring initial conditions.

Visual Summary:

flowchart TD
    A["ODE Problem"] --> B["Choose Method"]
    B --> C["Euler: Simple but Low Accuracy"]
    B --> D["RK4: High Accuracy, More Work"]
    B --> E["Multistep: Uses Past Points"]
    C --> F["Truncation Error: O(h)"]
    D --> G["Truncation Error: O(h⁴)"]
    E --> H["Stability Depends on h"]
    F --> I["Small h → Better but Slower"]
    G --> J["Best for Smooth ODEs"]

Based on the TU BCA syllabus for Numerical Method (CACS252), unit 6.

Discussion

Loading…