|
|
◆ qk15()
| function qk15 |
( |
f::Function |
, |
|
|
a::Real |
, |
|
|
b::Real |
|
|
) |
| |
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 (Float64):
Approximation to I = integral of f over [a, b].
abserr (Float64):
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 function f(x) returns computed function value f(x). end _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))
function TestQk15()
f(x) = 1/(1 + x^2)
a = 0
b = 4
s, abserr = qk15(f, a, b)
println(s, " ", abserr)
end
function qk15(f::Function, a::Real, b::Real) Finite interval quadrature (15 point Gauss-Kronrod rule)
- Example Results
> TestQk15()
1.3258176613637855 0.0014827239412162237
|