Questions tagged [quad]

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

135 questions
0
votes
2 answers

optimizing python quad using ctypes

I need to use ctypes functions to reduce the running time of quad in python. Here is my original question original question, but now i know what path i need to follow. I need to follow the same steps as in here similar problem link. However in my…
user1571823
  • 394
  • 5
  • 20
0
votes
1 answer

Can't undertand this behavior of dblquad

This is a case in which I think a simple integral should be 1, but dblquad stubbornly says 0.81. The details: function createFun below returns a real function. It is piecewise linear, intended to be a density function for a random variable that…
zeycus
  • 860
  • 1
  • 8
  • 20
0
votes
1 answer

numerical integration python

I need to reduce the running time for quad() in python (I am integrating some thousands integrals). I found a similar question in here where they suggested to do several integrations and add the partial values. However that does not improve…
user1571823
  • 394
  • 5
  • 20
0
votes
0 answers

Python error: function does not return a valid float

def voigt_PD(x,y0,xc,A,wG,wL): def integconvo(t,x1,xc1,wG1,wL1): return exp(-t**2)/((sqrt(log(2))*wL1/wG1)**2+ ((sqrt(4*log(2))*(x1- xc1)/wG1)-t)**2) return y0+(A*(2*log(2)/pi**1.5)*(wL/wG**2)*…
0
votes
1 answer

Python: fsolve near asymptotic region

For E=0.46732451 and t=1.07589765 I am trying to solve for the upper limit of the integral t= \int_{0}^{z} 1/sqrt(2*(0.46732451-z**2)), I plotted this function and it looks like this . Around t=1 it kind of asymptotes. I have the following code…
HuShu
  • 501
  • 6
  • 19
0
votes
0 answers

Integrating an array using scipy.integrate.quad and nquad "Does not return valid float"

I want to plot a function that takes a number, uses it as a parameter in an integration, and returns the result of the integration. The function returns values just fine when I input a single float number. But when I give it something like…
Soundsgoood
  • 315
  • 3
  • 8
0
votes
0 answers

How to take the double integral of an equation with an integral in python?

I'm trying to integrate this function in Python: I = integral(integral( g(y) * ln[f(x,y)/g(y)] dx) dy) where g(y) = integral(f(x,y)dx) from 0 to 1 eq = lambda x: x #NOTE: want to be able to be able to input any equation f = lambda x,y:…
0
votes
0 answers

Integration of a function of two variables

I have a function func(rp,pi) for which I now have the values. I also have the values of rp and pi. I now need to integrate this function within the limits of 0 to pi How do I go about using quad from scipy to solve this? The doubt I have is, how…
Srivatsan
  • 9,225
  • 13
  • 58
  • 83
0
votes
1 answer

How to define the sequence of discontinuity points for integrate.quad method

I have an integrand similar to Dirac Delta Function. But it is finite and with a very narrow base. I need to integrate it, but quad method has not recognized this singularity. After looking in python docs: points : (sequence of floats,ints),…
Margaral
  • 27
  • 1
  • 10
0
votes
2 answers

error in math formulas in python code scipy

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 =…
littleg
  • 45
  • 5
0
votes
0 answers

Combining function integration with trapz integration

This is what I'm trying to do: Divide a numerically integrated array (over the whole data range) by a "quad" integrated function over a specific integration range: maxw = lambda t,en: exp(-en/(kB*t)) # where the following is inside a loop through t…
dcnicholls
  • 391
  • 1
  • 5
  • 15
-1
votes
0 answers

Problem with optimizing a value function featuring integrals and fractional powers using Scipy quad and optimize

I am trying to run a dynamic optimization with Scipy, that features a definite integral with fixed bounds. However, the optimization fails to send back any value for my objective function, and report two issues (detailed report below) : Roundoff…
GaL
  • 21
  • 3
-1
votes
1 answer

What would be the C code to draw a cylinder between 2 3D vectors in OpenGL? I want it to get proportionally bigger as it is closer to viewer

I'm trying to implement a quad function to draw lines. My goal is to be able to display a beam from one 3D spot to another. But I'm failing at it. Also I want to be able to specify a 3D thickness parameter in the function that draws the…
Grunwaldt
  • 41
  • 8
-1
votes
1 answer

ValueError when using scipy.integrate.quad

I am receiving a ValueError when integrating using scipy.integrate.quad. Here is my simplified code: import numpy as np import scipy.integrate as integrate p = np.arange(0,1,1/1000) h = lambda p: p**2/2+p*(1-p) Kl = lambda p: h(p) + 0.02 K = Kl(p) R…
splinter
  • 3,727
  • 8
  • 37
  • 82
-3
votes
1 answer

python plot integration result , how to do like what Mathematica does

I want to rewrite this Mathematica code into Python, but I was puzzled then, please help me! Thanks a lot. Perhaps the result of an integration is different with array, however, I don' t know! IMAGE: mathematica code which I want to rewrite in…
1 2 3
8
9