Numerical MethodUnit 115 min read

Numerical Methods: Errors, Approximations & Foundations

Unit 1 of Numerical Method introduces core concepts of numerical analysis—types of errors (truncation, rounding, absolute/relative), error propagation, and the need for approximations in real-world computations. Learn how to quantify uncertainty, compare methods, and understand why exact solutions often require numeric

TAKEAWAYS:

  • Numerical methods approximate solutions because exact analytical methods fail for complex real-world problems (e.g., nonlinear equations, large datasets).
  • Errors arise from truncation (method limitations), rounding (finite precision), and propagation (accumulation in calculations).
  • Absolute error measures raw deviation, while relative error normalizes it to the magnitude of the value (critical for small numbers).
  • Condition number determines how sensitive a problem is to input errors—high condition numbers mean tiny input changes cause huge output errors.
  • Floating-point arithmetic introduces rounding errors; understanding its limits (e.g., IEEE 754 standard) is key to designing stable algorithms.
  • Error analysis guides method selection: choose methods with faster convergence (e.g., Newton-Raphson over bisection) for efficiency.

1. Why Numerical Methods? Exact vs. Approximate Solutions

Most real-world problems cannot be solved exactly using pen-and-paper math. Numerical methods provide approximate solutions with controlled error.

When Do We Need Numerical Methods?

Problem Type Exact Solution Possible? Numerical Method Used Example
Linear equations (3+ variables) Yes (Cramer’s rule) Gauss-Seidel, LU decomposition Solving traffic flow equations
Nonlinear equations Rarely Newton-Raphson, Bisection Finding equilibrium in economic models
Differential equations Only for simple cases Runge-Kutta, Finite Difference Modeling population growth
Large datasets (big data) No Regression, Monte Carlo Predicting stock prices (NEPSE)

2. Types of Errors in Numerical Computation

Errors are inevitable in numerical calculations. Classifying them helps minimize their impact.

0.10.20.30.40.50.60.70.80.9111.522.5yTrue e^x2nd-order Taylor approx(0.1, 1.105170918)(0.1, 1.105)
Visualizing Truncation Error: The gap between the true curve and the 2nd-order approximation at x=0.1

A. Truncation Error

  • Definition: Error due to approximating an infinite process with a finite one.
  • Example: Using a Taylor series expansion with only 3 terms instead of ∞.
  • Real-World Impact:
    • eSewa’s payment processing: If a transaction fee is approximated as a fixed percentage (instead of a dynamic rate), truncation error accumulates over millions of transactions.
    • Weather forecasting: Simplifying atmospheric equations (e.g., ignoring small-scale turbulence) introduces truncation error, leading to less accurate predictions.

Worked Example 1: Truncation Error in Taylor Series Approximate using a 2nd-order Taylor expansion around 0. Solution: The Taylor series for is: For 2nd-order (): Exact value: Truncation error:

Observation: Higher-order terms reduce truncation error. For , a 3rd-order term adds , improving accuracy.


B. Rounding Error

  • Definition: Error introduced when storing numbers with finite precision (e.g., 32-bit floats).
  • Example: Storing as 0.333333333 (instead of its true decimal expansion).
  • Real-World Impact:
    • Khalti’s transaction logs: Rounding errors in fractional paisa values can accumulate to significant losses over millions of transactions.
    • Bank loan calculations: Interest rates compounded daily may introduce rounding errors, affecting final repayment amounts.

Worked Example 2: Rounding Error in Floating-Point Arithmetic Compute in 32-bit floating-point. Solution:

  • In IEEE 754 (32-bit), the smallest representable number near 1 is .
  • rounds to 1.0 (since is below the precision limit).
  • Result: (exact), but the true result should be .

Key Takeaway: Rounding errors can cancel out meaningful digits. Always use higher precision (e.g., double in Python) for critical calculations.


