Reputation: 33
Is there a possibility to include more than 1 argument in a quadpy integration?
def function(x,a):
return a*x**2
scheme = quadpy.line_segment.gauss_legendre(10)
scheme.integrate(function, [0,1])
# function() missing 1 required positional argument
Similar to scipy integration:
a=2
scheme.integrate(function, [0,1], args=(a))
Upvotes: 2
Views: 644
Reputation: 58881
You can already do that:
import quadpy
def function(x, a):
return a * x ** 2
scheme = quadpy.c1.gauss_legendre(10)
a = 10
out = scheme.integrate(lambda x: function(x, a), [0, 1])
print(out)
3.3333333333333326
Upvotes: 2