Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
457 views2 pages

How To Generate A Quantum Harmonic Oscillator in MATLAB

The document describes how to generate the creation and annihilation matrices (a and a†) for modeling a quantum harmonic oscillator in MATLAB without using loops. It explains that a is a diagonal matrix with entries given by the square roots of integers from 0 to the dimension, and a† is its transpose. It then shows the code to generate these matrices in a single line by taking the square root of a sequential array, making it diagonal, and circularly shifting to obtain a.

Uploaded by

Hans
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
457 views2 pages

How To Generate A Quantum Harmonic Oscillator in MATLAB

The document describes how to generate the creation and annihilation matrices (a and a†) for modeling a quantum harmonic oscillator in MATLAB without using loops. It explains that a is a diagonal matrix with entries given by the square roots of integers from 0 to the dimension, and a† is its transpose. It then shows the code to generate these matrices in a single line by taking the square root of a sequential array, making it diagonal, and circularly shifting to obtain a.

Uploaded by

Hans
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

How to generate a Quantum Harmonic Oscillator

creation and annihilation matrices in MATLAB


C.B.
May 19, 2007

A Small Introduction - The Harmonic Oscillator

The Hamiltonian for a 1-dimensional quantum harmonic oscillator is


H = Q2 + P 2
where


Q=

h
(a + a )
2m


hm
(a a)
P =
2
P and Q are the kinetic and potential energy operators for the harmonic
oscillator h, m and are constants. The symbols a and a represent the
creation and annihilation matrices.
If one wishes to create an anharmonic potential, the potential energy
operator will be different. A simple anharmonic potential is the double well
potential, in this case


Hdwp = Q4 Q2 + P 2
So if we can generate the P and Q matrices, the quantum oscillator
can be numerically solved for any potential by simply diagonalizing the
Hamiltonian matrix.
The a and a matrices look like the following.

0
0
0 0 ...
0
1 0
0 ...

0 0
1 0
0 0 ...
2 0 . . .

0
2
0
0
.
.
.
0
0
0
3
.
.
.
a=

a =
0 0

0
0
3
0
.
.
.
0
0
.
.
.

..
..
..
..
..
.. . .
..
.. . .
.
.
.
.
.
.
.
.
.
.
Because a is a real matrix its hermitian conjugate a , is just the transpose
of a. Thus in MATLAB if we generate a we can trivially generate a .
1

Generating a and a Matrices in MATLAB

It may look that the two matrices can be easily generated by a simple loop.
However we can avoid the use of loops to make the code run much faster,
especially if the dimension of the matrices is very large.
Firstly we create a temporary 1-dimensional sequential array named
tempvector up to the desired dimension of the matrix matdimension
tempvector =

0:1:matdimension;

Then we take the square root of each number in our temporary array
and store it back in the same variable
tempvector = sqrt(tempvector);
Then we generate a diagonal matrix with our temporary vector as the
diagonal
tempmatrix = diag(tempvector);
and finally we generate the creation matrix by simply performing a circular shift of the temporary matrix
creation = circshift(tempmatrix,-1);
and the annihilation matrix annihilation is just the transpose of creation
annihilation = creation;
All the above steps can be combined into one line of code to produce the
same result:
creation = circshift(diag(sqrt(0:1:mat_dim)),-1);

You might also like