I'm currently trying to understand the fft function from numpy. To do this, I tested the following assumption:
I have two functions: f(x) = x^2 and g(x) = f'(x) = 2*x . According to the laws of the Fourier transform and tungsten alpha, it must be that G(w) = 2pi*i*F(w) (prefactors can vary, but there should be only a constant factor). When implementing this in python, I write
import numpy as np def x2(x): return x*x def nx(x): return 2*x a = np.linspace(-3, 3, 16) a1 = x2(a) a2 = nx(a) b1 = np.fft.fft(a1) b2 = np.fft.fft(a2) c = b1/b2
Now I expect an almost constant value for c , but I get
array([ 1.02081592e+16+0.j , 1.32769987e-16-1.0054679j , 4.90653893e-17-0.48284271j, -1.28214041e-16-0.29932115j, -1.21430643e-16-0.2j , 5.63664751e-16-0.13363573j, -5.92271642e-17-0.08284271j, -4.21346622e-16-0.03978247j, -5.55111512e-16-0.j , -5.04781597e-16+0.03978247j, -6.29288619e-17+0.08284271j, 8.39500693e-16+0.13363573j, -1.21430643e-16+0.2j , -0.00000000e+00+0.29932115j, -0.00000000e+00+0.48284271j, 1.32769987e-16+1.0054679j ])
Where is my mistake, and what can I do to use fft as intended?
source share