Error in RK4 algorithm in Python
问题 I am solving a nonlinear Schrodinger (NLS) equation: (1): i*u_t + 0.5*u_xx + abs(u)^2 * u = 0 after applying Fourier Transform, it becomes: (2): uhat_t = -0.5*i*k^2 * uhat + i * fft(abs(u)^2 * u) where uhat is the Fourier Transform of u . The equation (2) above is a pretty stated IVP, which can be solved by the 4th oder Runge-Kutta method. Here are my code for solving equation (2): import numpy as np import math from matplotlib import pyplot as plt from matplotlib import animation #-----