The correct way to call quad
with your I
is:
In [20]: quad(I, 0, 10, args=(1,2))
Out[20]: (0.6984886554222364, 1.1361829471531105e-11)
As Longwen points out, the first argument to I
is the z
that quad
varies. The (y,a)
are parameters that quad
passes on to I
without change.
But you got the error because you tried using an array as the z
boundary
In [21]: quad(I, 0, np.arange(3), args=(1,2))
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-21-fbbfa9c0cd3f> in <module>()
----> 1 quad(I, 0, np.arange(3), args=(1,2))
/usr/local/lib/python3.5/dist-packages/scipy/integrate/quadpack.py in quad(func, a, b, args, full_output, epsabs, epsrel, limit, points, weight, wvar, wopts, maxp1, limlst)
313 if (weight is None):
314 retval = _quad(func, a, b, args, full_output, epsabs, epsrel, limit,
--> 315 points)
316 else:
317 retval = _quad_weight(func, a, b, args, full_output, epsabs, epsrel,
/usr/local/lib/python3.5/dist-packages/scipy/integrate/quadpack.py in _quad(func, a, b, args, full_output, epsabs, epsrel, limit, points)
362 def _quad(func,a,b,args,full_output,epsabs,epsrel,limit,points):
363 infbounds = 0
--> 364 if (b != Inf and a != -Inf):
365 pass # standard integration
366 elif (b == Inf and a != -Inf):
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
ValueError when using if commands in function - another recent question trying to do the same thing, use an array as an integration boundary. That post gave more of the error traceback, so it was easier to identify the problem.
If it hadn't been for this ValueError, your 3 term args
would have produced a different error:
In [19]: quad(I, 0, 10, args=(10,1,2))
....
TypeError: I() takes 3 positional arguments but 4 were given