# Quantum Matrix Diagonalization Visualized

 Process the drawn potential. ✅ Clear the current potential to draw another. ❌
Matrix options: nmax = 8
Reset    Cell highlighting
Color scheme:
Positive Negative Zero
Contrast = 1.0
Current cell: Find max cell
H =
θ = °
Rotate
Plot display options:
Emax =
scale = 1.00
Colorful wavefunctions
Display energies
Potential options: V(x):
= 100
Update Hamiltonian Matrix
Discretized potential
Grid size = 20

### The basics

• Select a colored off-diagonal matrix cell by clicking on it. Notice the highlighting of the two wavefunctions that correspond to the selected row and column.
• Rotate the angle dial (light blue disk) and see the effects on the rows and columns of the selected cell. Also watch the two selected wavefunctions mix with each other.
• Try to zero out the selected cell by rotating the dial until the cell is white (or black) and the displayed Hmn value is close to zero. What does this do to the wavefunctions?
• Continue zeroing out off-diagonal cells. What is happening to the matrix?
• If you are having a hard time distinguishing colored shades, adjust the contrast slider.
• Try playing around with the other settings or see below for explanations.

### Explanation

• The colored grid represents a Hamiltonian matrix for a quantum particle in one dimension, subject to the selected potential. The matrix is initially expressed in a basis of sinusoidal functions.
• Brighter grid cells represent larger matrix element magnitudes, while small magnitudes fade into a selected zero color (black or white).
• “Rotating a cell” corresponds to performing a rotation in the two-dimensional subspace spanned by the basis functions of the selected row and column; we’ll come back to this.
• As these rotations are performed the plotted wavefunctions are adjusted accordingly, at a vertical level corresponding to their average energies, with these energies also displayed numerically.
• The wavefunctions are drawn over a plot of the potential energy, so you can see which parts of the functions are in classically allowed regions. Note that the vertical scale for the wavefunctions is unrelated to the energy scale.
• The goal is to solve the time-independent Schrödinger equation (TISE) by diagonalizing the Hamiltonian matrix; this corresponds to making the grid white (or black) everywhere off the main diagonal. The plotted basis functions are then the energy eigenfunctions, and their energies are the corresponding eigenvalues.

### User interface

• The Rotate button is a short-cut to using the dial. It performs a rotation in the selected two-dimensional subspace to zero out the selected matrix element.
• You can use the Find max cell button to select the maximum (in magnitude) off-diagonal cell. Zeroing out this cell helps diagonalize the matrix more quickly.
• You can click on a diagonal matrix element to see its numerical energy value and highlight the corresponding wavefunction.
• Press the Reset button to reset the matrix to the original sine-wave basis functions.
• Use the nmax slider to vary to size of the matrix. Higher settings give more accurate results, but the diagonalization process requires more steps.
• Select a potential function to explore different one-dimensional quantum systems.
• Use the Draw a new potential option to draw a potential energy function of any shape, using the current potential function as a starting point.
• You can select colors to show positive and negative matrix elements, as well as a zero color.
• Adjust the contrast slider to change how the element magnitudes are related to brightness. A value of 1 sets the maximum brightness to the maximum energy on the grid.
• When you select a cell, its rows and columns are highlighted. To make this less pronounced you can uncheck “Cell highlighting”.

For a complete explanation of what this program is doing, please see the related paper in the American Journal of Physics (preprint at arXiv:1905.13269 [physics.ed-ph]). Here is a brief summary $$\ldots$$

Our goal is to solve the time-independent Schrödinger equation (TISE), $$\hat{H} \psi_n(x) = E_n \psi_n(x),$$ where the Hamiltonian operator $$\hat{H}$$$$= -\frac{1}{2} \frac{d^2}{dx^2} + V(x)$$ (in units where $$m = ℏ = 1$$) includes the potential energy function shown above (right).

