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 [integration]

The tag has no usage guidance.

2
votes
0answers
51 views

Best way to numerically compute elliptic integrals of the third kind with complex arguments?

I need to compute elliptic integrals of the third kind with complex arguments, preferably in C++. Is there code out there to do this? I have discovered the Arb library, but that does much more than I ...
-2
votes
0answers
33 views

python Simpson integration [on hold]

Currently, I am trying to apply a Crank-Nicolson method on a function that I want to evolve. However, I am only facing one drawback and it is the step when I normalize the initial function using the ...
0
votes
3answers
72 views

Rudin lecture — if f(x) is not integrable on some interval, does it not have a Fourier Series expansion on that interval?

I found an old lecture on YouTube given by Walter Rudin (1990, in Wisconsin), and towards the beginning he mentions that if $f(x)$ were not integrable, on some interval, it would be obvious that it ...
5
votes
0answers
67 views

Is there a numerically stable way to take $\epsilon \rightarrow 0$ in integrals of the form $\int \frac{f(x)dx}{x+i\epsilon}$?

The Sokhotski-Plemelj theorem states, $$\lim_{\epsilon\rightarrow 0^+}\int_a^b\frac{f(x)dx}{x+i\epsilon} = \mathcal P \int_a^b \frac{f(x)dx}{x} - i\pi f(0). $$ Is there a numerically stable way to ...
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(\...
0
votes
1answer
26 views

FEM 1D poisson substitution integral issue

I'm trying to solve $ \begin{cases} -u''=f \\ u(0)=0 \\ u(1)= \alpha \end{cases} $ with FEM using reference elements and local coordinates. So we have the global ...
1
vote
2answers
147 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
117 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 ...
3
votes
2answers
164 views

Integration of the Fermi distribution using Python

I want to calculate the carrier concentration of my semiconductor using this equation: $$ n(x) = \frac{m^*}{\pi\hbar^2}\int_{E_k}^{\infty}\frac{1}{1+\exp\left(\frac{E-E_f}{k_BT}\right)} \mathrm{d}E $$...
8
votes
1answer
152 views

What are these oscillations?

I have a function $g(x)$ defined numerically that is sort of in between a Gaussian and a Lorentzian. It decays much slower than a Gaussian, but still faster than a simple inverse power. I need to ...
11
votes
1answer
140 views

Numerically Recovering Imaginary Part of Analytic Continuation from Real Part

My situation. I have a function of a complex variable $f(z)$ defined through a complicated integral. What I am interested in is the value of this function on the imaginary axis. I have numerical ...
0
votes
0answers
92 views

Using Gram-Schmidt to obtain Spherical Harmonics

If we don't know the Spherical Harmonics offhand, we could try to observe they are stratified by degree. So that $x^a y^b z^c$ will have degree $n = a+b+c$. These do not form an orthonormal basis, ...
2
votes
1answer
37 views

Two variables integration matlab

I'm trying to solve physical problem in quantum mechanics of helium atoms, the solution require numerical integration over 2 variables. However when i'm trying to run the next code ...
3
votes
0answers
42 views

Book Suggestion for Approximating Integrals using Random Partitions

Suppose I want to approximate the integral $\int_0^1 x^2\,dx$ using Riemann Sums or Darboux sums over random partitions of the interval $[0,1]$, Like in the image below: Here, A "random" partition of ...
2
votes
2answers
138 views

Integration of a diverge function in c++ GSL Library

I am trying to perform an Integral of Hypergeometric function 2F1(a,b,c,x) from -1 to 1 for some good values of $a,b,c$ (lets say $a=1,b=2,c=3$) . I did it in ...
7
votes
3answers
126 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) ...
4
votes
1answer
73 views

Error on a integral quantity with noise

First of all sorry if this is the wrong place to ask this question, I went to a few stack sites and thought here it would be more suitable. My problem: I have a physical quantity $F$ that depends on ...
1
vote
1answer
100 views

Scipy odeint Unexpected Results

