Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Problem with quad from SciPy

I have a simple code that seems to work fine (although I cannot be sure when there are several constants like a13 that seem to be integration constants while the integrals are all definite?), at least runs with no error, when the symbolic "integral" function is used instead of "quad", but now using "quad" the code runs into error. This is an example code:


from scipy.integrate import quad



phi11(y)=y*(y-1);    phi12(y)=y*(y-1)*(y+1);    phi13(y)=y*(y-1)*(y^2+1)


U1(y)=sum(alpha1[j]*phi1[j](y) for j in range(3))

     for j in range(3)]

print eq1

The error is:

quadpack.error: Supplied function does not return a valid float.

Any idea how to resolve it? I have tested many different usages of the functions inside the argument of quad, using lambda, explicitly specifying (y) as the argument of the functions, defining a function Y(y)=y so to use Y instead of y in writing the expression "yU1phi1[j]", and etc but all with no success. Searching the web also didn't help much. Please bare with me I am not an expert.