# DEInt

A struct for performing numerical integration by double-exponential (DE) formula. It is also known as "Tanh-sinh quadrature". In 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

This struct calculates reusable state in advance. The type of DE formula is automatically decided from the given interval of the integration.

Reference:

## Constructors

this
this(F xa, F xb, Flag!"isExpType" isExpType = No.isExpType, size_t trapN = 0, F ta = F.nan, F tb = F.nan)

Initialize an object for computing DE integration.

## Members

### Functions

integrate
F integrate(scope Fn func)

Execute integration of func by DE formula.

setParams
void setParams(F xa, F xb, Flag!"isExpType" isExpType = No.isExpType, size_t trapN = 0, F ta = F.nan, F tb = F.nan)

Initialize an object for computing DE integration.

### Properties

isExpType
bool isExpType [@property getter]
ta
real ta [@property getter]
tb
real tb [@property getter]
trapN
size_t trapN [@property getter]

Return the set value

type
string type [@property getter]

Return type of integration. The First and second charactor of the return value are explain the the starting value or end value of integration is finite value ('F') or infinity 'I'. If the return value has the third character and its value is 'E', the integration is formed as int_{xa}^{xb} f(x) exp(-x) dx

weights
immutable(F)[] weights [@property getter]

Return weights of each division points.

xa
real xa [@property getter]
xb
real xb [@property getter]

Return the set value

xs
immutable(F)[] xs [@property getter]

Return division points (computing points) of trapezoidal quadrature for DE formula.

## Examples

```1 // integration on [0, 1]
2 auto int01 = DEInt!real(0, 1);
3 assert(int01.type == "FF");
4
5 // int_0^1 x dx = 0.5
6 assert(int01.integrate((real x) => x).approxEqual(0.5));
7
8 // int_0^1 x^^2 dx = 1/3
9 assert(int01.integrate((real x) => x^^2).approxEqual(1/3.0));
10
11
12 // integration on [-inf, inf]
13 auto intII = DEInt!real(-real.infinity, real.infinity);
14 assert(intII.type == "II");
15
16 // Gaussian integral
17 assert(intII.integrate((real x) => exp(-x^^2)).approxEqual(sqrt(PI)));
18
19 import std.mathspecial;
20 // integration int_1^inf x * exp(-x) dx = Gamma(2, 1)
21 auto intFI = DEInt!real(1, real.infinity, Yes.isExpType);
22 assert(intFI.type == "FIE");
23
24 // incomplete gamma function
25 assert(intFI.integrate((real x) => x).approxEqual(gammaIncompleteCompl(2, 1) * gamma(2)));```