Skip to main content
Back to module
Computational & Modern Physics · Modern Physics

Quantum basics

Reading45mLesson 2 of 3 in this module

Explain wavefunctions, probability and quantized energy levels using the particle in a box, and compute them in Python.

Why it matters

Quantum mechanics explains why atoms are stable, why materials conduct or insulate, why LEDs and quantum dots have the colours they do, and how lasers, transistors and MRI work. You do not need the full theory to start computing with it. The particle in a box is the standard first model: simple enough to solve by hand and rich enough to show every key idea.

The core ideas

  • Wavefunction. A particle is described by a wavefunction psi(x). It is not a physical wave you can see; it is a tool for predictions.
  • Probability. |psi(x)|^2 is a probability density. The chance of finding the particle between a and b is the integral of |psi|^2 from a to b. The total over all space must be 1 (the wavefunction is normalized).
  • Schrödinger equation. For a time-independent problem in one dimension:
-(hbar^2 / 2m) * psi''(x) + V(x) * psi(x) = E * psi(x)

Only some values of E give wavefunctions that obey the boundary conditions. That is why energy is quantized.

The particle in a box

Put a particle of mass m in a region 0 < x < L with zero potential inside and infinitely high walls outside. The wavefunction must be zero at both walls. Sine waves that fit a whole number of half-wavelengths into the box are the solutions:

psi_n(x) = sqrt(2/L) * sin(n * pi * x / L),   n = 1, 2, 3, ...
E_n = n^2 * h^2 / (8 * m * L^2)

What this tells you:

  • Energy grows as n^2: levels 1, 4, 9, 16 times the ground state.
  • The lowest energy is not zero. Confining a particle always costs energy (zero-point energy), a consequence of the uncertainty principle.
  • State n has n - 1 nodes inside the box where the particle is never found.
  • A smaller box or a lighter particle spreads the levels further apart (1/(m L^2)).

Worked example: an electron in a 1 nm box

h   = 6.62607015e-34 J s
m_e = 9.1093837e-31 kg
L   = 1.0e-9 m

E_1 = h^2 / (8 m L^2) = 4.390e-67 / 7.288e-48 = 6.025e-20 J
    = 6.025e-20 / 1.602e-19 = 0.376 eV

So E_2 = 4 * 0.376 = 1.504 eV and E_3 = 3.384 eV. If the electron drops from n = 3 to n = 2, it releases 5 * 0.376 = 1.880 eV, and the photon wavelength is

lambda = h c / dE = 1239.84 eV nm / 1.880 eV = 659 nm   (red light)

This is roughly how colour works in dye molecules and quantum dots: the size of the region the electron is confined to sets the colour. Real atoms have a different potential, so their levels follow other formulas. For hydrogen, E_n = -13.6 eV / n^2, and the 3 to 2 transition gives 656 nm, the red H-alpha line.

Worked example: probabilities

For the ground state, what is the chance of finding the particle in the middle half of the box?

P = integral from L/4 to 3L/4 of (2/L) sin^2(pi x / L) dx = 1/2 + 1/pi = 0.818

A classical particle bouncing at constant speed would spend exactly 50% of its time there. The quantum ground state piles probability up in the middle. Many such integrals have no neat closed form, so you compute them numerically:

import math

def psi(n, x, L):
    return math.sqrt(2 / L) * math.sin(n * math.pi * x / L)

def prob(n, L, a, b, steps=10_000):
    dx = (b - a) / steps
    return sum(psi(n, a + (i + 0.5) * dx, L) ** 2 for i in range(steps)) * dx

print(prob(1, 1.0, 0.25, 0.75))   # 0.8183...

This is the midpoint rule: split the interval, evaluate at each centre, add up.

Common mistakes

  • Treating psi as the probability. The probability density is |psi|^2, and probabilities come from integrating it.
  • Starting n at 0. n = 0 gives psi = 0 everywhere, which is no particle at all.
  • Mixing h and hbar. The box formula above uses h. With hbar = h / (2 pi) it reads n^2 pi^2 hbar^2 / (2 m L^2); both give the same number.
  • Forgetting the eV conversion (1 eV = 1.602176634e-19 J) and quoting joules as if they were electronvolts.

Recap

  • |psi|^2 is a probability density; normalized wavefunctions integrate to 1.
  • Boundary conditions quantize energy: E_n = n^2 h^2 / (8 m L^2) in a box.
  • Transitions emit photons with lambda = h c / dE.
  • Numerical integration (midpoint rule) handles the probabilities you can't do by hand.

Try it

Open the Do tab to compute box energy levels, a transition wavelength and a probability by numerical integration.

Also in this lesson: