Introduction to Numerical Methods and Error Analysis
Introduction to Numerical Methods
Numerical methods are algorithms and techniques designed to solve mathematical problems numerically (using basic arithmetic operations) instead of symbolically (using exact formulas).
These methods provide approximate solutions to problems that lack analytical solutions or are otherwise impractical to solve via exact formulas.
The Key Idea: Replace a complex, continuous problem with a sequence of simple arithmetic operations (, , , ) that a computer is capable of performing billions of times per second.
Analytical vs. Numerical Solutions
Analytical Solutions (Exact): These involve finding a closed-form formula.
Example: For the quadratic equation , the exact solution is calculated as:
Numerical Solutions (Approximate): No formula exists, leading to iterative processes.
Example: For the equation , one uses iteration: , which converges to .
Abel–Ruffini Theorem: This theorem states that general polynomials of degree have no closed-form solution by radicals; therefore, numerical root-finding is the only general choice available.
The Numerical Problem-Solving Workflow
Physical Problem: Identify the real-world scenario (e.g., heat flow in a metal rod).
Mathematical Model: Establish differential or algebraic equations representing the physical system (introduces modeling error).
Numerical Method: Discretize and approximate the model (introduces truncation error).
Computer Implementation: Use finite-precision arithmetic (introduces round-off error).
Result + Error Analysis: Determine the reliability of the derived answer. Error analysis is viewed as inseparable from numerical methods.
Importance of Numerical Methods
Solving Unsolvable Problems: Most nonlinear differential equations, complex integrals, and large systems of equations have no analytical solutions. Numerical methods are the only practical solution for weather prediction or airflow simulation over wings.
Handling Real-World Data: Real-world data is often discrete, messy, incomplete, or uncertain; numerical methods are specifically designed for these approximated systems.
Scientific Computing and Engineering:
Simulation: Fluid dynamics, structural analysis, climate modeling.
Optimization: Design optimization, resource allocation.
Data Analysis: Interpolation, regression, eigenvalue problems.
Powering Modern Technology:
Graphics: Physics simulation and rendering.
Finance: Monte Carlo methods and stochastic differential equations.
Signal Processing: Fast Fourier Transform (FFT).
Machine Learning: Gradient descent and numerical linear algebra.
Computational Efficiency: Faster than symbolic computation for large-scale problems and essential for real-time applications like navigation or control systems.
Historical Failures Due to Numerical Errors
Patriot Missile Failure (1991): Accumulated round-off error in a clock conversion caused a tracking error of approximately , causing the interceptor to miss.
Ariane 5 Explosion (1996): Caused by a floating-point value overflow during a conversion to a 16-bit integer.
Vancouver Stock Exchange (1982): Repeated truncation (chopping) caused the index to lose approximately half its value over 22 months.
Key Characteristics and Trade-offs
Approximation: Solutions require a stated error tolerance.
Discretization: Converting continuous problems into discrete counterparts.
Iteration: Using repeated convergent calculations.
Error Analysis: Controlling rounding and truncation errors.
Stability & Convergence: Ensuring small errors do not amplify.
Computational Cost: Balancing accuracy against speed and memory usage.
Common Examples of Numerical Methods
Root Finding: Newton–Raphson, Bisection.
Linear Systems: Gaussian Elimination, LU decomposition (solving ).
Integration: Trapezoidal Rule, Simpson’s Rule.
Differentiation: Finite difference approximations.
ODEs: Euler’s method, Runge–Kutta.
PDEs: Finite Element, Finite Volume, and Finite Difference Methods.
Optimization: Gradient Descent, Simplex.
Sources of Errors
Modeling Errors: Errors introduced when equations approximate physical systems (e.g., neglecting air resistance in projectile motion).
Blunders and Mistakes (Human Errors):
Blunders: Occur at any stage; avoided by fundamental knowledge and care.
Mistakes: Programming errors (e.g., typing instead of ) or mixing units (e.g., the Mars Climate Orbiter loss in 1999 due to mixing pound-seconds and newton-seconds).
Inherent (Data) Errors: Preexist in the problem statement (uncertain measurements, empirical constants). These can only be minimized with better data collection.
Machine Representation and Arithmetic (Round-off): Inevitable due to floating-point arithmetic (rounding and chopping).
Mathematical Approximation (Truncation/Discretization): Arise from using an approximate formulation for an exact problem (e.g., using finite terms of a Taylor series).
Accuracy vs. Precision
Accuracy: How closely a computed/measured value agrees with the true value.
Precision: How closely individual computed/measured values agree with each other.
Inaccuracy (Bias): Systematic deviation from the truth.
Imprecision (Uncertainty): The magnitude of the scatter in results.
Dartboard Analogy:
Precise but Inaccurate: Darts are tightly grouped but far from the bullseye.
Accurate but Imprecise: Darts are scattered around the bullseye but average out to the center.
Measuring Error
If is the exact value and is the approximation, the difference is the error.
Exact Value Formula: .
Absolute and Relative Errors
Absolute Error ():
Relative Error (): (provided ).
Percentage Relative Error ():
Comparison Example: Bridge vs. Rivet
Bridge: True length , measured as .
Rivet: True length , measured as .
Conclusion: While absolute errors are identical, the relative error shows the rivet measurement is far less reliable.
Approximation of by
True vs. Approximate Relative Error
When is unknown (common in iteration), the Approximate Relative Error () is used:
Scarborough Stopping Criterion: Iterate until \epsilon_a < \epsilon_s = (0.5 \times 10^{2-n})\%, which ensures result is correct to at least significant figures.
For , stopping at \epsilon_a < 0.05\%.
Significant Digits
Significant digits define the reliability of a number. They are the digits that can be used with confidence.
Requirement for Significant Digits: approximates to significant digits if is the largest non-negative integer satisfying: \left| \frac{X_E - X_A}{X_E} \right| < 5 \times 10^{-t}
Rules for Counting Significant Digits
All non-zero digits ( has 6).
Zeros between non-zeros ( has 4).
Leading zeros are NOT significant ( has 3: the 4, 5, and trailing 0).
Trailing zeros after a decimal are significant ( has 5).
Trailing zeros in integers are ambiguous; scientific notation should be used (e.g., has 3 vs has 5).
Significant Digits Examples
Case 1: approximating
Test : 0.0008097 < 0.0005 (No).
Test : 0.0008097 < 0.005 (Yes).
Result: 3 significant digits.
Case 2: approximating
Test : 6.6236 \times 10^{-7} < 5 \times 10^{-7} (No).
Test : 6.6236 \times 10^{-7} < 5 \times 10^{-6} (Yes).
Result: 6 significant digits.
Case 3: Approximation of by
Test : 1.510 \times 10^{-4} < 5 \times 10^{-4} (Yes).
Result: 4 significant digits.
Round-off Errors and Machine Representation
Floating-Point Representation
Numbers stored as .
: mantissa.
: base (usually 2).
: exponent.
Single Precision (32-bit): ~7 decimal digits.
Double Precision (64-bit): ~15–16 decimal digits.
Machine Epsilon (): Smallest number where ; for double precision, .
Binary error example: exactly in a computer because decimals like repeat forever in binary.
Chopping vs. Rounding
Example: keeping digits for
Chopping: Dropping extra digits (). Error is always biased in one direction ().
Rounding: Rounding the last kept digit (). Error is at most half a unit in last place ().
Arithmetic Effects: Subtractive Cancellation
Subtracting two nearly equal numbers destroys significant digits (loss of significance).
High-error example: Computing with 4-digit arithmetic.
True value: (Relative error ~$20\%$).
Algebraic Cure: Reformulate to .
Truncation Errors and Taylor Series
Truncation errors arise from approximating an infinite process with a finite one.
The Taylor Series Formula: where and the remainder is:
Taylor Series Examples
Approximating : Truncated after 3 terms (); true value , error .
Approximating from Base Point :
Zero order: ( error).
First order: ( error).
Fourth order: ( error).
Observation: Series converges slowly; higher orders or smaller steps improve it.
Approximating using :
Result:
True value:
Remainder bound (): predicts error bound of , very close to actual error ().
The Step-Size Dilemma
Total Error = Truncation Error + Round-off Error.
Decreasing step size () reduces truncation error but increases the number of operations and round-off impact.
Optimal : For central differences in double precision, . Making smaller than this increases total error.
Error Propagation
How input uncertainties () affect output volatility.
General Formulas
Statistical Formula:
Taylor Expansion Approximation:
Quick Propagation Rules (Relative Error )
: Absolute errors add ().
or : Relative errors add ().
: .
( is exact): .
Examples of Propagation
Sphere Volume: Given .
.
Result: .
Complex Function :
At ; .
Max relative error .
Stability and Conditioning
Definitions
Conditioning (Problem Property): Sensitivity of the exact solution to small input changes.
Stability (Algorithm Property): Whether the numerical method amplifies internal errors (round-off/truncation).
Condition Number ()
: Error unchanged.
\kappa > 1: Error amplified.
\kappa < 1: Error attenuated.
: Ill-conditioned problem.
Conditioning of Functions
: (always well-conditioned).
: (ill-conditioned for large ).
: (ill-conditioned near ).
: (ill-conditioned for ; subtractive cancellation).
Stability Examples
Ill-Conditioned System: A small change () in inputs to a nearly singular matrix results in a change in the solution.
Recursive Integral :
Forward Recursion (): Unstable. Errors are multiplied by ; by , the result is meaningless and negative.
Backward Recursion (): Stable. Errors are divided by at each step, yielding high precision even from a poor initial guess.