function [chf,f]=charge_frequencies(x)

global Q num_ch m gap volt tf time_nb

NFFT = 2^nextpow2(time_nb);
t = linspace(0,tf,time_nb);
q0 = -Q*num_ch/(2*pi);
a0 = num_ch*Q*volt/(2*m*gap);
d = gap+a0*t.^2;
ch = q0./(d.^2.*(1+x.^2./d.^2).^(3/2));
chf=fft(ch,NFFT)/time_nb;
f = pi*tf/time_nb*linspace(0,1,NFFT/2+1);



