I am trying to calculate the derivative of a function from the fourier coefficients of this function with IJulia.
for that, i there is a link between the fourier coefficient of the function and the fourier coefficient of the derivative , being X'[k]=X[k]*2*piik/N, is that right?
i wanted to verify this simple fact by starting from the usual square function x^2, computing its fourier transform and then obtaining the derivative by inverse fourier transform.
here is my code :
theta=-pi:pi/100:pi; # definition of the variable
four=fft(theta.^2); # computing DFFT of the simple square function
fourder=Array{Float64}(length(four)); # creating array for derivative
fourder=complex(fourder); # allowing complex values
for k=1:length(fourder)
fourder[k]=four[k]*2*pi*im*(k-1)/length(four); # formula transformation from function coefficients FFT to its derivative
end
test2=ifft(fourder); # computing inverse fourier transform
But with this algorithm i obtain something really far from what i am supposed to obtain (2x)...
What am I doing wrong? I think it might be a problem of discretization but i dont understand how to do what i want to do in an other way.
Thank you