function out = Xode(t,c) global n2 N D a % reconstruct u uf = [0 ; -flipud(c(2:end)) ; c]; u2 = ifft(fftshift(-i*uf))*N; u = real(u2(1:N)); % calculate coeffs of nonlinearity f = - (u-1+a).*(u+1+a).*u; f2 = [f ; 0 ; -flipud(f(2:end))]; ff = -imag(fftshift(fft(f2))/N); cf = ff(N+1:2*N); out = -D*(n2.*c) + cf;