I want to integrate a product of two functions x(t)*p1(t) as t goes from -1 to 1.
At the moment I have this code written:
import scipy.integrate as s
import numpy as np
p1 = lambda t: 1
p2 = lambda t: t
p3 = lambda t: (3*(t**2)-1)/2
x = lambda t: abs(t)
integral = s.quad(x*p1, -1, 1)
print(integral)
However, I am getting the following error:
TypeError: unsupported operand type(s) for *: 'function' and 'function'
Is it possible to combine two lambda functions symbolically to integrate them? I could define a function xp1 = lambda t: x(t)*p1(t), but since I have to do this for all pn, this seems kinda inefficient.
Is there a cleaner way to do this?