Cheatsheet 3
1 Floating Point Numbers
Normalized Form of Real Numbers
- Representation:
where - System Parameters:
where: = base = precision (mantissa length) = exponent bounds
- IEEE Standards:
- Single Precision (32 bits):
- Double Precision (64 bits):
Error Metrics
- Single Precision (32 bits):
- Absolute Error:
- Relative Error:
- Rule of Thumb: Result correct to
digits if - Machine Epsilon (
): Smallest value where - Rounding:
- Truncation:
Round-off Error Analysis
For, error bound: $$E_{rel} \leq \frac{|a|+|b|+|c|}{|a+b+c|}(2E + E^2)$$
Catastrophic Cancellation
- Rounding:
- Occurs when subtracting numbers of similar magnitude containing errors
- Critical when
Algorithm Stability - Well-conditioned problem: Small changes in input → small changes in output
- Ill-conditioned problem: Small changes in input → large changes in output
- Stable algorithm: Does not magnify errors in computation
2 Interpolation & Splines
Polynomial Interpolation
- Unisolvence Theorem: Given
distinct data points, there exists a unique polynomial of degree that interpolates the data - Monomial Form:
- Lagrange Form:
where: $$L_i(x) = \prod_{j=1,j\neq i}^n \frac{x-x_j}{x_i-x_j}$$
Hermite Interpolation - Fits polynomials given function values and derivatives
- On interval
: - Coefficients:
- Where
and
Cubic Splines
- Piecewise cubic polynomials with continuous first and second derivatives
- Requirements:
data points, unknowns - Constraints:
- Interpolation:
, - First derivatives match:
- Second derivatives match:
- Plus 2 boundary conditions
Boundary Conditions
- Interpolation:
- Clamped: Specified first derivatives at endpoints
- Natural/Free:
- Periodic:
, - Not-a-knot: Third derivatives match at second and second-to-last knots
Efficient Tridiagonal System
For interior nodes: $$\Delta x_i s_{i-1} + 2(\Delta x_{i-1}+\Delta x_i)s_i + \Delta x_{i-1}s_{i+1} = 3(\Delta x_i y'{i-1} + \Delta xy'_i)$$
Parametric Curves
- Represent curve as
- Can handle self-intersections and vertical segments
- Arc-length parameterization:
represents distance along curve - Common parameterizations:
- Node index:
- Approximate arc-length:
- Node index:
3 Ordinary Differential Equations
Initial Value Problem
- Form:
with - Systems of ODEs: Multiple interacting variables (vector form)
- Higher-Order ODEs: Involve derivatives of order > 1
- Convert to first-order system by substitution:
Time-Stepping Methods
- Convert to first-order system by substitution:
- Local Truncation Error (LTE): Error in a single step
- Global Error: Total accumulated error (typically one order less than LTE)
Forward Euler (Explicit, Single-step) - LTE:
- Conditionally stable:
Backward Euler (Implicit, Single-step) - LTE:
- Unconditionally stable
Improved/Modified Euler (Explicit, Single-step) - LTE:
- Conditionally stable:
Trapezoidal Rule (Implicit, Single-step) - LTE:
Midpoint Method (Explicit, Single-step) - LTE:
4th Order Runge-Kutta (Explicit, Single-step) - LTE:
Multi-step Methods
BDF (Implicit, Multi-step)
- BDF1 = Backward Euler
- BDF2:
- LTE:
Adams-Bashforth (Explicit, Multi-step) - 2nd order:
- LTE:
Adaptive Time-Stepping
- Run methods of order
and - Estimate error:
- Adjust step size: