A Collection of Quadrature Rules in Julia
Author JuliaGNI
Popularity
0 Stars
Updated Last
2 Years Ago
Started In
December 2020

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.

## Installation

QuadratureRules.jl and all of its dependencies can be installed via the Julia REPL by typing

`]add QuadratureRules`

## Basic Usage

`julia> using QuadratureRules`

a `QuadratureRule` can be created by calling any one of the provided constructors, for example

```julia> quad = TrapezoidalQuadrature()

The `QuadratureRule` type has the following fields:

• `order` the order of the method,
• `nodes` the nodes,
• `weights` the 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} = N`
• `nodes(quad::QuadratureRule) = quad.nodes`
• `order(quad::QuadratureRule) = quad.order`
• `weights(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:

• `RiemannQuadratureLeft`
• `RiemannQuadratureRight`
• `MidpointQuadrature`
• `TrapezoidalQuadrature`

as well as functions for generating quadrature rules with an arbitrary number of nodes on the fly:

• `ClenshawCurtisQuadrature`
• `GaussChebyshevQuadrature`
• `GaussLegendreQuadrature`
• `LobattoChebyshevQuadrature`
• `LobattoLegendreQuadrature`

## References

``````@misc{Kraus:2020:QuadratureRules,