To do so we expand $$\psi_n(x)$$ in terms of a set of normalized sine-wave basis functions, also initially shown above. Denoting these functions as $$\varphi_m(x)$$, we write the expansion as $$\psi_n = \sum_m c_{mn} \varphi_m,$$ where the first subscript on the coefficient $$c_{mn}$$ indicates which component, while the second subscript indicates which $$\psi_n$$ eigenfunction. Inserting this expansion on both sides of the TISE and then taking the inner product with an arbitrary basis function $$\varphi_l$$, we obtain (after a few algebraic steps) the TISE in matrix form:

$$\begin{bmatrix} H_{11} & H_{12} & \cdots \\ H_{21} & H_{22} & \cdots \\ \vdots & \vdots & \ddots \\ \end{bmatrix} \begin{bmatrix} c_{1n} \\ c_{2n} \\ \vdots \end{bmatrix} = E_n \begin{bmatrix} c_{1n} \\ c_{2n} \\ \vdots \end{bmatrix}.$$

Here the matrix elements $$H_{mn}$$ are defined by integrals,

$$H_{mn} = \langle \varphi_m | \hat{H} | \varphi_n \rangle = \int\!\varphi_m(x)\hat{H}\varphi_n(x)\,dx,$$

which the program computes when it loads, and whenever the matrix is reset. The results are displayed above (left) as colored squares.

To solve the matrix eigenvalue problem we use a method devised long ago by Jacobi. Note that the normalized column eigenvectors form an orthogonal matrix $$C$$, which we break down into a product of elementary rotation matrices $$R_i$$:

$$C = \begin{bmatrix} c_{11} & c_{12} & \cdots \\ c_{21} & c_{22} & \cdots \\ \vdots & \vdots & \ddots \\ \end{bmatrix} = R_1 R_2 R_3\ldots,$$

where the subscripts on the $$R_i$$ symbols indicate the sequence of rotations. Each rotation matrix has the form

$$R = \begin{bmatrix} \,1 \\[-5pt] & \ddots \\ && \cos\theta & \cdots & {-}\sin\theta \\[-3pt] && \vdots & 1 & \vdots \\ && \sin\theta & \cdots & \ \cos\theta \\[-3pt] &&&&& \ddots \\ &&&&&& 1\, \\ \end{bmatrix},$$

consisting of an identity matrix except for the four entries that accomplish a rotation by $$\theta$$ in a particular plane. When you click on an off-diagonal matrix cell above, you are selecting the plane for one of these rotations. Turning the dial changes the rotation angle $$\theta$$.

Each rotation modifies the Hamiltonian matrix according to $$H_\textrm{new} = R^T H_\textrm{old} R,$$ so if you choose the rotation angle to (approximately) zero out an off-diagonal matrix element, the new Hamiltonian will be closer to diagonal than the old one. Eventually, after enough of these rotations, you will have diagonalized the Hamiltonian so that its diagonal elements are the energy eigenvalues.

Meanwhile, the program accumulates the product of rotation matrices to form successive approximations to the matrix $$C$$ of eigenvectors, and uses these (approximate) eigenvectors to construct and plot the (approximate) eigenfunctions $$\psi_n(x)$$ as the calculation proceeds.

The Rotate button calculates the optimum rotation angle according to the formula

$$\theta = \frac{1}{2} \tan^{-1} \biggl( \frac{2H_{mn}}{H_{mm} - H_{nn}} \biggr),$$

where $$m$$ and $$n$$ are the chosen row and column numbers. To derive this formula, multiply out the matrix product $$R^T H R$$ in the rotating two-dimensional subspace, and set either off-diagonal element to zero.

• Version 1.0, August 2019. The program uses ES6 so it is not supported on Internet Explorer. Please send bug reports to kevinrandles@mail.weber.edu.
• Created by Kevin Randles, Weber State University
Design contributions by Dan Schroeder, Weber State University
Original concept and prototype by Bruce Thomas, Carleton College
• This is open-source software. Use your browser’s View Source or Page Source menu command to see the source code and copyright notice.
• For more physics software visit physics.weber.edu/schroeder/software/. See especially the Wave Builder web app, which shows in a simpler context how to construct arbitrary wavefunctions out of basis functions.