Calculus is the language of change. In quantum mechanics we differentiate wavefunctions to build momentum and energy operators, and we integrate them to compute probabilities and expectation values. This page collects the essentials, with a picture for the two ideas that matter most: the derivative as a slope, and the integral as an area.
Differentiation¶
The derivative as a slope¶
The derivative of at a point is the slope of the line tangent to the curve there. We build it from the slope of a secant line through two nearby points and then let those points merge:
As the spacing shrinks, the secant line pivots into the tangent line. The plot below shows this for at : three secant lines with shrinking close in on the true tangent of slope 2.
Source
import numpy as np
import matplotlib.pyplot as plt
f = lambda x: x**2
x0 = 1.0
x = np.linspace(-0.5, 2.5, 400)
fig, ax = plt.subplots(figsize=(6.5, 5))
ax.plot(x, f(x), 'k', lw=2, label=r'$f(x)=x^2$')
# Secant lines for shrinking h
for h, color in zip([1.0, 0.5, 0.2], ['#d1495b', '#edae49', '#66a182']):
slope = (f(x0 + h) - f(x0)) / h
sec = f(x0) + slope * (x - x0)
ax.plot(x, sec, '--', color=color, lw=1.5, label=f'secant, h={h} (slope {slope:.1f})')
ax.plot([x0, x0 + h], [f(x0), f(x0 + h)], 'o', color=color, ms=5)
# True tangent (slope 2)
ax.plot(x, f(x0) + 2 * (x - x0), color='#2e4057', lw=2, label='tangent (slope 2)')
ax.plot(x0, f(x0), 'ko', ms=6)
ax.set_xlim(-0.5, 2.5)
ax.set_ylim(-1, 6)
ax.set_xlabel('x')
ax.set_ylabel('f(x)')
ax.legend(fontsize=8, loc='upper left')
ax.set_title('Fig.1 Secant lines converging to the tangent as h shrinks')
plt.tight_layout()
plt.show()
The derivative is also the instantaneous rate of change: if is position, is velocity; if is concentration, is reaction rate. A function is differentiable only where it is smooth, so no corners, jumps, or vertical tangents.
Rules of differentiation¶
| Rule | Equation |
|---|---|
| Constant multiple | |
| Sum and difference | |
| Product | |
| Quotient | |
| Power | |
| Chain | |
| Linear approximation |
The chain rule is the one you will use most
Almost every wavefunction is a composition: , , . Each needs the chain rule. For , take the outer derivative times the inner derivative , giving .
Table of common derivatives¶
| Function | Derivative | Function | Derivative |
|---|---|---|---|
| 0 | |||
A few limits underlie these results: , , and the definition , which is exactly what makes its own derivative.
Integration¶
The integral as accumulated area¶
A definite integral measures the net area between a curve and the axis. We approximate that area with a Riemann sum of rectangles and let :
The plot shows the rectangles filling the area under on as grows from coarse to fine. The exact area is .
Source
import numpy as np
import matplotlib.pyplot as plt
f = lambda x: x**2
a, b = 0, 2
xs = np.linspace(a, b, 400)
fig, axes = plt.subplots(1, 3, figsize=(11, 3.6), sharey=True)
for ax, n in zip(axes, [4, 8, 32]):
edges = np.linspace(a, b, n + 1)
mids = 0.5 * (edges[:-1] + edges[1:]) # midpoint rule
dx = (b - a) / n
approx = np.sum(f(mids) * dx)
ax.bar(mids, f(mids), width=dx, align='center',
color='#66a182', edgecolor='white', alpha=0.7)
ax.plot(xs, f(xs), 'k', lw=2)
ax.set_title(f'n = {n}, sum = {approx:.3f}', fontsize=10)
ax.set_xlabel('x')
axes[0].set_ylabel('f(x)')
plt.suptitle('Fig.2 Riemann sums approaching the exact area 8/3 = 2.667 as n grows', y=1.04)
plt.tight_layout()
plt.show()
We can watch that convergence numerically:
import numpy as np
f = lambda x: x**2
a, b = 0.0, 2.0
for n in [4, 16, 64, 256, 1024]:
x = np.linspace(a, b, n + 1)
mids = 0.5 * (x[:-1] + x[1:])
approx = np.sum(f(mids) * (b - a) / n)
print(f"n = {n:5d} Riemann sum = {approx:.5f}")
exact = 8 / 3
print(f"\nexact value = {exact:.5f}")n = 4 Riemann sum = 2.62500
n = 16 Riemann sum = 2.66406
n = 64 Riemann sum = 2.66650
n = 256 Riemann sum = 2.66666
n = 1024 Riemann sum = 2.66667
exact value = 2.66667
Antiderivatives and the fundamental theorem¶
An antiderivative of satisfies . Because the derivative of a constant is zero, antiderivatives come as a family . The fundamental theorem of calculus ties the two halves of the subject together:
This is why we rarely compute Riemann sums by hand: finding an antiderivative turns an infinite sum into a single subtraction.
Table of indefinite integrals¶
| Function | Antiderivative | Function | Antiderivative |
|---|---|---|---|
Useful properties: reversing the limits flips the sign, , and integrals are linear, . For symmetric limits, an even function gives while an odd function gives , a shortcut that kills many quantum-mechanical integrals on sight.
Techniques of integration¶
Integration by parts is the reverse of the product rule, and it is the standard tool for integrals like or that appear constantly in expectation-value calculations.
For products of sines and cosines, the power-reduction and product-to-sum identities do the work:
These are exactly the integrals that enforce orthogonality of particle-in-a-box wavefunctions.
Problems¶
Problem 1: Differentiate a Gaussian¶
Differentiate with respect to .
Solution
Problem 2: Product and chain together¶
Differentiate .
Solution
Product rule, and the chain rule on :
Problem 3: A normalization integral¶
Evaluate .
Solution
Use with :
The sine term vanishes at both limits. This is the integral behind the particle-in-a-box normalization constant .
Problem 4: Integration by parts¶
Evaluate .
Solution
Let , , so and :
Problem 5: Symmetry shortcut¶
Without computing an antiderivative, evaluate .
Solution
The integrand is odd: replacing flips its sign. The integral over symmetric limits is therefore 0.
Problem 6: Verify a Riemann sum numerically¶
Modify the Riemann-sum code above to estimate and compare with the exact value 2.
Problem 7: Chain rule on a plane wave¶
Differentiate with respect to , and again to find .
Problem 8: An expectation-value integral¶
Evaluate using integration by parts twice.