## Solutions to the Schrodinger Equation

This applet illustrates the use of a "Shooting Method" to find solutions to the Schrodinger equation, with various different types of potential function. The default is "square wells", where the potential V(x) is constant, save for finitely many square wells.

The potential function is shown on the left-hand side of the applet, along with a marker indicating the chosen energy. There are controls for setting parameters for the potential function: the depth, width and number of the wells may be adjusted.

On the right-hand side is the wave function for the chosen energy and potential. The vertical red lines mark the edges of the potential well(s); when there is only one well, these markers may be dragged horizontally to change the width of the well.

Since the Schrodinger equation only has solutions for certain values of the energy, the wave function shown is not necessarily a solution. Examine the edges of the displayed portion of the function - these should be tending towards zero for a solution.

## Finding solutions

### Manually:

The energy marker (red horizontal line) may be dragged using the mouse, and the wave function display will update accordingly. Since a small change in energy can have a drastic effect on the wave function, it is difficult to find a solution this way with any accuracy at all. Normally, the square of the wave function is plotted - this can be changed using the checkbox provided. If we don't square the function, we can watch the right-hand edge of the function change sign as we vary the energy. If the function tends to positive infinity, then we can slowly change the energy until it tends to negative infinity, and we know that a solution lies between the two.

### Automagically:

If it is known that there is a solution within some energy interval, then that interval can be marked on the potential graph, and the solution found by bisection. To do this, click and drag with the right-hand mouse button on the potential graph; the selected area should appear shaded. Now click the Solve button, and the applet will attempt to find a solution in that interval. You should see the wave function graph rapidly change until it has converged on the solution. The validity of the end result depends on how many solutions the chosen interval contained:

• If the marked interval contains exactly one solution, it will be found
• If there are no solutions, the energy marker will return to the previously selected energy value
• If there were multiple solutions, the applet will attempt to find one of them, but may fail

The selected region may be cleared by clicking the RMB on the potential graph (without dragging); searching for a solution with no region selected is equivalent to searching over the whole depth of the well. Where there are multiple solutions, the applet will use the currently selected energy value as a "hint" to help find a solution, so the results may depend on the position of the energy marker. This is not intended to be a reliable way to find a particular solution, but does improve the probability of finding one solution of a closely spaced group (when even a tiny interval will contain several solutions).

The "square wells" potential may be exchanged for a quadratic potential - use the checkbox provided to switch between the two. With the obvious exception of the controls for depth, width and number of wells, everything behaves in exactly the same way.

## Custom function

With this function type selected, the potential is given by an expression chosen by the user, and entered in the "Potential function" field. The standard arithmetic operators (`+ - * /`) are supported, with the caret symbol (`^`) meaning "to the power of".

The `sin`, `cos`, `tan`, `abs` and `exp` functions are supported; function arguments should be enclosed within brackets (eg. `sin(x)` instead of `sin x`. The letter '`x`' represents the x parameter to the function; the name "pi" will give the value of pi. Extra whitespace between operators is permitted, but not between a function name and the opening bracket.

## Freehand function

When this option is selected, a potential function may be drawn using the mouse cursor - simply click and drag on the potential function. Drawing is assumed to be finished when the mouse button is released, after which further clicks will move the energy slider. To enter drawing mode again, click the "Draw new function" button.

## Miscellaneous

The width of the interval considered is usually wider than that of the region displayed (10 units). This may be increased using the Integration width box. The default is usually sufficient, but increasing the size of the interval may provide more convincing results if the wave function appears to "float" above the x-axis. An excessively large interval width may reduce the accuracy of the applet.

The applet uses a numerical method to provide the wave function graph. Increasing the number of steps (using the box provided) will improve the accuracy of the applet, although the default is usually more than adequate. An excessively large number of steps will reduce the speed of the applet (calculation time is directly proportional to the number of steps), and may even have a negative effect on accuracy.

## How does it work?

The applet uses the fourth order Runge-Kutta method to numerically integrate the Schrodinger equation. Solutions are found by bisection; where neither interval is guaranteed to contain a solution (multiple solutions or no solution), the interval containing the previously selected energy value is chosen as a guess.

The "custom" potential function is handled by a recursive descent parser which operates on the entire input. This does not provide impressive scalability (the parser is not LL(k) for any k), but so long as the number of operators is reasonable (less than 200, say), there should be no noticable performance reduction. The values of the potential function are of course cached, so that the function will only be parsed once, and only evaluated once for each x value.

Documentation