After reading this and that , it seems to me that both “square” and “quadrature” should be interchangeable *, at least syntactically. Strange, it seems this is not the case:
from scipy.integrate import quad as q
... the example works fine for "quad", but not for "quadrature" - the result is:
Traceback (most recent call last): File "./test.py", line 38, in <module> print integr2(10) File "./test.py", line 36, in integr2 return q(myfunc2, 0, 1, args=(y))[0] File "/usr/lib/python2.6/dist-packages/scipy/integrate/quadrature.py", line 136, in quadrature newval = fixed_quad(vfunc, a, b, (), n)[0] File "/usr/lib/python2.6/dist-packages/scipy/integrate/quadrature.py", line 48, in fixed_quad return (ba)/2.0*sum(w*func(y,*args),0), None File "/usr/lib/python2.6/dist-packages/scipy/integrate/quadrature.py", line 77, in vfunc return func(x, *args) TypeError: myfunc2() argument after * must be a sequence, not int
I need to switch the args tuple to a list (cf. commented line in integr2), although the documentation says that it should be a tuple. This seems to be what the interpreter is talking about ... (right?)
Is this intended? Or am I doing something wrong? In the end, I would like to be able to choose integration methods after that, without changing too much of the rest of the code.
* In fact, I do not understand how to choose between them. I understand the difference between a Gaussian quadrature and an adaptive quadrature, but I don’t know what “adaptive Gaussian quadrature” means, is the number of nodes adapted, if so, how !?