This is a tiny modern Fortran library to implement the Richardson extrapolation method for integration. For more information, see Ref. [1].
The library adds the extrapolation(array)
array reduction function. This is used as
result = extrapolation(array)
where the type of array(:)
is any of real(sp)
, complex(sp)
, real(dp)
or complex(dp)
and result
is an scalar of the corresponding type.
If array(:)
, of size array(i)
then, on output, result
represents the unnormalized integral of
Three cases are distinguished,
-
$N$ can be expressed as$2^M + 1$ for some$M\in\mathbb{N}$ : the extrapolation method is employed, and the expected accuracy is$\mathcal{O}(h^{2M})$ , where$h = (b-a)/2$ . -
$N$ cannot be expressed as$2^M + 1$ : the trapezoidal rule is employed and the expected accuracy is$\mathcal{O}(h^{2})$ , where$h = (b-a)/(N-1)$ . -
$N = 1$ : no integration andresult = array(1)
.
function extrapolation(array)
${type}$, intent(in) :: array(:)
${type}$ :: extrapolation
end function extrapolation
The extrapolation method computes an approximation to
by employing relatively inaccurate trapezoidal rule approximations. The method works by averaging these approximations such that error elimination is achieved iteratively [1]. This requires, that for a final result accurate up to
The implementation takes advantage of the fact that if the number of sampling points can be expressed as
An automated build is available for Fortran Package Manager users. This is the recommended way to build and use extrapolation integration in your projects. You can add extrapolation integration to your project dependencies by including
[dependencies]
Extrapolation_Integration = { git="https://github.com/irukoa/Extrapolation_Integration.git" }
in the fpm.toml
file.
[1] R. L. Burden y J. D. Faires, Numerical analysis, 9. ed., International ed. Belmont, Calif.: Brooks/Cole, 2011, pp. 213-220.