Skip to main content

quad_weighted

Function quad_weighted 

Source
pub fn quad_weighted(
    f: impl FnMut(f64) -> f64,
    a: f64,
    b: f64,
    weight: Weight,
    options: &WeightedOptions,
) -> Result<WeightedResult, ErrorsJSL>
Expand description

∫_a^b f(x) w(x) dx for the weights of SciPy’s quad(weight=…):

  • Cos(ω), Sin(ω) on [a, b]: adaptive Filon-Clenshaw-Curtis quadrature, which interpolates f alone and integrates the oscillation exactly, so its cost does not grow with ω; on [a, ∞), the integrals over successive half-periods form an alternating series whose limit is extrapolated by Wynn’s ε algorithm (QAWF’s idea).
  • Algebraic: tanh-sinh quadrature of f(x)w(x), which tolerates the integrable endpoint singularities; the endpoint distances are formed exactly, so (b − x)^β loses nothing near b.
  • Cauchy(c): with d = min(c − a, b − c), the principal value is ∫₀^d (f(c + t) − f(c − t))/t dt (a smooth integrand) plus the ordinary integral of f(x)/(x − c) over the part of [a, b] outside [c − d, c + d].