A Collection of Quadrature Rules in Julia
Author JuliaGNI
0 Stars
Updated Last
11 Months Ago
Started In
December 2020

Quadrature Rules

Stable Dev PkgEval Status Build Status Coverage DOI

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 QuadratureRules

Basic Usage

After loading the Quadrature Rule module by

julia> using QuadratureRules

a 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:

  • 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)

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)

Quadrature Rules

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


If you use QuadratureRules.jl in your work, please consider citing it by

  title={QuadratureRules.jl: A Collection of Quadrature Rules in Julia},
  author={Kraus, Michael},