quad

How to limit number of function calls in scipy.integrate.quad?

How to limit number of function calls in scipy.integrate.quad? Question: Scipy.integrate.quad() seems to make too many function calls in come cases. Here is a simple test to demonstrate: import numpy as np from scipy import integrate def intgnd(x): p = x + x**2 return p x0=-1 x1=1 epsrel=0.1 epsabs=0.1 I,err,info = integrate.quad(intgnd,x0,x1,full_output=1,epsabs=epsabs,epsrel=epsrel) print("{:.3f}, {:.3g}, {}, …

Total answers: 1

Why does my defined function not accept an array as an input?

Why does my defined function not accept an array as an input? Question: I am working with a double integral, and the inner integral has variable bounds. I wrote a function, using SciPy’s quad integration, that allows me to evaluate this integral. However, what I want is to just evaluate the inner integral, so that …

Total answers: 1

How do I use parameter epsabs in scipy.integrate.quad in Python?

How do I use parameter epsabs in scipy.integrate.quad in Python? Question: I am trying to compute the integrals more precise by specifying the parameter epsabs for scipy.integrate.quad, say we are integrating the function sin(x) / x^2 from 1e-16 to 1.0 from scipy.integrate import quad import numpy integrand = lambda x: numpy.sin(x) / x ** 2 …

Total answers: 1

Using scipy.integrate.quad to perform 3D integral

Using scipy.integrate.quad to perform 3D integral Question: 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 finite). This is because, as the volume of integration increases, the …

Total answers: 2

scipy.integrate.tplquad gives wrong result for integral over large volume

scipy.integrate.tplquad gives wrong result for integral over large volume Question: I’m trying to integrate a function of 3 variables f(x,y,z) over all space. When I integrate over a small volume, I get roughly the right result. However, when I increase the volume of integration, python says that the integral is zero. I’m fairly confident that …

Total answers: 1

scipy integrate.quad return an incorrect value

scipy integrate.quad return an incorrect value Question: i use scipy integrate.quad to calc cdf of normal distribution: def nor(delta, mu, x): return 1 / (math.sqrt(2 * math.pi) * delta) * np.exp(-np.square(x – mu) / (2 * np.square(delta))) delta = 0.1 mu = 0 t = np.arange(4.0, 10.0, 1) nor_int = lambda t: integrate.quad(lambda x: nor(delta, …

Total answers: 1

multiply Python Quad integration by float

multiply Python Quad integration by float Question: Hello I’m quite new to python and I’m trying to work through a set of equations. I’m trying to multiple the result of the quad integration by a float my code is: from __future__ import division import scipy.special as sp from scipy import integrate import math Tb = …

Total answers: 3

Definite integral over one variable in a function with two variables in Scipy

Definite integral over one variable in a function with two variables in Scipy Question: I am trying to calculate the definite integral of a function with multiple variables over just one variable in scipy. This is kind of like what my code looks like- from scipy.integrate import quad import numpy as np def integrand(x,y): return …

Total answers: 5

error in math formulas in python code scipy

error in math formulas in python code scipy Question: i have small piece of code which produce errormessages (I think because of the math formula). Anyone an idea why? import matplotlib.pyplot as plt import numpy as np from scipy.optimize import curve_fit from scipy.integrate import quad n = 3 x = np.array([2.1,2.2,2.3,2.4]) y = np.array([0.9,2.1,3.2,17.9]) def …

Total answers: 2