4

The go-to reference on this topic is the extensive book by Hairer, Lubich, & Wanner (HLW). The kind of property you are dealing with is known as a quadratic invariant, since $\|x(t)\|^2$ is constant. These are covered in Section IV.2 of the book. Any quadratic invariant will be preserved by a Runge-Kutta method if the method coefficients satisfy $$ ...


3

You could use a discretization method such as the finite element or finite difference method with a linearization technique such as Picard or Newton method to solve this problem. A similar question is this. The main idea of these solution techniques is as follows: Pick an initial guess for the solution. Linearize your equation and write an updated solution ...


2

Indeed the problem was that you were trying to calculate your nonlinear term incorrectly and you forgot that: $$\mathcal{F}[(f(x))^{2}] \neq (\mathcal{F}[f(x)])^{2}$$ I changed your code to this: import numpy as np import matplotlib.pyplot as plt from matplotlib.pyplot import cm nu = 1 L = 100 nx = 1024 t0 = 0 tN = 200 dt = 0.05 nt = int((tN - t0) / 0....


2

Are you sure that you have the correct boundary conditions? I think the equation you state for the analytical case, $$H=x/\tanh(x)-1$$ is incompatible with the boundary condition $H(\bar{\epsilon})=\bar{\epsilon}$ where $\bar{\epsilon}$ is large. Maybe this is why you are getting incorrect behaviour for large $x$? I tried solving your equation for the $\...


Only top voted, non community-wiki answers of a minimum length are eligible