Questions tagged [quad]

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

135 questions
2
votes
5 answers

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

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…
Hannah
  • 165
  • 2
  • 3
  • 13
2
votes
2 answers

Integrating a function over a variable other than the first, looking for an alternative to lambda

Is there any other way than using a lambda function to integrate a function in python 2.7 over, say, the 2nd of two variables? For instance, I would like to integrate this example function over x: import numpy as np from scipy.integrate import…
Forzaa
  • 1,465
  • 4
  • 15
  • 27
1
vote
1 answer

How to compute the inner integral with quad?

I am reading the paper by Floris​ and try to compute the numerical value of the normalization constant C_I from eq. (20). From the eqution and property of transition probability density function (PDF) , the normalization constant is: In my case,…
Nick
  • 1,086
  • 7
  • 21
1
vote
2 answers

Numerically evaluate triple integral with non-constant limits

Numerically evaluate triple integral with non-constant limits. I want to numerically perform a triple integral of a two-variable functionf(x,y) where both x and y have integration limits [a+t0-t,b+t0-t] and the third integral goes over t with…
TheHunter
  • 111
  • 2
1
vote
1 answer

Python Scipy integrate.quad()

I'm trying to solve an integral inside a for loop where the value of the integral changes with every loop. Ni_1D = np.array([(x/2)*(x-1), x-x**2, (x/2)*(x+1)]) Tn= [10.0, 10.0, 10.0] Tt=[0, 0, 0] y_coor = [0.0, 1.25, 2.5] x_coor = [4.0, 4.0,…
Lane
  • 11
  • 2
1
vote
0 answers

PixiJS: Affine projection vs bilinear one

Let's say there is an arbitrary composite shape in PixiJS: I need to project a texture onto it by some kind of a grid warp in a way, so the result would be: I have tried to do it via PIXI.SimplePlane and it seems that default projection algorithm…
toowren
  • 85
  • 7
1
vote
0 answers

Unity 3D Mesh Generation with Quads to Triangles

My goal is to create a simple flat mesh with a grid of vertices. These vertices are then manipulated to create a simple terrain with some areas being raised and flat like a plateau, and these plateaus are connected to the areas below by slopes. The…
1
vote
0 answers

How to define a function in python containing a definite integral whose free parameter is running between two fixed values?

I would like to define a python function that has three parameters: C, psi, and m but it actually internally has an integral that is running based on another variable called eta. def func(x: np.float64, C: np.float64, psi: np.float64, m: np.float64)…
Roosha
  • 89
  • 3
  • 10
1
vote
1 answer

Problem using lambda expression to be integrated using quad from mpmath

I am trying to integrate an oscillatory expression with mpmath.quad. The integral only has one variable but I need to evaluate it in a 2D space. I need the resulting function from the integral along kx to be evaluated for a group of coordinated in x…
1
vote
0 answers

Error map-functions.lua:42: bad argument #2 to 'draw' (Quad expected, got nil) , any idea what's wrong?

I'm very new to love and lua and I don't know why I keep getting this message, any ideas? here's my code, hope you guys know what I could do. in maps-functions.lua function loadMap(path) love.filesystem.load(path)() end function newMap(tileW,…
zara b
  • 11
  • 1
1
vote
1 answer

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

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…
1
vote
1 answer

Python: Integration over Multiple Dimensions of function taking an array input

I am having difficulty computing multiple integrals of functions with taking array inputs. I would like to use scipy.integrate's nquad function because I need to be able to integrate from -np.inf to np.inf (I'm working with probability density…
1
vote
0 answers

ValueError: Residuals are not finite in the initial point. (Python)

I need to fit a graph using a complicated function including numerical integration. If I do this using a simpler function (which is also an integral), this method works, but for the function I'm trying, it's not working. Although the program is…
1
vote
1 answer

TypeError: only size-1 arrays can be converted to Python scalars when using trapz method

This is my python code import numpy as np from scipy.integrate import quad, trapz, simps import math def f(x): return math.exp(-(x**2/2))/math.sqrt(2*math.pi) result, error = quad(f, 0, np.inf) print("{:f} {:g}".format(result, error)) x =…
Aswin K R
  • 29
  • 1
  • 8
1
vote
1 answer

Problems integrating using quadpy

I am trying to use quadpy as I want to do 2D numerical vector integration for 2D integrals. To see how fast quadpy works, I wanted to test it and compare it with scipy 1D vector integration. Thus I wrote a simple code: import numpy as np from scipy…
Shankar_Dutt
  • 115
  • 9
1 2
3
8 9