C. Propagation Error

  • Definition: Error that grows as calculations proceed (e.g., in iterative methods).
  • Example: Solving with rounded intermediate values.
  • Real-World Impact:
    • Pathao’s route optimization: Small errors in distance calculations propagate, leading to inefficient (and costly) delivery routes.
    • NTC’s load forecasting: Errors in initial power demand estimates grow when predicting future consumption.

Worked Example 3: Error Propagation in a Simple Formula Compute for with rounding to 3 decimal places. Solution:

  1. (rounded)
  2. Exact value: Propagation error: (small here, but grows in complex formulas).
flowchart TD
    A["Input: x = 1.001"] --> B["Step 1: x² ≈ 1.002 (rounded)"]
    B --> C["Step 2: x + 1 ≈ 2.001 (rounded)"]
    C --> D["Step 3: f(x) ≈ 0.50075"]
    D --> E["Error propagates if more steps are added"]

3. Absolute vs. Relative Error

Metric Definition Formula When to Use
Absolute Error Raw difference between true and computed value Comparing to a known standard (e.g., lab measurements).
Relative Error Error normalized by the true value Comparing errors across different scales (e.g., small vs. large numbers).
012Approx (0.999m)True (1m)
Relative Error Context: A small absolute error (0.001m) on a small scale (1m) yields a smaller relative error (0.1%) than the 100m case

Worked Example 4: Comparing Errors

  • Case 1: Measuring a 100m distance with an error of 1m.
    • Absolute error: m
    • Relative error: (1%)
  • Case 2: Measuring a 1m distance with an error of 1mm.
    • Absolute error: m
    • Relative error: (0.1%)

Key Insight: Relative error is scale-invariant—critical for comparing errors in different contexts (e.g., financial calculations vs. engineering tolerances).


4. Condition Number and Stability

The condition number () measures how sensitive a function is to input errors.

  • Low : Stable (small input errors → small output errors).
  • High : Ill-conditioned (tiny input errors → huge output errors).

Real-World Example: NEPSE Stock Prices

  • Problem: Predicting stock prices using historical data.
  • Issue: Small errors in past prices (due to rounding) can lead to wildly different future predictions if the model is ill-conditioned.
  • Solution: Use regularization (e.g., smoothing data) to reduce .

Worked Example 5: Condition Number of a Linear System For the system , the condition number is: where is the matrix norm.

Example:

  • (very small → ill-conditioned).
  • : A 1% error in could cause a 10,000% error in .

5. Floating-Point Arithmetic and IEEE 754 Standard

Computers represent numbers in binary floating-point, which introduces rounding errors.

Key Concepts:

  1. Sign bit (1 bit): + or –.
  2. Exponent (8 bits in single-precision): Range of values.
  3. Mantissa (23 bits in single-precision): Precision of the number.

Example: Storing in 32-bit float.

  • Exact binary:
  • Stored as: (rounded)
  • Decimal approximation: 0.33333334326744074

Real-World Impact:

  • Google Maps: Rounding errors in GPS coordinates can misplace markers by meters over large distances.
  • WhatsApp encryption: Floating-point errors in cryptographic keys (if used) could break security.
classDiagram
    class FloatingPoint {
        +sign: 1 bit
        +exponent: 8 bits
        +mantissa: 23 bits
        +range: ~10^-38 to 10^38
        +precision: ~7 decimal digits
    }
    class IEEE754 {
        <<standard>>
        +single: 32 bits
        +double: 64 bits
        +extended: 80 bits
    }
    FloatingPoint --> IEEE754 : "Implements"

6. Error Analysis in Algorithms

Not all numerical methods are equally sensitive to errors. Convergence and stability are critical.

Method Convergence Rate Error Behavior Best For
Bisection Method Linear () Slow but stable Finding roots in guaranteed intervals
Newton-Raphson Quadratic () Fast but may diverge Smooth, differentiable functions
Gauss-Seidel Linear Depends on matrix condition Solving large linear systems
Runge-Kutta (4th order) Accurate for ODEs Physics simulations

