Learning Objectives
By the end of this section, you will be able to:
- Set up the time-independent Schrödinger equation inside a hard-walled potential and read off the boundary conditions straight from the physics.
- Solve the equation by hand and obtain the eigenfunctions and energies .
- Explain why the energy spectrum is discrete and why the ground state cannot have .
- Interpret the nodes of and use orthogonality to expand any state.
- Compute a real example (electron in a 1-nm box) end to end, in eV and in photon-emission wavelengths.
- Watch a superposition oscillate in time and identify the beat frequency .
- Verify the analytic result numerically by discretizing the Hamiltonian and diagonalizing it in Python and PyTorch.
The Big Picture
"The particle in a box is to quantum mechanics what the simple harmonic oscillator is to classical mechanics: the first place where everything works out cleanly and you can see all the moving parts."
Imagine a bead trapped between two impassable walls a distance apart, free to slide between them but unable to escape. Classically there is nothing to talk about — the bead has whatever energy you gave it and bounces forever. Quantum mechanically, this is the simplest non-trivial problem in physics, and it already contains three of the deepest surprises of the theory:
- Energy is quantized. Only certain discrete energies are allowed:
- The lowest energy is not zero. Even at "rest" the particle has zero-point energy .
- Standing waves replace trajectories. The state is a shape, not a position. The shape has nodes — places where the particle is never found.
What we are about to do
We will write down the Schrödinger equation inside the box, solve the resulting ODE, apply the boundary conditions, and watch quantization fall out of nothing more than the requirement that the wave fit between the walls. Then we will turn the same calculation into a matrix and diagonalize it numerically in Python and PyTorch, and finally we will animate a superposition and discover that a quantum state can actually move even though every eigenstate is stationary.
Setting Up the Box
The infinite square well is the potential
The infinite barrier outside is a mathematical idealization of a physical wall the particle can absolutely not penetrate. The wave function is forced to be zero outside the box, and by continuity it must also vanish on the boundary:
Where the boundary conditions come from
You can derive as a limit. Replace the infinite walls with finite ones of height and solve. The interior solutions are sines/cosines and the exterior ones decay like with . As the decay constant and the exterior wave collapses to zero, dragging the interior wave to zero at the wall for continuity.
Inside the box , so the time-independent Schrödinger equation reduces to:
That is a second-order linear ODE with constant coefficients — the kind of object you have been solving since first-year calculus. The only quantum part is what we will do with it at the boundary.
Solving the Schrödinger Equation
Rearrange the ODE into the familiar harmonic-oscillator form:
For any we have and the general solution is the familiar pair of sines and cosines:
Step 1 — Apply
Plug in : . For this to vanish we need . The cosine piece is killed by the left wall.
Step 2 — Apply
What is left is . The right wall demands . Setting would zero out the wave function everywhere — that is the trivial solution and corresponds to no particle at all. The only useful way to satisfy the equation is to force the sine itself to vanish:
Negative just flips the overall sign of and doesn't give a new physical state. gives , so we throw it out. The allowed values of are therefore:
Boundary Conditions Force Quantization
Look at what just happened. The ODE itself doesn't care about — any positive energy gives a perfectly valid sine wave. It was the boundary conditions that selected a discrete set. Translating back into energy via :
This is energy quantization, derived from nothing more sophisticated than "the wave has to fit between two walls." The intuition is exactly the same as for a guitar string: only certain wavelengths fit, and each allowed wavelength corresponds to a definite frequency — and through the de Broglie relation , a definite momentum and energy.
Guitar string analogy. A string fixed at both ends vibrates only at frequencies whose half-wavelength fits an integer number of times into its length: . The quantum particle in a box is the exact same equation, with the energy taking the role of the squared frequency. Quantum mechanics didn't invent discrete spectra — every musical instrument has one. The difference is that for the bead in the box, the "string" is the wave function itself.
Why E = 0 is forbidden
If you tried the ODE becomes , whose general solution is linear: . Demanding forces . Demanding then forces . So the only way to have is — no particle at all. Localizing a particle costs energy. This is zero-point energy, and it is the cleanest face of the uncertainty principle: .
Normalization and Orthogonality
The wave function still has an unknown amplitude . We fix it by demanding total probability one:
With the integral evaluates to:
which yields . So our normalized eigenstates are:
Orthogonality
Different eigenstates are orthogonal: for ,
Combined with normalization this is . A quick way to see it: use the product-to-sum identity . Both cosine integrals over vanish when , because the cosine completes whole periods on the interval.
Why orthogonality matters
Orthogonality of the is the single most useful property of the box. It means any wave function on (vanishing at the walls) can be expanded as a Fourier sine series: with . Time evolution then becomes trivial because each piece carries its own phase factor .
Interactive: Eigenstate Explorer
Move the sliders. n picks the quantum number; L stretches or shrinks the box. Watch what each change does:
- Increasing n adds nodes (interior zeros where ) and pushes the energy up like .
- Increasing L stretches the wave horizontally and lowers every energy as .
- For even , the box centre is a node — the particle is never found exactly in the middle. For odd it is an antinode (the most likely spot).
The Energy Ladder
The energies form a ladder whose rungs spread out quadratically:
| n | k_n = nπ/L | E_n (units of E₁) | Gap to previous level |
|---|---|---|---|
| 1 | π/L | 1 | — |
| 2 | 2π/L | 4 | 3 |
| 3 | 3π/L | 9 | 5 |
| 4 | 4π/L | 16 | 7 |
| 5 | 5π/L | 25 | 9 |
| n | nπ/L | n² | 2n − 1 |
Two things are worth pausing on. First, the gap grows linearly with — the higher you climb, the more energy each new rung costs. Second, therelative gap shrinks. In the limit of huge the spectrum looks effectively continuous — this is the correspondence principle: classical physics emerges smoothly from quantum mechanics at high quantum numbers.
Properties of the Eigenstates
Nodes
vanishes at for . The endpoints and are forced zeros (the walls), leaving n − 1 interior nodes. The number of nodes is the quickest fingerprint of which eigenstate you are looking at.
Parity around the centre
Define . Then . For odd only the cosine term survives — the eigenstate is symmetric about . For even only the sine survives — it is antisymmetric. This alternation is why even-n states have a node right at the centre.
Expectation values you can compute by hand
| Quantity | Value | Why |
|---|---|---|
| ⟨x⟩ | L/2 | All ψ_n are either symmetric or antisymmetric about L/2; |ψ_n|² is symmetric, so the average position is the centre. |
| ⟨p⟩ | 0 | ψ_n is real, so the momentum-density expectation vanishes — there is no net flow. |
| ⟨x²⟩ | L²(1/3 − 1/(2n²π²)) | Drops out of ∫ x² sin²(nπx/L) dx; goes to L²/3 for high n (uniform distribution). |
| ⟨p²⟩ | n²π²ℏ²/L² = 2m·E_n | Since ⟨p⟩ = 0, ⟨p²⟩ = 2m·E_n. Higher energy levels carry more momentum spread. |
Worked Example: Electron in a 1 nm Box
Numbers grounded a model. Take an electron confined to a one-nanometre box — a reasonable cartoon of a quantum dot or a single benzene-ring-size cavity.
Walk it through by hand →
Constants we will use:
- J·s
- kg
- m
- J
Step 1 — Compute the ground-state energy .
Convert to electron-volts:
Step 2 — Build the ladder. :
Step 3 — Predict a photon. A 2 → 1 transition releases eV. Plug into with :
Step 4 — Sanity check the size dependence. If we had picked nm instead, every energy would be 4× larger and the same transition would emit blue-violet light at ≈ 275 nm. This is exactly how quantum dots are engineered to fluoresce in different colours — by tuning their size.
Step 5 — Average position and momentum. Because is symmetric about , nm and . But is not zero — it gives a momentum spread kg·m/s. That spread, times , lands right at the uncertainty-principle floor .
Superposition and Time Evolution
A single eigenstate evolves only in phase: . The complex phase rotates but doesn't change. Stationary states are truly stationary — their probability density is frozen.
The interesting dynamics show up the moment you combine eigenstates with different energies. Suppose:
Square it. The cross term picks up :
The first two pieces are static. The last piece oscillates at the beat (Bohr) frequency . Because is symmetric and is antisymmetric about , the product is antisymmetric: it is positive on one half of the box and negative on the other. So as the cosine oscillates, the probability density sloshes from one side to the other.
What just happened?
One eigenstate alone is just a colour photograph — frozen. Two eigenstates together make a movie. The frame rate is set by the energy gap divided by . That is how every quantum clock works: spectroscopists measure the frequency at which a superposition oscillates and back out the energy difference between two levels to many decimal places.
Numerical Solution in Python
It is a one-line story: discretize the Hamiltonian on a grid, diagonalize the matrix, read off the spectrum. The finite-difference rule turns the operator into a tridiagonal matrix. Diagonalizing it returns approximate eigenvalues — the discrete — and discrete samples of the eigenfunctions. The boundary conditions are built in just by the choice of grid (we omit the wall points from the unknowns).
What you should see when you run it
For :
The ratios come out as 1, 4, 9, 16 to four significant figures — direct experimental confirmation of .
The Same Idea in PyTorch
Why bother rewriting in PyTorch? Three good reasons. First, the operation is GPU-friendly: as a matrix is exactly what GPUs are designed for. Second, PyTorch's works on batches, so you can solve the eigenproblem for many different potentials or many different box lengths in one call. Third, the same Hamiltonian shows up as a building block in physics-informed neural networks and neural quantum states — having the operator in PyTorch lets you wire it directly into a learning loop.
The 1/L² scaling, verified empirically
The last block of the PyTorch script computes for 16 different values of . If the analytic formula is right, this product should be the constant . And it is — to four decimal places across the entire sweep. There is no extra tuning, no parameter sharing, no model. The numerics agree with the maths because the maths is right.
Why This Toy Model Matters
1. Quantum dots — colour by size
Real semiconductor quantum dots are three-dimensional infinite-well cousins of the model we just solved. Their emission wavelength is controlled almost entirely by their physical size: . Grow a CdSe dot at 2 nm and it glows blue; grow it at 6 nm and it glows red. Same chemistry, different box.
2. Quantum wells in lasers
Inside a semiconductor laser is a thin layer of low-bandgap material sandwiched between higher-bandgap layers — a near-perfect one-dimensional box for charge carriers. The quantized energy levels we just derived determine the laser's emission frequency.
3. Conjugated molecules and the free-electron model
In molecules like β-carotene, π-electrons are roughly free along the carbon backbone. Treating that backbone as an infinite well predicts the absorption colour of the molecule — it is why carrots are orange and tomatoes are red.
4. Numerical PDE solvers and ML for physics
Discretizing a Hamiltonian and diagonalizing it is the simplest case of the technique behind density-functional theory, neural quantum states, and physics-informed neural networks. The matrix we just diagonalized is exactly the building block those methods scale up to.
ML connection: variational quantum Monte Carlo
Neural Quantum States parameterize with a neural network and minimize the variational energy . For the infinite well, that loss has a global minimum at exactly , and the best-fit network output is — up to a sign and a normalization —. The toy problem is the unit test for the whole framework.
Test Your Understanding
Summary
| Concept | Result | Where it comes from |
|---|---|---|
| Eigenfunctions | ψ_n(x) = √(2/L) sin(nπx/L) | Sines with B = 0 (left wall) and kL = nπ (right wall) |
| Allowed k | k_n = nπ/L, n = 1, 2, … | Boundary condition sin(kL) = 0 |
| Energies | E_n = n²π²ℏ²/(2mL²) | k² = 2mE/ℏ² applied to k_n |
| Ground state | E_1 > 0 (zero-point energy) | ψ ≡ 0 is the only E = 0 solution — incompatible with a particle existing |
| Nodes | n − 1 interior zeros | sin(nπx/L) = 0 at x = kL/n, k = 1, …, n − 1 |
| Orthonormality | ∫₀ᴸ ψ_m ψ_n dx = δ_{mn} | Hermitian H + Fourier-sine product-to-sum identity |
| Time evolution | Ψ_n(x,t) = ψ_n(x) e^{−iE_n t/ℏ} | Stationary states only acquire a phase |
| Superposition dynamics | Oscillation at ω_{mn} = (E_m − E_n)/ℏ | Cross-term in |c_1ψ_1 + c_2ψ_2|² beats at the energy difference |
Key Takeaways
- Quantization is geometric. The discreteness of comes from a boundary condition, not from any quantum-mechanical postulate beyond Schrödinger's equation itself.
- Localizing costs energy. The ground state has strictly positive energy. There is no way to put a particle in a box of finite size with zero kinetic energy.
- Eigenstates are stationary; only superpositions move. The clock rate of the motion is set by the energy gap.
- The orthonormal basis ψ_n is a Fourier sine basis. Any state on vanishing at the walls expands into them, and time evolution becomes phase-rotation of the expansion coefficients.
- Numerics confirm everything. A 200-point finite-difference Hamiltonian recovers the analytic spectrum to four decimals, in both NumPy and PyTorch, and a single batched torch.linalg.eigh sweep proves directly.
Coming Next: In the next section we replace the rectangular potential with a parabola and meet the quantum harmonic oscillator — the second pillar of every quantum textbook. There the eigenfunctions are Hermite polynomials times a Gaussian, the energies become evenly spaced , and we discover the famous zero-point energy of empty space.