There is a function I am trying to integrate in Python using scipy.integrate.quad
. This particular function takes two arguments. There is only one argument I want to integrate over. An example is shown below.
from scipy import integrate as integrate
def f(x,a): #a is a parameter, x is the variable I want to integrate over
return a*x
result = integrate.quad(f,0,1)
This example doesn't work (as is likely clear to you) since, as Python reminds me when I try it:
TypeError: f() takes exactly 2 arguments (1 given)
I am wondering how to use integrate.quad()
to integrate in a single variable sense when the function given is, in general, a multi-variable function, with the extra variables providing parameters to the function.