This package provides quadrature rules for numerical integration, e.g., in finite element methods or variational integrators. It provides a unified interface for quadrature rules from different sources and algorithms for the computation of quadrature rules with an arbitrary number of nodes and weights in arbitrary precision.
QuadratureRules.jl and all of its dependencies can be installed via the Julia REPL by typing
]add QuadratureRulesAfter loading the Quadrature Rule module by
julia> using QuadratureRulesa QuadratureRule can be created by calling any one of the provided constructors, for example
julia> quad = TrapezoidalQuadrature()
QuadratureRule{Float64,2}(2, [0.0, 1.0], [0.5, 0.5])The QuadratureRule type has the following fields:
orderthe order of the method,nodesthe nodes,weightsthe weights.
A functor is defined, which integrates functions f(x) using the quadrature rule:
julia> quad(x -> x^2)
0.5
There are several convenience functions for accessing the fields:
nnodes(::QuadratureRule{T,N}) where {T,N} = Nnodes(quad::QuadratureRule) = quad.nodesorder(quad::QuadratureRule) = quad.orderweights(quad::QuadratureRule) = quad.weights
as well as a function for looping over all nodes and weights:
Base.eachindex(quad::QuadratureRule) = eachindex(quad.nodes, quad.weights)
There are several pre-tabulated quadrature rules:
RiemannQuadratureLeftRiemannQuadratureRightMidpointQuadratureTrapezoidalQuadrature
as well as functions for generating quadrature rules with an arbitrary number of nodes on the fly:
ClenshawCurtisQuadratureGaussChebyshevQuadratureGaussLegendreQuadratureLobattoChebyshevQuadratureLobattoLegendreQuadrature
If you use QuadratureRules.jl in your work, please consider citing it by
@misc{Kraus:2020:QuadratureRules,
title={QuadratureRules.jl: A Collection of Quadrature Rules in Julia},
author={Kraus, Michael},
year={2020},
howpublished={\url{https://github.com/JuliaGNI/QuadratureRules.jl}},
doi={10.5281/zenodo.4310382}
}
We are using git hooks, e.g., to enforce that all tests pass before pushing. In order to activate these hooks, the following command must be executed once:
git config core.hooksPath .githooks