Cheatsheet 4
FLOATING POINT NUMBERS
Normalized Form:
- Parameters:
where = base, = mantissa length, / = exponent bounds - IEEE Standards:
- Single Precision (32 bits):
- Double Precision (64 bits):
- Single Precision (32 bits):
Error Measures:
- Absolute Error:
- Relative Error:
- Result correct to ~
digits if or
Machine Epsilon (
- Rounding to nearest:
- Truncation:
- Rule:
where
Overflow/Underflow:
- Underflow: Result rounds to 0
- Overflow: Results in
or NaN
IEEE Arithmetic Operations:
- For
: where - Associativity is broken:
Cancellation Errors: Occur when subtracting similar-magnitude numbers with different signs
- Error bound for
: - Catastrophic when
Numerical Stability: Initial errors not magnified by algorithm
Conditioning:
- Well-conditioned problem: Small input changes → small output changes
- Ill-conditioned problem: Small input changes → large output changes
INTERPOLATION & SPLINES
Polynomial Interpolation: Given points
- Uniqueness Theorem: For
distinct data points, exists unique polynomial of degree
Monomial Form:
Lagrange Form:
- Direct computation without solving linear system
- High-degree polynomials (n>8) often exhibit Runge's phenomenon (excessive oscillation)
Hermite Interpolation: Uses function values and derivatives
- For interval
: and
Cubic Splines: Piecewise cubic polynomials with continuous first and second derivatives
- For
points: unknowns and equations - Need 2 boundary conditions:
- Clamped: Set
- Natural/Free:
- Periodic:
- Not-a-knot:
- Clamped: Set
Efficient Cubic Spline Equations (Interior nodes,
- Forms tridiagonal system for slopes
Parametric Curves: Express curve as
- Handles multi-valued functions (vertical lines, loops)
- Parameterization options:
- Node index (
) - Arc-length approximation:
- Node index (
ORDINARY DIFFERENTIAL EQUATIONS (ODEs)
First-Order ODE Form:
Higher-Order ODE:
- Convert to system of first-order ODEs by defining new variables:
Systems of ODEs:
Numerical Methods Categories:
- Single-step vs. Multi-step
- Explicit vs. Implicit
- Fixed vs. Variable timestep
Errors:
- Local Truncation Error (LTE): Error in one step assuming exact previous values
- Global Error: Total accumulated error (
)
Determining LTE
- Replace approximations on RHS with exact versions
- Taylor expand all RHS quantities about time
- Taylor expand the exact solution
to compare against - Compute difference
. Lowest degree non-cancelling power of gives the LTE
Test Equation
- Apply a given time stepping scheme to our test equation (
) - Find the closed form of its numerical solution and error behaviour
- Find the conditions on the timestep
that ensure stability (error approaching zero)
Forward Euler (Explicit, single-step):
- LTE =
, Global Error = - Conditionally stable:
for test equation
Backward Euler (Implicit, single-step):
- LTE =
, Global Error = - Unconditionally stable
Improved/Modified Euler (Explicit, single-step):
- LTE =
, Global Error = - Conditionally stable:
Midpoint Method (Explicit, single-step):
- LTE =
, Global Error =
Runge-Kutta Methods (Explicit, single-step):
- 4th Order RK (RK4):
- LTE =
, Global Error =
Multi-step Methods:
- BDF2 (Implicit):
- LTE =
, Global Error =
- LTE =
- Adams-Bashforth (Explicit):
- LTE =
, Global Error =
- LTE =
Adaptive Time-Stepping:
- Use two methods of different order
- Estimate error:
- Adjust step size:
where is order of lower method - Often use safety factor
(0.5-0.9) to avoid too-large steps