I'm trying to compute the following Fourier coefficients
where V_{pot} is a previous def function of this form.
I really don't know what numerical method I can use, however I began with Simpson’s rule of scipy library.
import numpy as np
from scipy.integrate import simps
Nf = 200
IVp = np.zeros(2*Nf)
snn = np.zeros(NP)
def f(k):
for i in range(0,NP):
sn = (i-1)*H
snn[i] = sn
return (1/SF) * np.cos(np.pi*k*sn/SF) * Vpot(sn)
for k in range(0,2*Nf):
Func = f(k)
y1 = np.array(Func,dtype=float)
I = simps(y1,snn)
I had this error:
IndexError: tuple index out of range