Here is an integration routine I found on another question see Use scipy.integrate.quad to integrate complex numbers. I am happy with its functionality but I wish to be able to perform the integration on my input function for different values of the parameter 't' and to do so using vectorization.
import numpy as np
from scipy.integrate import quad
def complex_quadrature(func, a, b, t):
def real_func(x,t):
return np.real(func(x,t))
def imag_func(x,t):
return np.imag(func(x,t))
real_integral = quad(real_func, a, b, args=(t))
imag_integral = quad(imag_func, a, b, args=(t))
return (real_integral[0] + 1j*imag_integral[0], real_integral[1:], imag_integral[1:])
vcomplex_quadrature = np.vectorize(complex_quadrature)
t = np.linspace(1,4,4)
print(vcomplex_quadrature(lambda x, t: (np.exp(1j*x*t)), 0, np.pi/2, t))
Can anyone provide some help with this?