# A soliton of light The magnitude of a pulse of light in a glass fibre at five times: it moves and does not spread. ```python import sympy as sp import pdemagic as pm x, t = sp.symbols("x t", real=True) psi = sp.Function("psi")(x, t) fibre = pm.Problem( sp.Eq(sp.I * psi.diff(t), -psi.diff(x, 2) / 2 - sp.Abs(psi) ** 2 * psi), domain=pm.Space(x, periodic={x: (-24, 24)}), time=(t, 0, 6), initial={psi: sp.exp(2 * sp.I * x) / sp.cosh(x + 6)}, ) pm.solve(fibre).plot() ``` ## What it shows The nonlinear Schrödinger equation, $i\,\psi_t = -\tfrac12\psi_{xx} - |\psi|^2\psi$, which describes the envelope of a pulse of light in a fibre. The unknown is complex, because the equation contains `sp.I`, and the plot shows its magnitude. The second derivative alone makes a pulse spread, as the [quantum wave packet](quantum-wave-packet.md) does. The cubic term, `sp.Abs(psi) ** 2 * psi`, pulls it together. For the pulse $1/\cosh x$ the two are in balance: it moves with the speed 2 that its phase $e^{2ix}$ gives it, and keeps its height and its width. At the end the solution agrees with the formula for this soliton to seven digits. ## What pdemagic decided The planner chose exponential time stepping of fourth order (`exponential_runge_kutta`): the second derivative is exact, and the cubic term is stepped, in 640 steps that each err by less than $10^{-10}$ of the solution. The grid has 512 points, the finest that the planner tries by itself. Its plan says that the spectrum of the initial state has only fallen to $5\cdot10^{-10}$ there, a little short of its aim, because the pulse fades slowly towards the ends of the period. ## More - [Complex unknowns](../topics/complex.md) - [Nonlinear equations in time](../topics/nonlinear-time.md) - [Nonlinear equations in time: the method](../methods/exponential.md) - [What is solved in free space and on periodic boxes](../ref/equations-free-space.md)