MultiQuad.jl is a convenient interface to perform 1D, 2D and 3D numerical integrations. It uses QuadGK and Cuba as back-ends.
quad(arg::Function, x1, x2; method = :quadgk, kwargs...)
It is possible to use quad
to perform 1D integrals of the following kind:
The supported integration method are:
:quadgk
:vegas
:suave
It is suggested to use :quadgk
(the default option).
See QuadGK and Cuba.jl for all the available keyword arguments.
Compute:
using MultiQuad
func(x) = x^2*exp(-x)
quad(func, 0, 4)
It is possible to compute integrals with unit of measurement using Unitful
.
For example, let's compute:
using MultiQuad
using Unitful
func(x) = x^2
quad(func, 1u"m", 5u"m")
dblquad(arg::Function, x1, x2, y1::Function, y2::Function; method = :cuhre, kwargs...)
It is possible to use quad
to perform 2D integrals of the following kind:
The supported integration method are:
:cuhre
(default):vegas
:suave
:divonne
It is suggested to use :cuhre
(the default option).
See Cuba.jl for all the available keyword arguments.
Compute:
using MultiQuad
func(y,x) = sin(x)*y^2
integral, error = dblquad(func, 1, 2, x->0, x->x^2, rtol=1e-9)
It is possible to compute integrals with unit of measurement using Unitful
.
For example, let's compute:
using MultiQuad
using Unitful
func(y,x) = sin(x)*y^2
integral, error = dblquad(func, 1u"m", 2u"m", x->0u"m^2", x->x^2, rtol=1e-9)
tplquad(arg::Function, x1, x2, y1::Function, y2::Function, z1::Function, z2::Function; method = :cuhre, kwargs...)
It is possible to use quad
to perform 3D integrals of the following kind:
The supported integration method are:
:cuhre
(default):vegas
:suave
:divonne
It is suggested to use :cuhre
(the default option)
See Cuba.jl for all the available keyword arguments.
Compute:
using MultiQuad
func(z,y,x) = sin(z)*y*x
integral, error = tplquad(func, 0, 4, x->x, x->x^2, (x,y)->2, (x,y)->3*x)
It is possible to compute integrals with unit of measurement using Unitful
.
For example, let's compute:
using MultiQuad
using Unitful
func(z,y,x) = sin(z)*y*x
integral, error = tplquad(func, 0u"m", 4u"m", x->0u"m^2", x->x^2, (x,y)->0, (x,y)->3)