Questions tagged [quad]

Quad is a scipy package which is used for 1D integration in Python

135 questions
3
votes
4 answers

how to call python scipy quad with array inputs

I am using nested scipy.integrate.quad calls to integrate a 2 dimensional integrand. The integrand is made of numpy functions - so it is much more efficient to pass it an array of inputs - than to loop through the inputs and call it once for each…
JPH
  • 1,224
  • 2
  • 14
  • 21
2
votes
1 answer

scipy.integrate.nquad ignoring opts?

I need to compute a numerical (triple) integral, but do not need very high precision on the value, and would therefore like to sacrifice some precision for speed when using nquad. I thought that I might be able to do this by increasing the epsrel…
ampw
  • 175
  • 10
2
votes
2 answers

Shape Creation using polygons doesnt work properly Java3d

To sum up the problem, I have code to create a cube using quads but instead of doing so some of the faces are missing for no clear reason and hope that somebody might be able to help me :) Also for some reason it produces no console errors This is…
Hoax
  • 76
  • 8
2
votes
1 answer

Quad function returning different values in python

I faced an issue when trying to use quad to integrate a function. Essentially, I have two versions of code where I define t(a) in different places. Both codes looks the same to me but the result I am getting is slightly different. I am guessing that…
Azuyugi
  • 23
  • 3
2
votes
0 answers

math domain error in a python code involving fsolve and quad integrations

Im getting math domain error in this code. But the same function F does work in another program (I didn't use fsolve) without any domain error. import numpy as np from scipy.integrate import quad from scipy.optimize import fsolve from math import…
mathfun
  • 101
  • 7
2
votes
1 answer

Is there a way to connect SymPy symbolic differentiation with SciPy's Quad Integration package?

I just recently learned how to integrate a two-variable function using SciPy's quad integration, with respect to just one variable. For instance, say we have a function f(x,y). I integrated with respect to x, in order to get f(y). I then plotted…
ryguy
  • 51
  • 6
2
votes
1 answer

Integral with variable limits in python

I'm trying to compute the following integral using scipy, with the following program: def E(z): result = 1/np.sqrt(Om*(1 + z)**3 + Ode + Ox*(1 + z)**2) return result def r(z, E): result, error = quad(E, 0, z) # integrate E(z) from 0…
scott
  • 35
  • 5
2
votes
2 answers

Using scipy.quad with iε trick: Bad results

In order to circumvent the cauchy principle value, I tried to integrate an integral using a small shift iε into the complex plane to evade the pole. However, as can be inferred from the figure below, the result is pretty bad. The code for this…
varantir
  • 6,624
  • 6
  • 36
  • 57
2
votes
1 answer

Quad definite integral with infinite limit

I am trying to solve the following: where, g is a constant, and \mu = 0, but I am getting a warning and the result is not quite what is supposed to be. Here is the code: %matplotlib inline from scipy.integrate import quad from numpy import…
Ah77
  • 85
  • 1
  • 9
2
votes
1 answer

scipy.integrate.quad fails (sometimes) when function to be integrated is also an integral

I am using sqipy.integrate.quad to calculate a double integral. Basically I'm trying to calculate the integral over exp[-mu_wx_par] where mu_wx_par is also a integral. My code mostly works. However, for some values it fails, i.e. it returns…
mortysporty
  • 2,749
  • 6
  • 28
  • 51
2
votes
2 answers

Using scipy.integrate.quad to perform 3D integral

Motivation for the question I'm trying to integrate a function f(x,y,z) over all space. I have tried using scipy.integrate.tplquad & scipy.integrate.nquad for the integration, but both methods return the integral as 0 (when the integral should be…
Ben Pepper
  • 37
  • 6
2
votes
1 answer

Increase number of nodes in quad

This might be a simple question, but I am trying to increase number of nodes in quad integration. I could not find relevant documentation about this. I have a one-dimensional function (Dirac delta-like) which is mostly zero, but non-zero at a very…
gurluk
  • 195
  • 2
  • 7
2
votes
0 answers

scipy.quad trouble for decreasing functions over large ranges

I have a problem with scipy.quad. In short, I have a really long and complicated set of nested functions and integrals which include an integral of a decreasing function which must be integrated over the specific range 10^2 < x < 10^20. To…
SeaWalk
  • 63
  • 4
2
votes
2 answers

Python/Scipy - Integrate with Quad Along Axis

I have a 2D array. The "xy" plane is a grid from (-1,-1) to (1,1). I want to compute and integral at each point where the function depends on the coordinates of the point. I know that with discrete data I can use simps or trapz and specify an axis…
Scott B
  • 2,542
  • 7
  • 30
  • 44
2
votes
1 answer

scipy quad uses only 1 subdivision and gives wrong result

I want to use quad to get the mean of a Gaussian distribution. My first try and 2nd try gets different result. And the 2nd try of quad uses only 1 subdivision. mu =1 sigma =2 import scipy as sp import scipy.integrate as si import scipy.stats as…
1
2
3
8 9