Skip to main content

Module numerical

Module numerical 

Source
Expand description

Numerical utilities for copula computations.

This module provides various numerical methods useful for copula analysis:

  • Numerical integration (trapezoidal rule, Simpson’s rule)
  • Root finding (bisection, Brent’s method)
  • Numerical differentiation
  • Interpolation methods

§Example

use copula_core::numerical::{bisection, trapezoid_integrate};

// Find root of f(x) = x^2 - 2 on [0, 2]
let root = bisection(|x| x * x - 2.0, 0.0, 2.0, 1e-10, 100).unwrap();
assert!((root - 2.0_f64.sqrt()).abs() < 1e-9);

// Integrate f(x) = x^2 from 0 to 1
let integral = trapezoid_integrate(|x| x * x, 0.0, 1.0, 1000);
assert!((integral - 1.0/3.0).abs() < 1e-6);

Functions§

bisection
Find a root of f(x) = 0 using the bisection method.
central_diff
Numerical derivative using central difference (more accurate).
forward_diff
Numerical derivative using forward difference.
linear_interp
Linear interpolation between two points.
log_sum_exp
Compute the log-sum-exp trick for numerical stability.
second_diff
Second derivative using central difference.
simpson_integrate
Numerical integration using Simpson’s rule.
trapezoid_integrate
Numerical integration using the trapezoidal rule.