I wrote a script to illustrate the superposition principle. The more cosine functions are superpositioned, the more precise can the position be described (by integrating over the probability density). Naturally, all information about the momentum is lost, since the probability of each momentum component becomes smaller and smaller with increasing superposition number.
The foregoing is illustrated by the below figure.
What I want to achieve now is to have this be interactive on the web. Since the only variable in the calculation is an integer (the number of superpositions), I would like to introduce something like a knob, which the user can click and turn and by doing so increase/decrease the number of superpositions. While he is doing this, the figure should update dynamically, i.e. for every selection the correct wavefunction should be displayed.
How can this be done? What are the general requirements for this? We will see.