Skip to content

A convenient interface to perform 1D, 2D and 3D numerical integrations. Uses QuadGK.jl, Cuba.jl, HCubature.jl and FastGaussQuadrature.jl as back-ends.

License

Notifications You must be signed in to change notification settings

aurelio-amerio/MultiQuad.jl

Repository files navigation

Build Status Coverage Status codecov.io

MultiQuad.jl

MultiQuad.jl is a convenient interface to perform 1D, 2D and 3D numerical integrations. It uses QuadGK and Cuba as back-ends.

Usage

quad

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.

Example 1

Compute:

using MultiQuad

func(x) = x^2*exp(-x)
quad(func, 0, 4)

Example 2

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

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.

Example 1

Compute:

using MultiQuad

func(y,x) = sin(x)*y^2
integral, error = dblquad(func, 1, 2, x->0, x->x^2, rtol=1e-9)

Example 2

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

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.

Example 1

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)

Example 2

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)

About

A convenient interface to perform 1D, 2D and 3D numerical integrations. Uses QuadGK.jl, Cuba.jl, HCubature.jl and FastGaussQuadrature.jl as back-ends.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages