A spectral solver for Schrödinger’s equation

Here is a MATLAB program for solving the 1D time-dependent Schrödinger equation:

You can specify a potential function and an initial condition, and the solver calculates the wavefunction at future times. Hopefully this will be useful for getting some intuition as to how solutions to Schrödinger’s equation behave.


The solver uses a spectral method which performs the time-integration exactly. Errors come from the spatial discretisation. The calculation is done in a periodic domain, so edge effects may affect your solution, especially in scattering problems.


Fourier-transforming the solution in space tells you about the relative strengths of different wavenumber components of the solution, and therefore about the momentum distribution at each time.

Fourier-transforming in time tells you about the different frequency components in the solution, which you can use to identify energy eigenstates. Note that you might have to calculate the solution for a long time before you have enough periods for the Fourier transform to be precise enough.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.