Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [quadrature]

Also called numerical integration, quadrature refers to the approximation of an integral made by evaluating the integrand at a finite number of points.

0
votes
0answers
39 views

Finite Element Nodal Point Field Variable Recovery

I am working on a program which takes values computed at the quadrature points from the finite element method and extrapolates them to the nodal points. I am working with a 10 node tetrahedral element ...
6
votes
1answer
106 views

How do I integrate a function defined over an arbitrary area?

Let's say, I have a compact area $S$ (for example a circle, a square or some arbitrary polygon) and a function $f: S \rightarrow \mathbb{R}$. I want to numerically calculate the Integral $$ \int_S f(\...
1
vote
2answers
146 views

How many quadrature points should I use?

I am trying to compute the following integration $$ \int_0^\infty e^{-y}y^{a/2}L_c^b(y)L_e^d(y)dy $$ using the generalized Gauss-Laguerre quadrature routine in the GNU Scientific Library. Here the $L$'...
1
vote
0answers
18 views

Algorithm for integrating a 6D function in a Morse-Smale 3D cell

Lets say that one has a scalar field defined in 3D space for whose gradient he wants to find the Morse-Smale Complex for later performing an integration of several hexa-dimensional functions over ...
4
votes
1answer
115 views

What is the best numerical method for a six dimensional spherical integral?

