The time dependent Schrödinger equation is:
A naive implementation using Eulers method where will usually cause the waveform to explode due to floating point and integration errors.
Because is usually derived from quantizing a classical theory, it's an infinite dimensional vector in a Hilbert space. So assigning a complex number to each possible position. For the simulation we will approximate it as a finite dimensional vector by discreetizing it over points so . Similarily is now a finite (Hermetian) matrix. The equation stays the same, but it's now in a finite dimensional Hilbert space:
Assuming the Hamiltonian isn't time dependent, the differential equation has the closed form solution using matrix exponentiation.
We should now actually define the Hamiltonian operator . The original discreet version for a non-relativistic particle with some potential function is the linear operator:
Since we discreetized as a finite dimensional vector, we replace the second derivative with the finite difference method.
So for each position of we can make a matrix below. We assume no repeating boundary conditions. The matrix is equivelent to the Laplacian of a path graph.
The potential term is simply the value at each point:
is the sum of those two matricies
Each discrete step of the simulation will go through a certain change in time using the matrix exponent of the Hamiltonian operator. It should be simple to put it into a for loop now.