Function integrateQAWS
Calculate an integral over the finite interval (a
,b
),
where the integrand has algebraic and/or logarithmic endpoint
singularities of a known type.
The integrand is taken to be on the form
alpha beta
f(x) (x - a) (b - x) w(x)
where f(x)
is the given function and w(x)
is
specified by setting the weight
parameter to one of the following:
Weight .unity: w(x) = 1
Weight .logxa: w(x) = log(x-a)
Weight .logbx: w(x) = log(b-x)
Weight .logab: w(x) = log(x-a) log(b-x)
A globally adaptive subdivision strategy is applied,
with modified
Clenshaw–Curtis integration on those subintervals
which contain a
or b
.
Example
// Calculate the integral of 1/(sqrt(1-x^^2) * (x+1.5)).
// Another way to write this integrand is
// (x-(-1))^^(-0.5) * (1-x)^^0.5 / (x+1.5),
// so we set alpha = beta = -0.5.
real f(real x) { return 1/(x + 1.5L); }
auto i = integrateQAWS(&f, -1.0L, 1.0L, -0.5L, -0.5L, Weight .unity, 1e-15L);