|
|
◆ qk15()
Finite interval quadrature (15 point Gauss-Kronrod rule)
- Purpose
- This routine computes
I = integral of f over [a, b] with error estimate, and
J = integral of abs(f) over [a, b],
where f is a given function defined by a user supplied subroutine.
The integral will be evaluated with the 15 point Gauss-Kronrod rule.
- Returns
- (result, abserr)
result (float):
Approximation to I = integral of f over [a, b].
abserr (float):
Estimate of the modulus of the absolute error, which should equal or exceed the true error.
- Parameters
-
| [in] | f | The user supplied subroutine which calculates the integrand function f(x) defined as follows. _CODE def f(x): return computed function value f(x) _ENDCODE |
| [in] | a | Lower limit of integration. |
| [in] | b | Upper limit of integration. |
- Reference
- SLATEC (QUADPACK)
- Example Program
- Compute the following integral.
∫ 1/(1 + x^2) dx [0, 4] (= atan(4))
def f(x):
return 1/(1 + x**2)
def TestQk15():
a = 0
b = 4
s, abserr = qk15(f, a, b)
print(s, abserr)
def qk15(f, a, b) Finite interval quadrature (15 point Gauss-Kronrod rule)
- Example Results
>>> TestQk15()
1.3258176613637855 0.0014827239412162237
|