integral
-
constexpr Complex integral(Complex (*f)(Complex, const std::vector<Complex (*)(Complex)> &fargs, std::vector<Complex>), const Complex &a, const Complex &b) noexcept
-
constexpr Complex integral(Complex (*f)(Complex, const std::vector<Complex (*)(Complex)> &fargs, std::vector<Complex>), const Complex &a, const Complex &b, const std::vector<Complex (*)(Complex)> &fargs) noexcept
-
constexpr Complex integral(Complex (*f)(Complex, const std::vector<Complex (*)(Complex)> &fargs, std::vector<Complex>), const Complex &a, const Complex &b, const std::vector<Complex> &args) noexcept
-
constexpr Complex integral(Complex (*f)(Complex, const std::vector<Complex (*)(Complex)> &fargs, std::vector<Complex>), const Complex &a, const Complex &b, const std::vector<Complex (*)(Complex)> &fargs, const std::vector<Complex> &args) noexcept
Evaluates the integral of a complex function at a point \(z\) from integral bounds \(a\) to \(b\). The integral is implemented using 15-point Gauss-Kronrod quadrature [1].
Parameters
- const Complex &z
A complex number.
- const Complex &a
Lower integration bound. Use
NINFfrom<Constants.hpp>for \(-\infty\).
- const Complex &b
Upper integration bound. Use
INFfrom<Constants.hpp>for \(\infty\).
Returns
- type Complex
A complex number.
This function evaluates the following definite integral of a function \(f\):
\[\int_{a}^{b} f(z) dz\]
To approxiate the integral, the following numerical quadrature method is used:
\[\int_{a}^{b} f(z) dz \approx \sum_{i = 1}^{n}w_if(z_i)\]
for some pre-tabulated Kronrod weights \(w\) and evaluation points \(z\).
Example
auto fn = [](Complex z) { return z*z }; // z^2
std::cout << integral(fn, 0, 1) << "\n"; // z^3/3 |0 -> 1 = 1/3
Output:
0.333333 + 0j
References