Worked Example 6: Comparing Bisection vs. Newton-Raphson Find a root of in [1, 2].

  • Bisection:
    • Iteration 1: , → new interval [1.5, 2]
    • Iteration 2: , → [1.75, 2]
    • Convergence: Slow (halves error each step).
  • Newton-Raphson:
    • Start at :
    • Convergence: Quadratically fast (error squared each step).

In the Real World

  1. eSewa’s Payment Processing

    • Concept: Rounding and truncation errors in transaction fees.
    • How it works: When eSewa calculates a 1.5% fee on a Rs. 1000 transaction, it rounds to Rs. 15.00 (truncating the paisa). Over 1 million transactions, this accumulates to Rs. 150,000 in lost revenue due to truncation error.
    • Solution: Use arbitrary-precision arithmetic for financial calculations.
  2. Pathao’s Delivery Route Optimization

    • Concept: Error propagation in distance calculations.
    • How it works: Pathao’s algorithm uses GPS coordinates to compute distances. A 1-meter error in GPS (due to rounding) can lead to a 5% error in estimated delivery time for long routes, causing delays and customer dissatisfaction.
    • Solution: Apply Kalman filtering to smooth GPS data and reduce propagation errors.
  3. NTC’s Power Load Forecasting

    • Concept: Ill-conditioned systems in linear algebra.
    • How it works: NTC uses linear regression to predict electricity demand. If the input data (historical consumption) has high variance, the regression coefficients become extremely sensitive to small changes (high condition number), leading to unreliable forecasts.
    • Solution: Use regularized regression (e.g., Ridge regression) to stabilize the system.

Exam Tip

  1. Error Definitions: Always define absolute error, relative error, and truncation/rounding errors with formulas. Examiners love precise definitions.

    • Example: "Absolute error is , while relative error is ."
  2. Worked Examples: For questions like "Find the relative error of 5.6 if both digits are correct", show step-by-step:

    • True value range: [5.55, 5.65]
    • Maximum absolute error: 0.05
    • Relative error: (0.89%).
  3. Condition Number: If asked about stability, always relate it to matrix norms or function derivatives. Example:

    • "For , is high near because , making it ill-conditioned."
  4. Floating-Point Pitfalls: Mention IEEE 754 and catastrophic cancellation (e.g., ) in your answers. Example:

    • "In floating-point arithmetic, rounds to 1.0, leading to a loss of 16 significant digits."
  5. Method Comparison: For root-finding or integration, compare convergence rates and error bounds. Example:

    • "Newton-Raphson converges quadratically, while bisection converges linearly. For , Newton-Raphson finds in 2 iterations, whereas bisection requires ~20."
  6. Real-World Links: Always tie numerical concepts to Nepali examples (e.g., NTC, banks, eSewa) or global tech (Google, WhatsApp). Example:

    • "Like how Pathao’s route errors propagate, numerical methods in traffic simulation must account for rounding errors in distance matrices."

Final Note: Numerical methods are everywhere—from mobile apps to national infrastructure. Mastering errors and approximations is the first step to designing reliable, efficient algorithms. Practice error calculations and method comparisons to excel in exams!

In the real world

  • eSewa & Khalti (Payment Gateways): Use Rounding Error management in their backend. When processing millions of transactions with fractional paisa values, they use high-precision arithmetic (like double or decimal types) to ensure that tiny rounding errors don't accumulate into significant financial discrepancies in their daily settlement reports.
  • Pathao (Ride-Hailing): Relies on Propagation Error control in route optimization. Small errors in GPS coordinates or distance calculations can propagate through the algorithm, leading to inefficient routes. They use robust numerical methods to minimize this accumulation, ensuring drivers take the most cost-effective path.
  • NTC (Telecom): Applies Condition Number analysis in load forecasting. When predicting future power or data demand, they assess how sensitive their models are to small input errors (like minor fluctuations in historical data). High condition numbers would mean tiny data changes cause huge forecast errors, so they stabilize their input data to keep predictions reliable.

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

Discussion

Loading…