Compute a definite integral.
Integrate func from a to b (possibly infinite interval) using a technique from the Fortran library QUADPACK.
If func takes many arguments, it is integrated along the axis corresponding to the first argument. Use the keyword argument args to pass the other arguments.
Run scipy.integrate.quad_explain() for more information on the more esoteric inputs and outputs.
Parameters : | func : function
a : float
b : float
args : tuple, optional
full_output : int
|
---|---|
Returns : | y : float
abserr : float
infodict : dict
message : :
explain : :
|
Other Parameters: | |
epsabs : :
epsrel : :
limit : :
points : :
weight : :
wvar : :
limlst : :
wopts : :
maxp1 : :
|
See also
odeint, ode, simps, trapz, romb
Examples
Calculate and compare with an analytic result
>>> from scipy import integrate
>>> x2 = lambda x: x**2
>>> integrate.quad(x2,0.,4.)
(21.333333333333332, 2.3684757858670003e-13)
>> print 4.**3/3
21.3333333333
Calculate
>>> invexp = lambda x: exp(-x)
>>> integrate.quad(invexp,0,inf)
(0.99999999999999989, 5.8426061711142159e-11)
>>> f = lambda x,a : a*x
>>> y, err = integrate.quad(f, 0, 1, args=(1,))
>>> y
0.5
>>> y, err = integrate.quad(f, 0, 1, args=(3,))
>>> y
1.5