Questions tagged [numerical-integration]

Algorithms that integrate functions over one or more dimensions using approximation techniques, instead of exact, closed-form solutions using symbolic algebra and calculus. Includes concepts like adaptive quadrature, Monte-Carlo methods, finite element analysis, Markov chains.

Methods of numerical integration include:

769 questions
71
votes
7 answers

Calculate the Area under a Curve

I would like to calculate the area under a curve to do integration without defining a function such as in integrate(). My data looks as this: Date Strike Volatility 2003-01-01 20 0.2 2003-01-01 30 0.3 2003-01-01 …
Dani
  • 2,325
  • 5
  • 24
  • 20
18
votes
1 answer

Defining the Goal using Microsoft Solution Foundation

Program Purpose: Integration. I am implementing an adaptive quadrature (aka numerical integration) algorithm for high dimensions (up to 100). The idea is to randomly break the volume up into smaller sections by evaluating points using a sampling…
Paul Chernoch
  • 5,275
  • 3
  • 52
  • 73
17
votes
1 answer

Integrating error: maximum number of subdivisions reached

I am trying to plot a Fourier integral, but I get error while integrating X <- seq(-10, 10, by = 0.05) f_fourier <- function(X) { Y <- sapply(X, function(x) { integrand <- function(l) { y <- (2 / pi) * cos(l * x) / (l^2 + 1) …
Eugene Kolesnikov
  • 643
  • 2
  • 6
  • 15
16
votes
2 answers

double integral in R

I'm wondering how to code that takes double integrals in R. I already referred two similar questions. calculating double integrals in R quickly double integration in R with additional argument But I'm still confused how I can get my question from…
moggirio
  • 161
  • 1
  • 1
  • 4
16
votes
6 answers

using SciPy to integrate a function that returns a matrix or array

I have a symbolic array that can be expressed as: from sympy import lambdify, Matrix g_sympy = Matrix([[ x, 2*x, 3*x, 4*x, 5*x, 6*x, 7*x, 8*x, 9*x, 10*x], [x**2, x**3, x**4, x**5, x**6, x**7, x**8, x**9, x**10,…
Saullo G. P. Castro
  • 56,802
  • 26
  • 179
  • 234
14
votes
3 answers

Gauss-Legendre over intervals -x -> infinity: adaptive algorithm to transform weights and nodes efficiently

Okay I know this has been asked before with a limited example for scaling [-1, 1] intervals [a, b] Different intervals for Gauss-Legendre quadrature in numpy BUT no one has posted how to generalize this for [-a, Infinity] (as is done below, but not…
Matt
  • 2,602
  • 13
  • 36
12
votes
3 answers

Help with symplectic integrators

I'm trying to develop a physics simulation and I want to implement a fourth-order symplectic integration method. The problem is that I must be getting the math wrong, since my simulation is not working at all when using the symplectic integrator (as…
11
votes
3 answers

Looking for Python package for numerical integration over a tessellated domain

I was wondering if anyone knew of a numpy/scipy based python package to numerically integrate a complicated numerical function over a tessellated domain (in my specific case, a 2D domain bounded by a voronoi cell)? In the past I used a couple of…
JoshAdel
  • 66,734
  • 27
  • 141
  • 140
10
votes
1 answer

Integrating over a constant function

I am trying to integrate over a constant function in MATLAB 2017a, but I am stuck. First of all when I integrate using the following script, I get the right output. So the script works for a x0 which depends on t. function E=sol(n,k) x0 = @(t) …
Airapet
  • 103
  • 6
9
votes
2 answers

Vectorize integration of pandas.DataFrame

I have a DataFrame of force-displacement data. The displacement array has been set to the DataFrame index, and the columns are my various force curves for different tests. How do I calculate the work done (which is "the area under the curve")? I…
blokeley
  • 6,726
  • 9
  • 53
  • 75
9
votes
2 answers

Absolute error of ODE45 and Runge-Kutta methods compared with analytical solution

I would appreciate if someone can help with the following issue. I have the following ODE: dr/dt = 4*exp(0.8*t) - 0.5*r ,r(0)=2, t[0,1] (1) I have solved (1) in two different ways. By means of the Runge-Kutta method (4th order) and by means…
8
votes
4 answers

How to overcome singularities in numerical integration (in Matlab or Mathematica)

I want to numerically integrate the following: where and a, b and β are constants which for simplicity, can all be set to 1. Neither Matlab using dblquad, nor Mathematica using NIntegrate can deal with the singularity created by the denominator.…
Calvin
  • 225
  • 3
  • 7
8
votes
1 answer

Laplace transform using numerical integration in Python has very poor precision

I have written a function to compute the Laplace transform of a function using scipy.integrate.quad. It is not a very sophisticated function and currently performs poorly on the probability density function of an Erlang distribution. I have included…
8
votes
2 answers

Different intervals for Gauss-Legendre quadrature in numpy

How can we use the NumPy package numpy.polynomial.legendre.leggauss over intervals other than [-1, 1]? The following example compares scipy.integrate.quad to the Gauss-Legendre method over the interval [-1, 1]. import numpy as np from scipy import…
Paul
  • 358
  • 3
  • 14
8
votes
3 answers

The time-corrected Verlet numerical integration formula

There is a commonly used verlet-integration formula on the web by Johnathan Dummer, called Time-Corrected Verlet. However I've read several forum posts, that people get weird or unexpected results with it in certain conditions. Formula by Johnathan…
1
2 3
51 52