All Questions
Tagged with integration numerics
60 questions
3
votes
0
answers
146
views
Quantifying the inefficiency of Gauss–Hermite quadrature
I am trying to understand the following part of the paper https://doi.org/10.1137/20M1389522 where the author argues about the inefficiency of Gauss-Hermite quadrature.
I think I get the gist of the ...
6
votes
2
answers
1k
views
Implementation of Monte-Carlo Integration
After reading the Wikipedia page for Monte-Carlo integration, I have understood the basic idea but I am having trouble implementing it for a general case.
The integration that I am trying to do is
$$
\...
0
votes
1
answer
152
views
How to use a custom OdeSolver in Scipy's solve_ivp
In Scipy's solve_ivp documentation, we see the method argument can be either a string or a user-defined ...
0
votes
1
answer
116
views
Integration of a singular kernel function over a triangle
Problem:
I am currently trying to integrate a singular kernel function of the type
$$G(x,y)=\frac{\exp(ik||x-y||_2)}{4\pi ||x-y||_2}$$
which lies at the centre of a triangle, over this triangle. $i$ ...
0
votes
0
answers
216
views
discrete definition of curl $ \nabla \times \vec{A}$ on a 3D grid?
I have the data for 3D vector field $\vec{A}$ (with components $\vec{A_1}$, $\vec{A_2}$ and $\vec{A_3}$) sampled on a 3D grid with integer indices i, j and k.
Assuming that only the third component $\...
0
votes
0
answers
49
views
Numerical Method for Multivariate Inversion Formula
For my research, I need to evaluate the density of a random vector $\boldsymbol{X} \in \mathbb{R}^p$ using the multivariate inversion formula. Let the density function of $\boldsymbol{X}$ be $f (\...
4
votes
3
answers
1k
views
How can I numerically integrate the Kepler problem?
I tried to solve a simple Kepler problem numerically.
I have discrete time steps, a starting position $(x_0,y_0)$ and starting velocity $(u_0, v_0)$.
I used this iteration by calculating the forces ...
3
votes
2
answers
2k
views
Inaccurate results of integration using scipy solve_ivp
I am trying to use solve_ivp to solve the following 1st order ODE:
$$ \frac{d \rho}{d z} = \frac{m \theta}{(1+\theta z)} \, \rho, $$
subject to $\rho(z=0)=1$, where ...
0
votes
0
answers
30
views
What are the known or used numerical methods for integration over the sphere $S^2$ ? and what about over $S^3$?
What are the numerical methods available to compute integrals over $S^2$, for the particular integration :
$$\int_{S^2} f(\omega)\,d\sigma(\omega)\ , \quad \text{ where $d\sigma$ is the usual measure ...
3
votes
1
answer
473
views
Importance Sampling for multidimensional integrals and random numbers from multivariable pdf's
I am aiming to get a numerical value for a five-dimensional integral using Monte Carlo Integration. I am getting good results using the Mean Value Method, but I would like to try to use Importance ...
6
votes
0
answers
105
views
What is the best method to do a MC Integration of a multidimensional integral where the integration limits depend upon other variables?
What is the best method to do a Monte Carlo Integration of a multidimensional integral where the integration limits depend upon other variables?
I am interested in getting a numerical value of a 5 ...
4
votes
0
answers
103
views
Sample Average Approximation vs. Numerical Integration
To calculate the expected value of objective functions, we have two choices:
Sample Average Approximation (SAA):
$$
\frac{1}{N}\sum_{i=1}^N f(x,\xi^i).
$$
Numerical Integration (e.g., Monte Carlo ...
2
votes
1
answer
6k
views
Error in Simpson's 3/8 rule is higher than that of Simpson's 1/3 rule
For a given function $f(x)$, I have tried to find its numerical integral using Simpson's 1/3 and Simpson's 3/8 rules.
I then compare the solution from the numerical quadratures to the analytical ...
5
votes
0
answers
557
views
Fast integration scheme for path integral of Gaussian over a cubic curve
I need to numerically compute an integral of the following form:
$$\int_0^1 \frac{1}{2\pi\sigma^2}\exp\left(-\frac{\|(q_0t^3 + q_1t^2 + q_2t + q_3) - a\|^2}{2\sigma^2}\right)\|3q_0t^2 + 2q_1t + q_2\|\,...
1
vote
1
answer
121
views
Numerical integrator for $a'(t)=e^{-a(t)}f(t)$
Suppose I know a function $f(t)$ and all its derivatives in $t$ in closed form. Given $a(0)$ and some $t_0>0$, I'm looking for an explicit integrator that can estimate $a(t_0)$, where $a(\cdot)$ ...
2
votes
0
answers
736
views
Errors in Integral Estimate of Gaussian using Trapezoidal Rule
I'm trying to estimate the percentage error in computing the integral of a Gaussian via composite trapezoidal rule versus via an exact formula. To do this I've generated a gaussian with mean 0, ...
2
votes
1
answer
2k
views
Trouble with backwards time integration in Python
I am struggling with a rather basic numerical integration task: Using Python's scipy.integrate.solve_ivp module to integrate an ODE sytem backwards in time. As a test, I am using the following ODE ...
2
votes
1
answer
3k
views
Numerical integration problem: IntegrationWarning The integral is probably divergent, or slowly convergent
I am trying to get the numerical integration of a function using scipy's integrate.quad as follows.
$$
\begin{equation}
G (\alpha) = \frac{4\alpha}{\pi}\int_0^{\...
3
votes
1
answer
322
views
Find quadrature points and weights
I'm struggling with the following problem:
What is the maximum degree of exactness that we can obtain with the following quadrature >formula
$$\int_0^1 f(x)\frac{1}{\sqrt{x}}dx \approx w_0 f(x_0) +...
4
votes
1
answer
757
views
How to use numerical integration to calculate the surface area of a superellipsoid?
I am working in an application in which I need to calculate the surface area of a superellipsoid. I have read that there is no closed form solution (see here), so I am trying to compute it using ...
1
vote
0
answers
171
views
Is Romberg integration method implemented as weighted function values numerically correct?
I have to integrate expression f(x) * g(x) for many different functions f but just one g.
I ...
1
vote
0
answers
89
views
Plot of ratio of two integrals:
Consider the following integrals
$$
I_1(x) =\int_0^\infty\mathrm dy \frac{F(x + \mathrm iy) − F(x −\mathrm iy)}{\mathrm e^{2πy}-1},
$$
And
$$I_2(x) =\int_1^x F(t)dt$$
Where, $ F(z) = \sin^2[π\Gamma(z)/...
4
votes
0
answers
339
views
How to numerically evaluate this double Integral?
I want to evaluate the following integral:
$$\int_{0}^{60} \ \left(\int_{0}^{2z} 0.5\cdot t \left(\mathrm{erf}(t-a) -1 \right)J_{0}(qt)\mathrm{d}t \right)^2 \mathrm{exp}\left(-\frac{(z-a)^2}{2s^2}\...
1
vote
3
answers
294
views
Comparison of integrals with a function:
Consider the following integral:
$$S(q)=\int_{x=2}^q\sin^2\left(\frac{π\Gamma(x)}{2x}\right)dx$$
And consider the functions :
$$R(q)=\frac{q}{\log(q)}$$
$$T(q)=\int_2^q\frac{1}{\log(x)}dx$$
I ...
0
votes
3
answers
215
views
Changing variables in integral to avoid infinity
I want to write a code in Fortran to solve this integral numerically: $$\int_{1095}^\infty \frac{dx}{x\sqrt{(x+644.153)(4.17 \cdot 10^{-5} x+0.145)}}$$ What is the best method for it?
I tried Monte-...
2
votes
0
answers
46
views
Evaluating integral $F(r_2) = \frac{1}{r_2^n} \int_0^{r_2} r_1^n f(r_1)\ \mathrm{d}r_1$ without growing instability
I have the following expression to be numerically integrated in a vector-based library (e.g. numpy, MATLAB, etc),
$$
F(r_2) = \frac{1}{r_2^n} \int_0^{r_2} r_1^n f(r_1)\ \mathrm{d}r_1,
$$
where $n$ is ...
2
votes
0
answers
372
views
2-dimensional Gauss-Hermite quadrature in R
A similar question was asked here and the given answer is perfect for a unidimensional integration.
I need to make bidimensional integration in R with a Gauss-Hermite quadrature:
$$\int_{R^2} h(p1,p2)...
3
votes
0
answers
110
views
Numerical integration with singularity term
In https://www.johndcook.com/blog/2012/02/21/care-and-treatment-of-singularities, the author explains the subtraction method to get rid of singularities when performing numerical integration.
The ...
2
votes
1
answer
69
views
Numerical integration of the dataset of a function
The energy equation for a spherically symmetric system is given by
$$\mathscr{E}=\frac{v^2(r)}{2}+\frac{c_s^2(r)}{\gamma-1}+\phi(r)$$
where $\mathscr{E}$ is the total energy, $v$ is the velocity of ...
1
vote
2
answers
69
views
Numerical integral with symbolic integral in exponent
Many times in fourier approximation we come across integrals such as
$$\int_0^1 e^{-\gamma\int_0^xu_0(\eta)d\eta}dx$$ where $\gamma$ is a constant and the data for $u_0$ is provided as a discretely ...
7
votes
1
answer
184
views
Numerically estimating expected value of f(x) when x is normally distributed
I need to estimate
$$
\mathbb{E}_x[f_i(x)] = \int_{\mathbb{R}^n} f_i(x) p(x) dx
$$
for many functions $f_i(x)$, where $p(x)$ is the density of a normal distribution. The evaluation of all the ...
0
votes
0
answers
44
views
Techniques to optimise the integral of a function of known analytical form
I need to compute repeatedly a function that depends on an integral. The integral is not solvable analytically, but it depends on the argument of the function parametrically, like this:
$$
f(x) = \...
-2
votes
1
answer
122
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, ...
3
votes
4
answers
3k
views
Numerical integration in Python with unknown constant
I’d like to solve the below equation for the unknown $T$:
$$\int_0^\infty \frac{x^2}{\exp\left(\frac{x}{T}\right)-1}\kappa_x \mathrm{d}x = C,$$
where $C$ is a known constant and $\kappa_x$ is some ...
0
votes
1
answer
114
views
calculating integral for an ODE system
I have an ODE system defining a mathematical model of a biological system, say
$$
\frac{da}{dt}=f_1(a,b,\ldots,z,p)\\
\frac{db}{dt}=f_2(a,b,\ldots,z,p)\\
\cdots\\
\frac{dz}{dt}=f_n(a,b,\ldots,z,p)
$$
...
6
votes
1
answer
513
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(\...
2
votes
0
answers
128
views
Why would someone use empirical sum instead of numerical integration methods?
In the context of a scientific computing application, using data coming from (powerful) embedded systems, acquiring raw data (but from calibrated acquisition electronics), I have been asked to ...
2
votes
0
answers
161
views
What could be causing multi-dimensional numerical integration inconsistency?
I'm trying to numerically integrate a multi-dimensional expression. The integrand is complicated; for example this is the integrand for $N=4$:
$$\begin{aligned}&x_1^6x_2^5x_3^3x_4^2(x_1-x_1x_2)(...
1
vote
1
answer
176
views
Integrating over $\mathbb{R}^{3}$ without a convex subset
I am working on a problem (solid state physics, I am stripping all the details for brevity but if more details can help I'll elaborate) where I need to numerically calculate an integral of the form:
$$...
0
votes
1
answer
1k
views
How can this multidimensional integral be efficiently implemented in python using Gauss-Hermite quadrature
I'm playing around with dynamic programming and need to calculate a multidimensional integral $E[V(W)]$ where we assume $W$ has a log normal distribution. I was looking at the following example in ...
-1
votes
1
answer
6k
views
Using scipy.odeint to solve coupled equations [closed]
I have a set of three coupled autonomous equations:
${y_{1}}\prime = y_{1}(\frac{\Omega_{m}}{y_{1}^3} + \frac{y_{3}^2}{6.0} + \frac{V(y_{2})}{2.H_{0}^2})$
$y_{2}\prime = y_{3}$
$y_{3}\prime = -3\frac{...
1
vote
0
answers
763
views
How accurate is cumtrapz in MatLab?
Say I have a set of discrete acceleration data and want to integrate it to get a set of velocity data. How accurate is the cumtrapz (Cumulative trapezoidal ...
1
vote
0
answers
102
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\...
2
votes
1
answer
247
views
Another way to evaluate the gravitational force from a uniform cube?
Appendix A of Liu, Baoyin, and Ma (2011) Equilibria, periodic orbits around equilibria, and heteroclinic connections in the gravity field of a rotating homogeneous cube shows an analytic expression ...
0
votes
1
answer
804
views
Numerical integration of given points, simple/easy way
I have the x and the f(x) for a set of x. I don't know the function, actually. This is ...
1
vote
1
answer
301
views
Line integral along the edge of an isoparametrically mapped quadrilateral
I need to integrate a function along the edge of a quadrilateral (boundary integral). For example, the function is $f(x,y)=x^3+y^3$, the quadrilateral coordinates are $(0,0),(2,-1),(3,2),(1,3)$ and ...
13
votes
2
answers
9k
views
Which Runge-Kutta method is more accurate: Dormand-Prince or Cash-Karp?
I simply want to know whether the Dormand-Prince Numerical Method
or the Cash-Karp Numerical Method
is more accurate.
2
votes
1
answer
2k
views
4th Order Runge Kutta: Integration of Differential Equations for Planetary Orbit
I'm supposed to integrate differential equations for $r$ and $\theta$ in order to simulate orbital motion. The differential equation I used for $r$ is second order and $\theta$ is first order. The end ...
0
votes
1
answer
96
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 ...
8
votes
1
answer
261
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 ...