I am trying to do integrals of the type $$ \int d^3\vec{p} \int d^3\vec{p}' e^{-p^2} e^{-{p'}^2}f(\vec{p}, \vec{p}') $$ where $\vec{p}$ and $\vec{p}'$ are three dimensional vectors represented using ...
7
votes
3answers
125 views

Evaluating an integral numerically at many points

Given a real function $f$, how can one efficiently evaluate $\int_0^{a_i}f(x)dx$ for millions of different $a_i$? Applying a standard quadrature method (such as Simpson's rule or Gaussian quadrature) ...
11
votes
1answer
238 views

For noisy or fine-structured data, are there better quadratures than the midpoint rule?

Only the first two sections of this long question are essential. The others are just for illustration. Background Advanced quadratures such as higher-degree composite Newton–Cotes, Gauß–Legendre, ...
3
votes
0answers
103 views

Convergence of Gauss quadrature for a discontinuous function

Is there a known error estimate for Gaussian quadrature when applied to a discontinuous function? For simple one-dimensional experiments, the error appears to be bounded by $C h$, where $C$ is some ...
1
vote
0answers
32 views

Stability of different quadrature rules in 1st-kind Volterra integral equation

I am dealing with a integral equation $$ f'(t) = -\int_0^t K(s) f(t-s)\quad t\in [0,t_\max] \tag{1}$$ in which $f(t)$ and $f'(t)$ are known, well-behaved functions of $t$ and $K(t)$ is the unknown. In ...
4
votes
1answer
139 views

Kernel-based differentiation

Consider a $\mathcal{C}^1$ function $V:\Omega\rightarrow\mathbb{R}$ where $\Omega\subset\mathbb{R}^n$. If a random vector $X$ has a parametric density $p_\theta(\textbf{x})$ that's smooth in its ...
6
votes
2answers
110 views

Building Gaussian-type quadrature schemes with Zernike polynomials

The abscissas for Gauss quadrature are given by the zeros of the Legendre polynomials. The Legendre polynomials form an orthogonal set over $[-1, 1]$, and it is shown in (for instance) Kress that the ...
-4
votes
1answer
55 views

Modulus (absolute) of a function, its quadrature, and relevance of zeros

Modulus of a (discretized) function, $|f_h(x)|$, where $h$ refers to the mesh spacing, would, in general, have zeros, and those zeros would not necessarily lie exactly at the mesh points. A naive <...
0
votes
1answer
67 views

Reference for Dunavant Quadrature Implementations

I am using Dunavant quadrature in my software, specifically this file by John Burkardt. Recently, I wanted to convert the code into a constexpr code in C++. But ...
4
votes
1answer
324 views

2D numerical integration with infinite limit (C++)

In order to integrate a two dimensional function of the form $$\int_{1}^\infty \int_{-\sqrt{x^2-1}}^{\sqrt{x^2-1}} e^{-x} \rm{d}y \rm{d}x,$$ I have been attempting to use the following code (written ...
1
vote
1answer
456 views

Line integral along the edge of an isoparametrically mapped triangle

I need to integrate the following function on the line segment from $P_{1} = \begin{bmatrix} -2\\-1 \end{bmatrix}$ to $P_{2} = \begin{bmatrix} 1\\2 \end{bmatrix}$: $$\int_{P_{1}}^{P_{2}} 4x + y \ ds$$...
0
votes
1answer
269 views

Computation of stiffness matrix with variable coefficient

I am implementing a finite element solver (in 2D) to solve the generic differential equation : $$-\nabla(a(x) \nabla u) = f$$ Brief explanation By integrating and multipling by a test function, the ...
1
vote
0answers
104 views

Numerical integral of oscillating function with known zeros

I have a function that I need to numerically integrate from $0$ to $+\infty$, given by: $$I = \int_0^{+\infty} \mathrm{d}x\,x\,T^2(x)f(x)$$ where $T^2$ is an interpolated function that goes to $1$ ...
0
votes
2answers
104 views

Spherical volume integral from pre-calculated points - which algorithm is best?

I need a fast and accurate method to calculate 3d spherical volume integrals. I have pre-calculated data of high precision that just needs a few trivial manipulations before each integration step - ...
1
vote
2answers
261 views

Vandermonde matrix DG Hestaven

I am trying to understand the nodal and modal basis formulation from the book of Hesthaven (Nodal Discontinuous Galerkin Methods, Hesthaven, Jan S., Warburton, Tim). For $N=2$, I get the Vandermonde ...
1
vote
0answers
79 views

solving numerically a 2D integral by using simps and quad combined

I have the following function $$f(x,y) =\left(\frac{1}{\exp(x-E_f)+1}-\frac{1}{\exp(x-y-E_f)+1} \right)\frac{1}{\sqrt{4-xy}}$$ I want to integrate it using Python 3. The domain of the $y$ variable ...
1
vote
1answer
40 views

Methods for integration of oscillatory complex vectors as a function of time

I'm attempting to solve a problem of the form: $$ \mathbf{a}^{(n+1)}(t) = \int_{0}^{t}d\tau e^{i\mathbf{H}\tau} \mathbf{D}(\tau)e^{-i\mathbf{H}\tau}\mathbf{a}^{(n)}(\tau) $$ Where $\mathbf{D}(\tau)$ ...
3
votes
2answers
157 views

How to estimate the error of trapezoidal rule using discrete data?

How can I estimate the error of a result obtained by using the trapezoidal rule if I don't have the function that describes my problem? The only thing I have is discrete points.
1
vote
0answers
70 views

Quadrature in finite element methods | How should I compute integrals involving the solution of the last time step?

Let $\Delta\subseteq\mathbb R^2$ denote the triangle spanned by $(0,0)$, $(1,0)$ and $(0,1)$ and $$\mathbb P_r(\Delta):=\left\{p:\Delta\to\mathbb R\mid p(x)=\sum_{|\alpha|\le r}\lambda_\alpha x^\alpha\...
7
votes
1answer
205 views

Gaussian Numerical Differentiation

Gaussian quadrature improves on Newton-Cotes formulas by allowing the abscissas to vary along with the weights in order to integrate higher order polynomials. Can this idea be extended to numerical ...
9
votes
2answers
199 views

Integrating Lagrange polynomials with many nodes, round-off

Given a set of points $\{x_j\}_{j=1}^n$ in $[-1, 1]$, I would like to compute $$ \int_{-1}^{1} L_i(x)\,\text{d} x $$ exactly. $L_i$ is the Lagrange polynomial with respect to the points $x_j$ with $...
1
vote
0answers
385 views

Numerical Double integration with endpoint singularity in scipy Python gives incorrect answer

I am trying to integrate the following function in Python, $\int_{0}^{\infty}\int_{0}^{\infty} \dfrac{e^{-x-y}}{B(x,y)}dx dy$, where $B(x,y)$ is the beta function - $B(x,y) = \int_0^{1}a^{x-1}(1-a)^{...
6
votes
1answer
189 views

Numerical quadrature in Discontinuous Galerkin

I would like to know which is the best way to integrate numerically Legendre polynomials. I am building up a Discontinuous Galerkin CFD code for which Legendre polynomials are used as basis functions ...
0
votes
1answer
151 views

How to increase precision of Gauss-Legendre Quadrature in MAPLE? [closed]

I've written a simple legendre quadrature in MAPLE to compute the integral $\int_{-1}^1 r^2 dr = \frac{r^3}{3} |_{-1}^1=\frac{2}{3}$ ...
6
votes
1answer
141 views

Numerical integration of a hypergeometric function

The Task Let $z_1, z_2, z_3$ be positive real numbers and define $$ r(\mathbf{z}):= \int_0 ^\infty (t+z_1)^{-3/2}(t+z_2)^{-3/2}(t+z_3)^{-1/2}\text{d}t. $$ The task is to compute $r$ numerically in ...
2
votes
2answers
153 views

computing Newton-Cotes weights

For the closed Newton-Cotes quadrature over $[x_1, x_n]$, the coefficients $H_{n,i}$ for $$ \int_{x_1}^{x_n} f(x)\:\text{d}x = h \sum_{i=1}^n H_{n,i} \; f(x_i) $$ are given explicitly by $$ H_{n,r+1} =...
3
votes
1answer
87 views

Numerical evaluation of gaussian-like integral expressible as a recurrence relation

I'm looking to numerically evaluate $\log f_p(z)$ and its derivative $f^\prime_p(z)/f_p(z)$ accurately and efficiently in floating-point, where $$ f_p(z)=\int_0^\infty r^{p-1} \exp\left(-\tfrac{1}{2} ...
2
votes
2answers
121 views

Are there mesh generation methods that allow ugly elements?

Most mesh generation software seems to be aimed at building nicely shaped elements for FEM. I'm curious about a different situation: I need to numerically integrate over an irregular region. I don't ...
0
votes
1answer
127 views

fast adaptive quadrature on equispaced 2-D grid

I need to numerically evaluate 2-D integrals of the form: $$ \mathcal{I}(\theta) = \int_{0}^{1} \int_0^1 \varphi_\theta(x,y) dx dy $$ where $\varphi_\theta$ is a family of smooth functions indexed by ...
0
votes
1answer
895 views

Faster code for double integration using Gauss-Legendre quadrature

I came with a the following code to evaluate a double integral using Gauss Legendre quadrature in MatLab ...
3
votes
2answers
128 views

Adaptive tolerance for nested quadrature

I am doing a nested integral via quadrature. To give a definite example, lets say: $$ \int_0^2dx \left[x + \int_0^x dy \, 2y\right] $$ So effectively I'm integrating $x + x^2$ from 0 to 2 (although ...
0
votes
2answers
114 views

Adaptive numerical integration of a univariate vector integrand

Background & Problem formulation I'm trying to write a simple program in C++ that performs adaptive numerical integration of vector valued integrands (in one variable), i.e. $$\int_a^b \bar{f}(...
0
votes
1answer
43 views

Choice of Newton-Cotes formulae for regularly gridded multi-dimensional data

I have a function evaluated on a regular 5D grid with 21 points per dimension (so $21^{5}$ points total). I need to evaluate the integral of the function over all 5 dimensions, so I was planning on ...
5
votes
0answers
101 views

Numerical computation of two-sided (bilateral) Laplace transform

I need to compute the two-sided (bilateral) Laplace transform of a numerically given function $F$, $$ I(t) = \int_{-\infty}^{+\infty} {dx} \, e^{-x} \, F(x + t) ~, $$ where $F(x)$ has some sharp ...
0
votes
2answers
180 views

Calculating integrals for a function approximated by Chebyshev polynomials

Setup (complete, but all very standard): My problem is how to best calculate the cumulative integral of a function which comes out of Spectral Collocation with a chebyshev basis. Take some function $...
9
votes
1answer
207 views

When is it advantageous to iterate integrals numerically?

If there is an $(n+1)$-dimensional integral of the form $$ \int_{[0,1]^{n+1}} f(x, y)\,\mathrm{d}^n x \,\mathrm{d}y,$$ normally one would evaluate this using a multi-dimensional integration library ...
4
votes
1answer
95 views

Efficient Quadrature Methods for Indicator Functions?

I am looking to numerically solve many different integrals where the integrand is simply the indicator function for a region (i.e. 1 on the region, 0 outside. This is for measuring areas). The ...
5
votes
2answers
9k views

Plot integral function with scipy and matplotlib

I want to plot a numerical integral function of some function $f$ using scipy and matplotlib. How can I do this? I tried the ...
3
votes
1answer
326 views

Using Gauss quadrature for a discontinuous integrand

Suppose I have the following integral: $$\int_{-1}^1 \int_{-1}^1 C_if(x,y)dxdy$$ where \begin{equation} C_i= \begin{cases} C_1 \quad \text{in }\Omega_1\\ C_2 \quad \text{in } \Omega_2\\ \end{cases} \...
3
votes
0answers
41 views

Not sure if sparse quadrature routine is working correctly?

I have written a sparse quadrature routine to integrate multidimensional Gaussian integrals. I'm trying to show convergence plots in my thesis and demonstrate that the code works correctly. I am in ...
10
votes
5answers
4k views

C++ library for numerical intergration (quadrature)

I have my own little subroutine for numerical integration (quadrature), which is a C++ adaptation of an ALGOL program published by Bulirsch & Stoer in 1967 (Numerische Mathematik, 9, 271-278). I ...
3
votes
1answer
339 views

Numerical integration with singularities

I need to compute some integrals numerically. The integrand is this: $$f(x,y) = \left ( \sum_{mn=-j}^{j}A(m,n)\dfrac{\tan^{2j+m+n}(x/2)}{(1+\tan^2(x/2))^{2j}}e^{iy(n-m)} \right )^{N}$$ Note: sums ...
1
vote
1answer
164 views

Quadrature order for finite elements and time dependent discontinuous Galerkin

When setting up a finite element system you have to use quadrature to calculate the integrals. I'm having trouble understanding what order rule to use. I know of some rules of thumb, for example with ...
2
votes
1answer
211 views

Monte Carlo Double Integration Implementation

Am implementing a monte carlo integration routine to compute this double integral in eqn 0.3 of page 2 of this paper 'Mobius energy of knots and unknots', Annals of Mathematics, http://www.math.ucsb....
1
vote
1answer
92 views

Numerical quadrature when locations of singularities are approximate

I'd like to numerically integrate $\frac{1}{\sqrt{f(x)}}$ on an interval between two consecutive zeros of the function $f(x)$, which makes the integrand singular at two endpoints. Standard practice ...
1
vote
3answers
117 views

Numerical integration of a multivariate function whose expression is unknown

This question is related to the previous one, but I believe the extension to several variables is a problem in itself. I have a collection of points $(x_j,y_k,f(x_j,y_k))$ for $x_j=\frac{j}{n}$ and $...