| name | quantum-mechanics |
| description | Quantum mechanics fundamentals including wave functions, operators, Schrödinger equation, superposition, entanglement, and quantum measurement for physics applications. |
| category | physics |
| tags | ["physics","quantum-mechanics","wave-functions","schrödinger","operators","superposition","entanglement","quantum-states"] |
| difficulty | advanced |
| author | neuralblitz |
Quantum Mechanics
What I do
I provide comprehensive expertise in quantum mechanics, the fundamental theory describing nature at the smallest scales of energy levels of atoms and subatomic particles. I enable you to work with wave functions, quantum operators, the Schrödinger equation, superposition, entanglement, and measurement postulates. My knowledge spans from foundational principles to advanced topics like perturbation theory and quantum dynamics essential for quantum computing, atomic physics, chemistry, and materials science.
When to use me
Use quantum mechanics when you need to: compute energy levels of atomic systems, calculate transition probabilities and selection rules, analyze quantum tunneling phenomena, understand atomic and molecular spectra, model quantum harmonic oscillators, analyze spin systems and magnetic properties, simulate quantum dynamics and time evolution, or develop quantum computing algorithms.
Core Concepts
- Wave Functions and Probability Amplitudes: Mathematical descriptions of quantum states encoding all observable information.
- The Schrödinger Equation: Fundamental dynamical equation governing quantum system evolution in time.
- Quantum Operators and Observables: Linear operators corresponding to measurable quantities with discrete or continuous spectra.
- Superposition Principle: Linear combination of quantum states forming valid states, leading to interference phenomena.
- Heisenberg Uncertainty Principle: Fundamental limits on simultaneous knowledge of conjugate variables like position and momentum.
- Quantum Entanglement: Non-classical correlations between quantum systems that defy classical intuition.
- Quantum Measurement: Wave function collapse and the probabilistic nature of quantum predictions.
- Angular Momentum and Spin: Intrinsic and orbital quantum properties with associated operators and commutation relations.
- Perturbation Theory: Approximate methods for solving quantum systems close to solvable cases.
- Identical Particles and Symmetry: Quantum statistics (bosons vs fermions) and their implications for many-body systems.
Code Examples
Wave Functions and Probability
import numpy as np
from scipy import integrate
def gaussian_wavepacket(x, x0, sigma, p0):
"""
Create a Gaussian wave packet.
ψ(x) = (1/(2πσ²)^(1/4)) * exp(-(x-x0)²/(4σ²)) * exp(ip0x/ℏ)
"""
norm = (1 / (2 * np.pi * sigma**2))**0.25
envelope = np.exp(-(x - x0)**2 / (4 * sigma**2))
phase = np.exp(1j * p0 * x)
return norm * envelope * phase
def probability_density(psi):
"""Compute probability density |ψ(x)|²."""
return np.abs(psi)**2
def normalize_wavefunction(psi, x):
"""Normalize wave function to have unit probability."""
norm_squared, _ = integrate.quad(lambda x: np.abs(psi(x))**2, x[0], x[-1])
norm = np.sqrt(norm_squared)
return lambda x: psi(x) / norm, norm
def particle_in_box_wavefunction(n, L, x):
"""
ψ_n(x) = sqrt(2/L) * sin(nπx/L)
Energy: E_n = n²π²ℏ²/(2mL²)
"""
return np.sqrt(2/L) * np.sin(n * np.pi * x / L)
x = np.linspace(0, 10, )
L =
psi1 = particle_in_box_wavefunction(, L, x)
psi2 = particle_in_box_wavefunction(, L, x)
prob_left = integrate.trapz(np.(psi1[:])**, x[:])
()
()
x0, sigma, p0 = , ,
psi_gauss = gaussian_wavepacket(x, x0, sigma, p0)
psi_norm, norm = normalize_wavefunction( x: gaussian_wavepacket(x, x0, sigma, p0), x)
()
()
()
Schrödinger Equation Solver
import numpy as np
from scipy.linalg import eigh_tridiagonal
from scipy.integrate import solve_ivp
def finite_difference_schrodinger(V, x, m=1, hbar=1):
"""
Solve 1D Schrödinger equation using finite differences.
-ℏ²/2m ψ'' + Vψ = Eψ
Returns: eigenvalues (energies) and eigenvectors (wavefunctions)
"""
n = len(x)
dx = x[1] - x[0]
h2 = hbar**2 / (2 * m * dx**2)
diag = np.full(n, 2 * h2 + V(x))
off_diag = np.full(n - 1, -h2)
diag[0] = h2 + V(x[0])
diag[-1] = h2 + V(x[-1])
eigenvalues, eigenvectors = eigh_tridiagonal(diag, off_diag)
return eigenvalues, eigenvectors.T
L = 10
x = np.linspace(0, L, 200)
V_infinite = np.zeros_like(x)
energies_inf, psi_inf = finite_difference_schrodinger(lambda x: 0, x)
print("Infinite square well energies (units of ℏ²/2m):")
for i, E in enumerate(energies_inf[:5]):
exact = (i + 1)**2 * np.pi** / ( * L**)
()
():
V = np.zeros_like(x)
i, xi (x):
xi < L/ xi > *L/:
V[i] = V0
V
V_finite = finite_well(x)
energies_fin, psi_fin = finite_difference_schrodinger( x: V_finite, x)
()
i, E (energies_fin[:]):
()
():
dx = x[] - x[]
psi = psi.reshape(-, )
laplacian = (np.roll(psi, -, axis=) - *psi + np.roll(psi, , axis=)) / dx**
V = np.diag(V_func(x))
dpsi = (-hbar** / (*m)) * laplacian + V @ psi
dpsi = dpsi.flatten()
- * dpsi / hbar
x0, sigma = L/,
psi0 = gaussian_wavepacket(x, x0, sigma, )
()
Quantum Operators and Expectation Values
import numpy as np
from scipy import integrate
def expectation_value(psi, operator_func, x):
"""
Compute expectation value <ψ|Ô|ψ>.
For position: <x> = ∫ψ* x ψ dx
For momentum: <p> = ∫ψ* (-iℏ d/dx) ψ dx
"""
psi_conj = np.conj(psi)
op_psi = operator_func(psi, x)
integrand = psi_conj * op_psi
expectation, _ = integrate.trapz(integrand, x)
return expectation
def position_operator(psi, x):
"""Position operator: xψ."""
return x * psi
def momentum_operator(psi, x, hbar=1):
"""Momentum operator: -iℏ d/dx."""
dpsi_dx = np.gradient(psi, x)
return -1j * hbar * dpsi_dx
def kinetic_energy_operator(psi, x, m=1, hbar=1):
"""Kinetic energy operator: -ℏ²/2m d²/dx²."""
d2psi_dx2 = np.gradient(np.gradient(psi, x), x)
return -hbar**2 / (2*m) * d2psi_dx2
def harmonic_oscillator_analytic(n, x, m=1, hbar=1, omega=1):
"""
Hermite polynomial solutions.
E_n = ℏω(n + 1/2)
"""
from scipy.special import hermite
xi = np.sqrt(m * omega / hbar) * x
Hn = hermite(n)(xi)
norm = / np.sqrt(**n * np.math.factorial(n)) * (m * omega / (np.pi * hbar))**
norm * Hn * np.exp(-xi** / )
x = np.linspace(-, , )
psi0 = harmonic_oscillator_analytic(, x)
<x> = expectation_value(psi0, position_operator, x)
<p> = expectation_value(psi0, momentum_operator, x)
<T> = expectation_value(psi0, kinetic_energy_operator, x)
()
()
()
()
():
x2 = expectation_value(psi, position_operator, x)**
psi2 = expectation_value(psi, psi, x: x** * psi, x)
np.sqrt(np.(psi2 - x2))
():
p2 = expectation_value(psi, momentum_operator, x)**
p2_sq = expectation_value(psi, psi, x: momentum_operator(psi, x, hbar)**, x)
np.sqrt(np.(p2_sq - p2**))
delta_x = uncertainty_position(psi0, x)
delta_p = uncertainty_momentum(psi0, x)
()
()
()
()
Quantum Tunneling
import numpy as np
def tunneling_coefficient(E, V0, m=1, hbar=1, a=1):
"""
Calculate tunneling probability through a rectangular barrier.
For E < V0 (under-barrier transmission).
Transmission coefficient T ≈ exp(-2κa)
where κ = sqrt(2m(V0-E))/ℏ
"""
if E > V0:
k = np.sqrt(2 * m * E) / hbar
k1 = np.sqrt(2 * m * (V0 - E)) / hbar
T = 1 / (1 + (V0**2 * np.sinh(k1*a)**2) / (4 * E * (V0 - E)))
else:
kappa = np.sqrt(2 * m * (V0 - E)) / hbar
T = np.exp(-2 * kappa * a)
return T
m_alpha = 3727
V0 = 25
E_alpha = 5
hbar_c = 197.3
hbar = hbar_c
a = 5
T = tunneling_coefficient(E_alpha, V0, m_alpha, hbar, a)
print(f"Alpha decay tunneling:")
print(f" Barrier height: {V0} MeV")
print(f" Alpha energy: {E_alpha} MeV")
()
()
energies = np.linspace(, , )
transmissions = [tunneling_coefficient(E, V0, m_alpha, hbar, a) E energies]
()
()
()
()
():
kappa = np.sqrt( * m * V0) / hbar
k = np.sqrt( * m * E) / hbar
resonance_condition = np.sin(k * b / )**
T_resonant = / ( + (V0** * kappa** * np.sin(k*b)**) / ( * E * (V0 - E) * k**))
T_resonant
()
n (, ):
E_res = (n * np.pi * hbar / b)** / ( * m)
()
Spin Systems and Entanglement
import numpy as np
def pauli_matrices():
"""Return Pauli matrices and identity."""
sigma_x = np.array([[0, 1], [1, 0]], dtype=complex)
sigma_y = np.array([[0, -1j], [1j, 0]], dtype=complex)
sigma_z = np.array([[1, 0], [0, -1]], dtype=complex)
I = np.array([[1, 0], [0, 1]], dtype=complex)
return sigma_x, sigma_y, sigma_z, I
def spin_state(direction, theta=0, phi=0):
"""
Create spin-1/2 state in arbitrary direction.
|θ,φ⟩ = cos(θ/2)|↑⟩ + e^(iφ)sin(θ/2)|↓⟩
"""
sigma_x, sigma_y, sigma_z, I = pauli_matrices()
psi = np.array([np.cos(theta/2), np.exp(1j * phi) * np.sin(theta/2)])
return psi / np.linalg.norm(psi)
def expectation_spin(psi, direction):
"""Compute expectation value of spin in given direction."""
sigma_x, sigma_y, sigma_z, I = pauli_matrices()
if direction == 'x':
sigma = sigma_x
elif direction == 'y':
sigma = sigma_y
:
sigma = sigma_z
np.real(np.conj(psi) @ sigma @ psi)
():
which == :
np.array([, , , ]) / np.sqrt()
which == :
np.array([, , , -]) / np.sqrt()
which == :
np.array([, , , ]) / np.sqrt()
:
np.array([, , -, ]) / np.sqrt()
():
rho = rho.reshape(, , , )
subsystem == :
reduced = np.trace(rho, axis1=, axis2=)
:
reduced = np.trace(rho, axis1=, axis2=)
reduced
():
eigenvalues = np.linalg.eigvalsh(rho)
eigenvalues = eigenvalues[eigenvalues > ]
-np.(eigenvalues * np.log2(eigenvalues))
psi_bell = bell_state()
rho = np.outer(psi_bell, np.conj(psi_bell))
rho_A = partial_trace(rho, )
rho_B = partial_trace(rho, )
()
()
()
():
bell = bell_state(which)
rho_bell = np.outer(bell, np.conj(bell))
I = np.eye(, dtype=)
rho = f * rho_bell + ( - f) / * I
rho / np.trace(rho)
()
f [, , , ]:
rho_w = werner_state(f)
rho_red = partial_trace(rho_w, )
S = entanglement_entropy(rho_red)
()
Best Practices
- Always normalize wave functions numerically or analytically to ensure proper probability interpretation.
- Use consistent units throughout calculations; common choices include atomic units or natural units with ℏ=c=1.
- For numerical solutions, choose grid spacing small enough to resolve features but coarse enough for efficiency.
- When computing expectation values, verify operator Hermiticity and boundary conditions.
- For time-dependent problems, use unitary evolution methods (split-operator, Crank-Nicolson) to preserve probability.
- Be aware of the sign ambiguity in wave functions; physical observables are unaffected but interference depends on relative phases.
- In perturbation theory, verify convergence by computing higher-order corrections.
- For identical particles, always use properly symmetrized/antisymmetrized wave functions.
- When analyzing entanglement, use multiple measures (entropy, negativity) for complete characterization.
- Validate numerical solutions against known analytical results when available.