I am attempting to numerically integrate the equation $$\frac{\mathrm{dP} }{\mathrm{d} r}=-\left ( P+\rho\left ( r \right ) \right )\frac{m\left ( r \right )+4\pi r^{3}P}{r\left [ r-2m\left ( r \...
1
vote
1answer
73 views

Weighted Monte Carlo Integration

I have a function $F(x)$ which drops exponentially (like differential QCD cross section vs. Invariant mass). I want to perform Monte-Carlo integration. The problem is that only small $x$'s which have ...
2
votes
0answers
86 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 ...
23
votes
2answers
1k views

What does “symplectic” mean in reference to numerical integrators, and does SciPy's odeint use them?

In this comment I wrote: ...default SciPy integrator, which I'm assuming only uses symplectic methods. in which I am refering to SciPy's odeint, which uses ...
1
vote
1answer
67 views

Numerical integration of a quadratic form exponential in two variables over a rectangle

Let $$f(x,y) = \exp \left(- \frac{1}{2}a x^2 - \frac{1}{2}c y^2 + bxy \right)$$ where $a,b,c\ge 0$. I want to integrate numerically: $$\int_{x_0}^{x_1}\mathrm{d}x \int_{y_0}^{y_1}\mathrm{d}y \, f(...
2
votes
0answers
115 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
1answer
123 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: $$...
4
votes
1answer
280 views

How to solve this set of equations involving an integral?

I have the following set of equations: $$ x(t) = x_0 \psi, \qquad y(t) = \kappa \ln \psi - x_0 \psi +1,\qquad z(t) =-\kappa\ln \psi,$$ with $$ t- t_0 = \int ^\psi_{\psi_0} \frac{d\eta}{\eta(1+\...
4
votes
1answer
342 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
0answers
46 views

Computing dilogarithm

I'm measuring the integral of a quantity which, mathematically, requires the computation of a dilogarithm function. $$\operatorname{Li}_2(be^{ax})$$ where $b$ and $a$ (are real and) can be positive ...
0
votes
1answer
360 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
1answer
629 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
0answers
108 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
106 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
0answers
305 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
1answer
158 views

Solid volume calculation

In order to calculate the volume of the solid defined by $$\frac{51}{100} (\cos x \cos y+\cos x \cos z+\cos y \cos z)+\cos x+\cos y+\cos z+1\le0$$ where $x,y,z\in[0,2\pi]$ I used the following code ...
6
votes
2answers
830 views

Evaluating the surface integral in an FEM (Finite Elements Method) procedure

I want to evaluate the Surface force integral in an FEM procedure. The basic reference tet is shown in the figure. The faces are numbered corresponding to the node opposite to them. For example the ...
2
votes
2answers
1k views

Plotting Voigt Function in Python

I've been trying to plot the following function in Python: $H(a,u) = \frac{a}{\pi} \int_{-\infty}^{\infty}\frac{exp(-y^2)}{a^2 + (u - y)^2}dy $ But I keep receiving the following error: ...
1
vote
0answers
70 views

Monte Carlo integration with reusable importance sampling

A problem at hand is solving the same multidimensional integral many times (my current estimation is $10^7$ times) while adjusting integrand through pair of parameters. As I expect the calculation to ...
3
votes
2answers
158 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\...
2
votes
1answer
99 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 ...
9
votes
2answers
201 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 $...
2
votes
1answer
1k views

scipy optimize fsolve or root

I have a function: delt=1 #trial def f(z): return ((1-2*z)*np.exp(-delt/z))/(((1-z)**(2+delt))*(z**(2-delt))) I also have a variable: ...
1
vote
1answer
71 views

Integrating nonlinear force term in FEM

I had a similar question to Finite element method applied to 1D structural problem - what is wrong with body force? I did some work on it as per answers, but it seems that is not working. Quadratic ...
2
votes
1answer
58 views

Is this a proper implementation of point charge dynamics with ODEs

Since learning about point charges in my physics II class this semester, I want to be able to investigate not only the static force and field distributions but the actual trajectories of movement of ...
0
votes
1answer
246 views

Integration by parts for FEM

I am trying to teach myself the basics of FEM but am having trouble with the the manipulations involved. For instance, Example 5.5 of Hutton's "Fundamentals of Finite Element Analysis" provides a ...
0
votes
2answers
163 views

Finite element method applied to 1D structural problem - what is wrong with body force?

I have quadratic finite element - shape function is quadratic. Element spans from 0 to 5. Body force is given by (in physical coordinates) $$f_b = \int_0^5 N(x)^T b(x) dx \approx \sum_{i=1}^3 N(\...
0
votes
1answer
431 views

What is wrong with this Euler method code in python?

I am testing the ability of my integration method to reproduce results obtained analytically (for various values of the parameters), but the results turn out to be completely wrong and I can't find ...
6
votes
1answer
192 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
79 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
1answer
156 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 ...