Let's say the position of an object is given by simple sine function. By elementary calculus, I can calculate the acceleration in the time domain and find its Fourier transform. I can also calculate the Fourier transform of velocity and multiply it by frequency or multiply the Fourier transform of position by frequency square. All these three methods should yield the same Fourier transformed accelerations(within numerical accuracy).
Source: http://prosig.com/wp-content/uploads/pdf/blogArticles/OmegaArithmetic.pdf
However, as you can see in the attached plot the magnitude of Fourier transformed acceleration is off by orders of magnitude. Can you please point out what I am doing wrong? I understand that the peak frequency is the same but the magnitudes and overall shape of plots is worrying me.
Here is my code
N =2**8
a =1
t=np.arange(N)
t = np.linspace(-100,100,N)
fs= 2
freq_normalized = rfftfreq(N)*fs
y = np.sin(a*t)
vel = np.cos(a*t)
acc = -np.sin(a*t)
fft_y = np.abs(rfft(y))
acc_y = [a*b**2 for a,b in zip(fft_y,freq_normalized)]
fft_v = np.abs(rfft(vel))
acc_v = [a*b for a,b in zip(fft_v,freq_normalized)]
acc_a = np.abs(rfft(acc))
acc_ifft_v = irfft(acc_v)
acc_ifft_y = irfft(acc_y)
acc_ifft = irfft(acc_a)
fig, ax = plt.subplots(figsize=(12, 8))
ax.spines['left'].set_position('center')
ax.spines['right'].set_color('none')
ax.spines['bottom'].set_position('center')
ax.spines['top'].set_color('none')
ax.spines['left'].set_smart_bounds(True)
ax.spines['bottom'].set_smart_bounds(True)
ax.xaxis.set_ticks_position('bottom')
ax.yaxis.set_ticks_position('left')
plt.plot(t,y)
plt.ylabel(r'$ y $', fontsize=16)
plt.xlabel(r'$ t $', fontsize=16)
plt.xticks(fontsize=15)
plt.yticks(fontsize=15)
plt.show()
fig, ax = plt.subplots(figsize=(12, 8))
plt.title('Fourier spectrum from position')
plt.plot(freq_normalized,acc_y)
plt.ylabel(r'$ a_{\omega} $', fontsize=16)
plt.xlabel(r'$ \tilde \omega $', fontsize=16)
plt.xscale('log')
plt.yscale('log')
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.show()
fig, ax = plt.subplots(figsize=(12, 8))
plt.title('Fourier spectrum from velocity')
plt.plot(freq_normalized,acc_v)
plt.ylabel(r'$ a_{\omega} $', fontsize=16)
plt.xlabel(r'$ \tilde \omega $', fontsize=16)
plt.xscale('log')
plt.yscale('log')
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.show()
fig, ax = plt.subplots(figsize=(12, 8))
plt.title('Fourier spectrum from acceleration')
plt.plot(freq_normalized,acc_a)
plt.ylabel(r'$ a_{\omega} $', fontsize=16)
plt.xlabel(r'$ \tilde \omega $', fontsize=16)
plt.xscale('log')
plt.yscale('log')
plt.xticks(fontsize=12)
plt.yticks(fontsize=12)
plt.show()