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.

Filter by
Sorted by
Tagged with
7
votes
1answer
124 views

Numerical calculation of Integral of Si(x)/x

I'm interested in evaluating \begin{equation} \int_0^x \frac{Si(t)}{t}\;dt \end{equation} Where \begin{equation} Si(x) = \int_0^x \frac{\sin t}{t}\;dt \end{equation} I've found a nice method for ...
5
votes
2answers
155 views

Numerical evaluation of a Gaussian Integral in Python?

Goal I'm trying to write code to compute the normalized Gaussian in the following, $$ \begin{equation} \int_{-\infty}^{\infty} \frac{1}{ \sigma \sqrt{2 \pi}} \exp\bigg( - \frac{(x - \mu)^{2}}{2 \...
11
votes
3answers
257 views

Numerical evaluation of highly oscillatory integral

In this advanced course on applications of complex function theory at one point in an exercise the highly oscillatory integral $$I(\lambda)=\int_{-\infty}^{\infty} \cos (\lambda \cos x) \frac{\sin x}...
-2
votes
1answer
79 views

How to : numerical integration by quadrature in C language / remove NaN

What I wanna solve it the problem following ( by quadrature method ) I want to get two arrays of data ( z & tau ) from z[0], tau[0] to z[2249], tau[2249]. Since the integrand diverges at z=0.9, ...
1
vote
0answers
44 views

How to integrate the contents of a vector using an adaptive quadrature routine [duplicate]

I have a function which requires the return type to be a container. The problem is that I need to integrate the contents of the container as efficiently as possible and was hoping to use adaptive ...
1
vote
0answers
32 views

Does adaptive Gauss-Kronrod reuse function evaluations?

I'm curious to know how QUADPACK's QAG routine works. My understanding is that it begins by calculating on each subinterval the numerical quadrature with a Gaussian-Legendre rule and a nested Kronrod ...
1
vote
1answer
22 views

Domain transformation squashing interior quadrature nodes into boundary

In many quadrature problems, we are interested in computing $\int_a^b f(x) \, \mathrm{d}x$ via a quadrature sum. However, most software packages precompute the quadrature nodes and weights for use ...
6
votes
0answers
68 views

Quadrature methods for peaky integrands

Consider $$ I = \int_{-L}^L f(x)dx, $$ where $f(x)$ is real-valued and analytic on $[-L,L]$, but it has a pole in the complex plane whose real part lies in $[-L,L]$. Call it $z_0$, and assume it is a ...
0
votes
1answer
75 views

How to cope with the following singularity

I have the following integral: $\int_{1}^{Xd} \dfrac{(X^{z_i}-1)}{[X^2 \sum_{l=1}^{N}c_l(X^{z_l}-1)]^{1/2}}dX = \int_{1}^{Xd} h(X) dX$ where: Xd is a real that can be either negative, positive or ...
6
votes
1answer
110 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
169 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
22 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
128 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
135 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) ...
12
votes
2answers
330 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
142 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
35 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 ...
5
votes
1answer
153 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 ...
5
votes
2answers
149 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 ...
-3
votes
1answer
59 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
75 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
518 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
790 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$$...
1
vote
1answer
433 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
158 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
127 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
351 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
98 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
52 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)$ ...
2
votes
2answers
174 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
73 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\...
6
votes
1answer
260 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 ...
8
votes
2answers
215 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
491 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)^{...
5
votes
1answer
218 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
205 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}$ ...
5
votes
1answer
176 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
250 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
90 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
131 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
147 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
1k 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
132 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
132 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
45 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
1answer
163 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
239 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 $...
8
votes
1answer
218 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
113 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
12k 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 ...