// integration on [0, 1] auto int01 = makeDEInt!real(0, 1); // int_0^1 x dx = 0.5 assert(int01.integrate((real x) => x).approxEqual(0.5)); // int_0^1 x^^2 dx = 1/3 assert(int01.integrate((real x) => x^^2).approxEqual(1/3.0)); // int_0^1 log(x)/sqrt(x) dx = -4 assert(int01.integrate((real x) => log(x)/sqrt(x)).approxEqual(-4, 1E-12, 1E-12)); // int_{-1}^0 log(-x)/sqrt(-x) dx = -4 assert(makeDEInt!real(-1, 0).integrate((real x) => log(-x)/sqrt(-x)).approxEqual(-4, 1E-12, 1E-12)); // integration on [-1, 1] auto int11 = makeDEInt!real(-1, 1); // int_{-1}^1 1/sqrt(1-x^2) dx = pi assert(int11.integrate((real x) => 1/(1 + x^^2)).approxEqual(PI/2, 1E-12, 1E-12)); // integration on [-inf, inf] auto intII = makeDEInt!real(-real.infinity, real.infinity); // Gaussian integral assert(intII.integrate((real x) => exp(-x^^2)).approxEqual(sqrt(PI))); import std.mathspecial; // integration on [1, inf] and integrand is expected to decay exponentially auto intFI = makeDEInt!real(1, real.infinity, Yes.isExpDecay); // compute incomplete gamma function: int_1^inf x * exp(-x) dx = Gamma(2, 1) assert(intFI.integrate((real x) => x * exp(-x)).approxEqual(gammaIncompleteCompl(2, 1) * gamma(2)));
This function create a instance of NumInt!(F, F) for the DE formula. * It is also known as "Tanh-sinh quadrature". * In the DE formula, the integration (1) is converted to (2). * (1) int_{xa}^{xb} f(x) dx * (2) int_{ta}^{tb} f(g(t)) g'(t) dt * * The type of DE formula is automatically decided from the given interval of the integration. * * Params: * xa = starting value of original integration. * xb = end value of original integration. * isExpDecay = if the integration is formed as int_a^b f(x) exp(-x) dx, this value is Yes. otherwise No. * trapN = division points of trapezoidal quadrature. * ta = starting value of integration transformed by DE-formula. * tb = starting value of integration transformed by DE-formula. * * Reference: *