NumericalIntegration.jl
NumericalIntegration.jl copied to clipboard
Add Simpson's method on irregular grid + tests
Added the methods
integrate(x::AbstractVector, y::AbstractVector, ::Simpson)
integrate(x::AbstractVector, y::AbstractVector, ::SimpsonFast)
which work on irregular grids.
Also added a testset to test the new methods (together with Trapezoidal/Trapezoidal Fast)
Example:
julia> x = LinRange(0, sqrt(π/2), 10).^2
10-element Vector{Float64}:
0.0
0.01939254724438143
0.07757018897752573
0.17453292519943292
0.3102807559101029
0.484813681109536
0.6981317007977317
0.9502348149746904
1.2411230236404116
1.5707963267948963
julia> y = sin.(x)
10-element Vector{Float64}:
0.0
0.019391331771824363
0.0774924206719309
0.1736481776669303
0.305325997695113
0.4660435197025388
0.6427876096865393
0.8135520702629675
0.9461481568757503
1.0
julia> integrate(x, y, Simpson())
0.9998087840617803 #analytic result is 1