### Object-Oriented Quantum Mechanics

Frank J. Kampas
fkampas@msn.com

One of the fundamental principles of object-oriented programming is that the internal structures of objects are private (hidden). The response of the objects to "messages" passed to them is independent of their internal structures. This is similar to the fact that measurements upon quantum mechanical states give definite results independent of the various ways in which the states may be represented (e.g., wave functions, vectors in a Hilbert space). This similarity is illustrated here by constructing objects which represent both the states of a quantum mechanical harmonic oscillator and the operators associated with measurements on those states.

Object-oriented programming can be implemented in Mathematica using Roman Maeder's package Classes.m (available from www.mathsource.com/Content/0205-186), which is described in [1, p. 60] and [2, p. 293]. First we load the package.

Now we can construct the simple harmonic oscillator class, sho. The class members are states of definite energy, described by two instance variables: a complex amplitude a and a nonnegative integer quantum number n.

· new is the constructor.
· amp and num return the amplitude and quantum number of the object.
· mult multiplies the amplitude of the state by a constant.
· raise and lower increase and decrease the quantum number, respectively.
· The energy function corresponds to measuring the energy of the state and returns the state multiplied by its energy. is Planck's constant divided by , and is the radial frequency of the corresponding classical harmonic oscillator.
· inprd returns the inner product of two states. The inner product of states and is designated by in Dirac bracket notation [3, p. 19].

Note that the raising and lowering operators do not correspond to physical variables, but will be useful for defining other functions. Also note that the states are not normalized unless the magnitude of a is 1.

We use a simple trick for computing the complex conjugate of complex expressions involving real variables using a replacement rule.

The Dirac bracket notation can be implemented using the Notation package.

It is also useful to have a notation for mult.

The following steps illustrate the construction of a state s with an amplitude of 1 and a quantum number of 2, and the determination of the expectation value of its energy, which is in Dirac notation.

The next step is the construction of a class whose members are linear combinations of states with definite energy. Members of class lincom are sequences of objects of type sho.

· new is the constructor.
· states returns a list of the sho components making up a variable of type lincom.
· mult and inprd are similar to the functions in class sho and are based upon them.
· The functions x and p are the position and momentum operators, respectively.

Using the two classes, it is possible to calculate the matrix elements of the x and p operators, which are defined as and , where and are states with amplitude 1 and quantum numbers and , respectively.

Single energy state members of the class lincom are constructed first.

The following are scaled matrix representations of x and p (see [4, p. 103]).

It is also possible to construct time-dependent states s(i, t) after constructing a function which gives the energy of a state with quantum number i.

Constructing an equal mixture of the two states s(0, t) and s(1, t),

we compute the expectation value of the position operator, .

We see that oscillates back and forth at frequency .

Converted by Mathematica

[Article Index] [Prev Page][Next Page]