Skip to content
Quantum Physics

quantum-physics-ai999x

Special relativity, photons and matter waves, the hydrogen atom, quantum wells and tunnelling, spin and qubits, quantum gates, nuclear and particle physics and statistical physics.

75capabilities
11topics
75formulas typeset
8worked examples below
1.0.0version
About this model

What Quantum Physics does

Quantum Physics (quantum-physics-ai999x) is an offline Python package for quantum physics. It covers special relativity, photons and matter waves, the hydrogen atom, quantum wells and tunnelling, spin and qubits, quantum gates, nuclear and particle physics and statistical physics.

It has 75 capabilities — 75 computational procedures — in 11 topics, the largest being Statistical physics, Special relativity, Quantum wells, Spin and qubits, Hydrogen atom and Photons and matter waves. Ask a question in words with ask(), or call a capability by name with typed inputs with solve(). Every answer carries its value and unit, the steps that produced it and the formula in LaTeX.

When a question is not determined — a value is missing, an input is out of range, or the request is outside the package — it says so and names what it needs, instead of guessing. It runs on an ordinary CPU without a network connection (Python >=3.10), and the same question always gets the same answer.

Install

pip install quantum-physics-ai999x
hf download AI999X/quantum-physics-ai999x --local-dir quantum-physics-ai999x

What it covers

Try it

Worked examples

Each question below was put to quantum-physics-ai999x and the answer shown is the one it returned, with the steps it took.

Special relativitym.ask(…)

Lorentz factor: v = 0.8 c

gamma = 1.666666667
beta = 0.8
gamma_minus_1 = 0.6666666667
Show the steps
  1. Lorentz factor
    \gamma = \frac{1}{\sqrt{1 - v^2/c^2}}
    with v = 239833966.4 m/s
    → gamma = 1.666666667, beta = 0.8, gamma_minus_1 = 0.6666666667
Capability: Lorentz factor
Hydrogen atomm.ask(…)

Hydrogen transition: Z = 1, n_upper = 3, n_lower = 2

E_photon_eV = 1.8896796 eV
lam = 6.561122764e-07 m
lambda_nm = 656.1122764 nm
f = 4.569224945e+14 Hz
series = Balmer
Show the steps
  1. Photon from a hydrogen-like transition (Rydberg formula)
    \frac{1}{\lambda} = R_\infty Z^2\left(\frac{1}{n_\ell^2} - \frac{1}{n_u^2}\right)
    with Z = 1, n_upper = 3, n_lower = 2
    → E_photon_eV = 1.8896796 eV, lam = 6.561122764e-07 m, lambda_nm = 656.1122764 nm, f = 4.569224945e+14 Hz, series = Balmer nm
Photons and matter wavesm.ask(…)

Photoelectric effect: lambda = 250 nm, W = 4.3 eV

E_photon_eV = 4.959367937 eV
K_max_eV = 0.6593679373 eV
V_stop = 0.6593679373 V
lambda_threshold = 2.883353452e-07 m
lambda_threshold_nm = 288.3353452 nm
f_threshold = 1.039735374e+15 Hz
Show the steps
  1. Photoelectric effect
    K_{max} = \frac{hc}{\lambda} - W = e V_{stop}
    with lam = 250 nm, W = 4.3 eV
    → E_photon_eV = 4.959367937 eV, K_max_eV = 0.6593679373 eV, V_stop = 0.6593679373 V, lambda_threshold = 2.883353452e-07 m, lambda_threshold_nm = 288.3353452 nm, f_threshold = 1.039735374e+15 Hz
Quantum gatesm.solve(…)
m.solve("two_qubit_circuit", start="00", gates="H0 CNOT01")
p00 = 0.5
p01 = 0
p10 = 0
p11 = 0.5
concurrence = 1
p_q0_is_1 = 0.5
Show the steps
  1. Two-qubit circuit: probabilities and entanglement
    |\Phi^+\rangle = \mathrm{CNOT}_{01}(H\otimes I)|00\rangle = \tfrac{1}{\sqrt2}(|00\rangle + |11\rangle)
    with start = 00, gates = H0 CNOT01
    → p00 = 0.5, p01 = 0, p10 = 0, p11 = 0.5, concurrence = 1, p_q0_is_1 = 0.5, p_q1_is_1 = 0.5
Quantum wellsm.ask(…)

Barrier transmission: E = 1 eV, V0 = 2 eV, a = 0.5 nm, m = 9.109e-31 kg

T = 0.02354963067
R = 0.9764503693
kappa_a = 2.56152966
regime = tunnelling (E < V0)
Show the steps
  1. Transmission through a rectangular barrier
    T = \left[1 + \frac{V_0^2\sinh^2(\kappa a)}{4E(V_0 - E)}\right]^{-1},\quad \kappa = \frac{\sqrt{2m(V_0 - E)}}{\hbar}
    with E = 1 eV, V0 = 2 eV, a = 0.5 nm, m = 9.109e-31 kg
    → T = 0.02354963067, R = 0.9764503693, kappa_a = 2.56152966, regime = tunnelling (E < V0)
Angular momentumm.ask(…)

Clebsch-Gordan coefficient: j1 = 0.5, m1 = 0.5, j2 = 0.5, m2 = -0.5, J = 1, M = 0

cg = 0.7071067812
cg_squared = 0.5
cg_squared_exact = 1/2
Show the steps
  1. Clebsch-Gordan coefficient
    \langle j_1 m_1; j_2 m_2 | J M\rangle
    with j1 = 0.5, m1 = 0.5, j2 = 0.5, m2 = -0.5, J = 1, M = 0
    → cg = 0.7071067812, cg_squared = 0.5, cg_squared_exact = 1/2
Nuclear and particle physicsm.ask(…)

Semi-empirical mass formula: Z = 26, A = 56

B_MeV = 495.3836999 MeV
B_per_A_MeV = 8.846137499 MeV
mass_u = 55.93158207
volume_MeV = 882 MeV
surface_MeV = 260.5425666 MeV
coulomb_MeV = 120.7962953 MeV
Show the steps
  1. Semi-empirical mass formula (liquid-drop binding energy)
    B = a_V A - a_S A^{2/3} - a_C\frac{Z(Z-1)}{A^{1/3}} - a_A\frac{(A-2Z)^2}{A} + \delta(A,Z)
    with Z = 26, A = 56
    → B_MeV = 495.3836999 MeV, B_per_A_MeV = 8.846137499 MeV, mass_u = 55.93158207 MeV, volume_MeV = 882 MeV, surface_MeV = 260.5425666 MeV, coulomb_MeV = 120.7962953 MeV, asymmetry_MeV = 6.771428571 MeV, pairing_MeV = 1.493990342 MeV, Z_stable = 25.27970457 MeV
Nuclear physicsm.ask(…)

Coulomb barrier: Z1 = 1, A1 = 1, Z2 = 1, A2 = 1, r0 = 1 fm

V_MeV = 0.7199822734 MeV
R = 2e-15 m
R_fm = 2 fm
Show the steps
  1. Coulomb barrier between two nuclei
    V_C = \frac{Z_1 Z_2 e^2}{4\pi\varepsilon_0\,r_0\left(A_1^{1/3} + A_2^{1/3}\right)}
    with Z1 = 1, A1 = 1, Z2 = 1, A2 = 1, r0 = 1 fm
    → V_MeV = 0.7199822734 MeV, R = 2e-15 m, R_fm = 2 fm
Use it

From Python or the command line

Every snippet was run as shown; the output under it is what it printed.

import quantum_physics_ai999x as m

a = m.ask("Lorentz factor: v = 0.8 c")
print(a.outcome)
print(a.values)
for step in a.steps:
    print(step["name"])
Output
SOLVED
{'gamma': 1.66666666667, 'beta': 0.8, 'gamma_minus_1': 0.666666666667}
Lorentz factor
Figures

Computed, not drawn by hand

Every value in these figures was computed by the package, each point a run of solve(); in a notebook, plot() and plot_relation() draw a capability's curves the same way.

Hydrogen energy levels and spectral lines

\frac{1}{\lambda} = R_\infty Z^2\left(\frac{1}{n_\ell^2} - \frac{1}{n_u^2}\right)
Hydrogen energy levels and spectral linesEnergy levels of hydrogen, E_n from the package for n = 1 … 6 (E₁ = -13.6057 eV), with the photon wavelengths of Lyman and Balmer transitions it computes: 2→1: 121.502 nm, 3→1: 102.518 nm, 3→2: 656.112 nm, 4→2: 486.009 nm, 5→2: 433.937 nm, 6→2: 410.07 nm.-10-50n = 1n = 2n = 3n = 4, 5, 6122103656486434410LymanBalmerE — energy [eV]
Energy levels of hydrogen, E_n from the package for n = 1 … 6 (E₁ = -13.6057 eV), with the photon wavelengths of Lyman and Balmer transitions it computes: 2→1: 121.502 nm, 3→1: 102.518 nm, 3→2: 656.112 nm, 4→2: 486.009 nm, 5→2: 433.937 nm, 6→2: 410.07 nm.

The hydrogen line spectrum

\frac{1}{\lambda} = R_\infty Z^2\left(\frac{1}{n_\ell^2} - \frac{1}{n_u^2}\right)
The hydrogen line spectrumThe hydrogen emission spectrum: the first six lines of the Lyman, Balmer and Paschen series, each wavelength and photon energy computed by the package (Lyman 121.502–93.0252 nm; Balmer 656.112–388.807 nm; Paschen 1874.61–922.658 nm); the dashed lines bound the visible range 380–750 nm, where only Balmer lines fall.10010000510visibleLymanBalmerPaschenλ — wavelength [nm] (log scale)photon energy [eV]
The hydrogen emission spectrum: the first six lines of the Lyman, Balmer and Paschen series, each wavelength and photon energy computed by the package (Lyman 121.502–93.0252 nm; Balmer 656.112–388.807 nm; Paschen 1874.61–922.658 nm); the dashed lines bound the visible range 380–750 nm, where only Balmer lines fall.

Particle in a box: levels and probability densities

P = \int_{x_1}^{x_2} \frac{2}{L}\sin^2\frac{n\pi x}{L}\,dx
Particle in a box: levels and probability densitiesAn electron in a 1 nm infinite square well: the three lowest energy levels the package gives (E1 = 0.37603 eV, E2 = 1.50412 eV, E3 = 3.38427 eV), each with its probability density drawn on the level (the probability of each of 60 intervals of 0.0166667 nm divided by the interval, 0.4 eV per 1/nm); state n has n humps and n − 1 nodes.00.5101234E1 = 0.37603 eVE2 = 1.50412 eVE3 = 3.38427 eVn = 1n = 2n = 3x — position in the box [nm]E — energy [eV]
An electron in a 1 nm infinite square well: the three lowest energy levels the package gives (E1 = 0.37603 eV, E2 = 1.50412 eV, E3 = 3.38427 eV), each with its probability density drawn on the level (the probability of each of 60 intervals of 0.0166667 nm divided by the interval, 0.4 eV per 1/nm); state n has n humps and n − 1 nodes.

Two-qubit circuits: outcome probabilities and entanglement

|\Phi^+\rangle = \mathrm{CNOT}_{01}(H\otimes I)|00\rangle = \tfrac{1}{\sqrt2}(|00\rangle + |11\rangle)
Two-qubit circuitsTwo-qubit circuits started in |00⟩ — rows, top to bottom: X0; H0; H0 H1; H0 CNOT01; X1 H0 CNOT01; H0 CNOT01 H0 — with the probability of each measurement outcome and the concurrence (1 = maximally entangled) the package computes; H0 CNOT01 makes the Bell state, P(00) = P(11) = 0.5 with concurrence 1.00.50.250.500.25P(00)000.2500.50.25P(01)10.50.2500.50.25P(10)000.250.500.25P(11)000111entangled
Two-qubit circuits started in |00⟩ — rows, top to bottom: X0; H0; H0 H1; H0 CNOT01; X1 H0 CNOT01; H0 CNOT01 H0 — with the probability of each measurement outcome and the concurrence (1 = maximally entangled) the package computes; H0 CNOT01 makes the Bell state, P(00) = P(11) = 0.5 with concurrence 1.

Blackbody spectra and their peaks

B_\lambda(T) = \frac{2hc^2}{\lambda^5}\,\frac{1}{e^{hc/(\lambda k_B T)} - 1}
Blackbody spectra and their peaksPlanck spectral radiance at three temperatures, 117 wavelengths each from the package; the dots are the peaks given by its Wien's-law capability: T = 3000 K: λ_max = 965.924 nm, B_λ = 995.249 W/(m² sr nm); T = 4500 K: λ_max = 643.949 nm, B_λ = 7557.67 W/(m² sr nm); T = 5778 K: λ_max = 501.518 nm, B_λ = 26376.3 W/(m² sr nm).010002000300001000020000501.518 nmT = 3000 KT = 4500 KT = 5778 Kλ — wavelength [nm]B_λ [W/(m² sr nm)]
Planck spectral radiance at three temperatures, 117 wavelengths each from the package; the dots are the peaks given by its Wien's-law capability: T = 3000 K: λ_max = 965.924 nm, B_λ = 995.249 W/(m² sr nm); T = 4500 K: λ_max = 643.949 nm, B_λ = 7557.67 W/(m² sr nm); T = 5778 K: λ_max = 501.518 nm, B_λ = 26376.3 W/(m² sr nm).

Tunnelling through a rectangular barrier

T = \left[1 + \frac{V_0^2\sinh^2(\kappa a)}{4E(V_0 - E)}\right]^{-1},\quad \kappa = \frac{\sqrt{2m(V_0 - E)}}{\hbar}
Tunnelling through a rectangular barrierTransmission and reflection of an electron (m = 9.1094e-31 kg) at a rectangular barrier of height V₀ = 3.2044e-19 J (2 eV) and width a = 0.5 nm, for 60 energies computed by the package; tunnelling below E = V₀, transmission resonances above it; marked: E/V₀ = 0.5, T = 0.0235471.012300.250.50.751E = V₀T = 0.0235471reflection Rtransmission TE / V₀ — particle energy over barrier heightprobability
Transmission and reflection of an electron (m = 9.1094e-31 kg) at a rectangular barrier of height V₀ = 3.2044e-19 J (2 eV) and width a = 0.5 nm, for 60 energies computed by the package; tunnelling below E = V₀, transmission resonances above it; marked: E/V₀ = 0.5, T = 0.0235471.
Formulas

The mathematics inside

12 of its 75 formulas; every one is in the capability browser below.

Lorentz factor
\gamma = \frac{1}{\sqrt{1 - v^2/c^2}}
Photon from a hydrogen-like transition (Rydberg formula)
\frac{1}{\lambda} = R_\infty Z^2\left(\frac{1}{n_\ell^2} - \frac{1}{n_u^2}\right)
Photoelectric effect
K_{max} = \frac{hc}{\lambda} - W = e V_{stop}
Two-qubit circuit: probabilities and entanglement
|\Phi^+\rangle = \mathrm{CNOT}_{01}(H\otimes I)|00\rangle = \tfrac{1}{\sqrt2}(|00\rangle + |11\rangle)
Transmission through a rectangular barrier
T = \left[1 + \frac{V_0^2\sinh^2(\kappa a)}{4E(V_0 - E)}\right]^{-1},\quad \kappa = \frac{\sqrt{2m(V_0 - E)}}{\hbar}
Clebsch-Gordan coefficient
\langle j_1 m_1; j_2 m_2 | J M\rangle
Semi-empirical mass formula (liquid-drop binding energy)
B = a_V A - a_S A^{2/3} - a_C\frac{Z(Z-1)}{A^{1/3}} - a_A\frac{(A-2Z)^2}{A} + \delta(A,Z)
Coulomb barrier between two nuclei
V_C = \frac{Z_1 Z_2 e^2}{4\pi\varepsilon_0\,r_0\left(A_1^{1/3} + A_2^{1/3}\right)}
Wigner 3j symbol
\begin{pmatrix} j_1 & j_2 & J \\ m_1 & m_2 & M \end{pmatrix}
Energy level of a hydrogen-like atom (Bohr model)
E_n = -\frac{Z^2 R_\infty h c}{n^2} \approx -\frac{13.6\ \mathrm{eV}\,Z^2}{n^2}
Kinematics of a two-body decay
p = \frac{\sqrt{\left[M^2 - (m_1 + m_2)^2\right]\left[M^2 - (m_1 - m_2)^2\right]}}{2M}
Age from the remaining fraction (radioactive dating)
t = \frac{T_{1/2}}{\ln 2}\ln\frac{N_0}{N}
Capabilities

Every capability, with an example

Search by name, formula, input or topic. Each capability opens to show what it takes, what it returns, when it applies, and a question it answered.

75 capabilities

Angular momentum 2

Clebsch-Gordan coefficientclebsch_gordan

The coefficient <j1 m1; j2 m2 | J M> for coupling two angular momenta (Condon-Shortley convention), with its exact square.

\langle j_1 m_1; j_2 m_2 | J M\rangle

Inputs

  • j1 first angular momentum (whole or half-whole)
  • m1 its projection
  • j2 second angular momentum
  • m2 its projection
  • J total angular momentum
  • M total projection

Returns

  • cg Clebsch-Gordan coefficient
  • cg_squared its square (a probability)
  • cg_squared_exact the square as an exact fraction

Applies when

  • each j >= 0 and whole or half-whole
  • |m| <= j with j - m whole

Example

m.ask("Clebsch-Gordan coefficient: j1 = 0.5, m1 = 0.5, j2 = 0.5, m2 = -0.5, J = 1, M = 0")
→ cg = 0.707107, cg_squared = 0.5, cg_squared_exact = 1/2
Wigner 3j symbolwigner_3j_symbol

The Wigner 3j symbol (j1 j2 J; m1 m2 M), nonzero only when m1 + m2 + M = 0.

\begin{pmatrix} j_1 & j_2 & J \\ m_1 & m_2 & M \end{pmatrix}

Inputs

  • j1 first angular momentum (whole or half-whole)
  • m1 its projection
  • j2 second angular momentum
  • m2 its projection
  • J total angular momentum
  • M total projection

Returns

  • w3j the 3j symbol
  • w3j_squared its square

Applies when

  • each j >= 0 and whole or half-whole
  • |m| <= j with j - m whole

Example

m.ask("Wigner 3j symbol: j1 = 1, m1 = 1, j2 = 1, m2 = -1, j3 = 0, m3 = 0")
→ w3j = 0.57735, w3j_squared = 0.333333

Hydrogen atom 7

Energy level of a hydrogen-like atom (Bohr model)bohr_energy_level

Energy, ionization energy, orbit radius and orbital speed of level n of a one-electron atom or ion with nuclear charge Z.

E_n = -\frac{Z^2 R_\infty h c}{n^2} \approx -\frac{13.6\ \mathrm{eV}\,Z^2}{n^2}

Inputs

  • Z atomic number (nuclear charge; 1 for hydrogen, 2 for He+ ...) integer
  • n principal quantum number integer

Returns

  • E_eV energy of the level (negative: bound) [eV]
  • E the same in J [J]
  • ionization_eV energy needed to ionize from this level [eV]
  • r Bohr orbit radius [m]
  • r_nm orbit radius in nm [nm]
  • v orbital speed [m/s]

Applies when

  • Z >= 1
  • n >= 1
  • infinitely heavy nucleus (no reduced-mass correction)

Example

m.ask("Bohr level: Z = 1, n = 1")
→ E_eV = -13.6057 eV, E = -2.17987e-18 J, ionization_eV = 13.6057 eV, r = 5.29177e-11 m, r_nm = 0.0529177 nm, v = 2.18769e+06 m/s
Hydrogen-like transition with the reduced-mass correctionhydrogen_transition_reduced_mass

Photon energy and wavelength of a transition of a one-electron atom whose nucleus has mass M (in u): R_M = R_inf mu/m_e.

\frac{1}{\lambda} = \frac{\mu}{m_e} R_\infty Z^2\left(\frac{1}{n_\ell^2} - \frac{1}{n_u^2}\right)

Inputs

  • Z atomic number (1 for hydrogen) integer
  • n_upper upper level integer
  • n_lower lower level integer
  • M_u mass of the nucleus in u (1.007276 for the proton, 2.013553 for the deuteron)

Returns

  • E_photon_eV photon energy [eV]
  • lam vacuum wavelength [m]
  • lambda_nm vacuum wavelength in nm [nm]
  • f frequency [Hz]
  • series spectral series (Lyman, Balmer, ...)
  • mu_ratio mu/m_e

Applies when

  • n_upper > n_lower >= 1
  • M > 0

Example

m.ask("Reduced-mass transition: Z = 1, n_upper = 3, n_lower = 2, M_u = 1.00727646688")
→ E_photon_eV = 1.88865 eV, lam = 6.5647e-07 m, lambda_nm = 656.47 nm, f = 4.56674e+14 Hz, series = Balmer, mu_ratio = 0.999456
K-alpha X-ray line (Moseley's law)moseley_k_alpha

Energy and wavelength of the K-alpha X-ray line of element Z, with one unit of screening (Z - 1).

E_{K\alpha} = \tfrac{3}{4} R_\infty h c\,(Z - 1)^2

Inputs

  • Z atomic number of the target element integer

Returns

  • E_keV photon energy [keV]
  • lam wavelength [m]
  • lambda_nm wavelength in nm [nm]
  • lambda_pm wavelength in pm [pm]
  • f frequency [Hz]

Applies when

  • Z >= 2

Example

m.ask("Moseley's law: Z = 29")
→ E_keV = 8.00015 keV, lam = 1.54977e-10 m, lambda_nm = 0.154977 nm, lambda_pm = 154.977 pm, f = 1.93443e+18 Hz
Landé g factor and anomalous Zeeman shiftlande_g_zeeman

The Landé g factor of a level L, S, J (with g_s = 2) and the energy shift g_J mu_B B mJ in a weak magnetic field.

g_J = 1 + \frac{J(J+1) + S(S+1) - L(L+1)}{2J(J+1)},\quad \Delta E = g_J \mu_B B m_J

Inputs

  • L orbital angular momentum quantum number
  • S spin quantum number
  • J total angular momentum quantum number
  • mJ magnetic quantum number
  • B magnetic field (T) [T]

Returns

  • g_J Landé g factor
  • dE Zeeman energy shift [J]
  • dE_eV the shift in eV [eV]
  • g_J_exact g_J as an exact fraction

Applies when

  • |L - S| <= J <= L + S, J > 0
  • |mJ| <= J
  • weak field (LS coupling holds)

Example

m.ask("Landé g factor: L = 1, S = 0.5, J = 1.5, mJ = 0.5, B = 1 T")
→ g_J = 1.33333, dE = 6.18267e-24 J, dE_eV = 3.85892e-05 eV, g_J_exact = 4/3
Photon from a hydrogen-like transition (Rydberg formula)hydrogen_transition

Energy, wavelength and frequency of the photon emitted when a one-electron atom drops from n_upper to n_lower.

\frac{1}{\lambda} = R_\infty Z^2\left(\frac{1}{n_\ell^2} - \frac{1}{n_u^2}\right)

Inputs

  • Z atomic number (1 for hydrogen) integer
  • n_upper upper level integer
  • n_lower lower level integer

Returns

  • E_photon_eV photon energy [eV]
  • lam vacuum wavelength [m]
  • lambda_nm vacuum wavelength in nm [nm]
  • f frequency [Hz]
  • series spectral series (Lyman, Balmer, ...)

Applies when

  • n_upper > n_lower >= 1
  • infinitely heavy nucleus

Example

m.ask("Hydrogen transition: Z = 1, n_upper = 3, n_lower = 2")
→ E_photon_eV = 1.88968 eV, lam = 6.56112e-07 m, lambda_nm = 656.112 nm, f = 4.56922e+14 Hz, series = Balmer
Probability of finding the electron within a radiushydrogen_radial_probability

The probability that the electron of the hydrogen-like state n, l lies within distance R of the nucleus.

P(r < R) = \int_0^R |R_{nl}(r)|^2 r^2\,dr

Inputs

  • n principal quantum number integer
  • l orbital quantum number (0 <= l < n) integer
  • Z atomic number integer
  • R radius (pm, nm, m) [m]

Returns

  • P_inside probability within R
  • P_outside probability beyond R
  • R_a0 R in units of a0

Applies when

  • n >= 1
  • 0 <= l <= n - 1
  • R > 0
  • infinitely heavy nucleus

Example

m.ask("Radial probability: n = 1, l = 0, Z = 1, R = 52.9177210544 pm")
→ P_inside = 0.323324, P_outside = 0.676676, R_a0 = 1
Radial expectation values of a hydrogen-like statehydrogen_radial_expectations

<r>, <r^2>, <1/r> and the radial spread of the state n, l of a one-electron atom with nuclear charge Z (in Bohr radii).

\langle r\rangle = \frac{a_0}{2Z}\left[3n^2 - l(l+1)\right]

Inputs

  • n principal quantum number integer
  • l orbital quantum number (0 <= l < n) integer
  • Z atomic number integer

Returns

  • r_mean_a0 <r> in units of a0
  • r2_mean_a0sq <r^2> in units of a0^2
  • inv_r_mean_per_a0 <1/r> in units of 1/a0
  • r_mean <r> in m [m]
  • dr_a0 radial spread sqrt(<r^2> - <r>^2) in a0

Applies when

  • n >= 1
  • 0 <= l <= n - 1
  • infinitely heavy nucleus

Example

m.ask("Radial expectation values: n = 2, l = 1, Z = 1")
→ r_mean_a0 = 5, r2_mean_a0sq = 30, inv_r_mean_per_a0 = 0.25, r_mean = 2.64589e-10 m, dr_a0 = 2.23607

Nuclear and particle physics 2

Kinematics of a two-body decaytwo_body_decay

Q value, momentum and kinetic energies of the two products when a particle or nucleus at rest decays into two bodies (alpha decay, pi -> mu nu, ...).

p = \frac{\sqrt{\left[M^2 - (m_1 + m_2)^2\right]\left[M^2 - (m_1 - m_2)^2\right]}}{2M}

Inputs

  • M mass of the parent
  • m1 mass of product 1
  • m2 mass of product 2 (0 for a photon or neutrino)
  • unit unit of the masses: MeV/c^2 (default) or u choice optional

Returns

  • Q_MeV Q value (M - m1 - m2) c^2 [MeV]
  • p_MeV momentum of each product times c [MeV]
  • E1_MeV total energy of product 1 [MeV]
  • E2_MeV total energy of product 2 [MeV]
  • K1_MeV kinetic energy of product 1 [MeV]
  • K2_MeV kinetic energy of product 2 [MeV]

Applies when

  • M > m1 + m2
  • m1, m2 >= 0

Example

m.ask("Two-body decay: M = 139.57039, m1 = 105.6583755, m2 = 0")
→ Q_MeV = 33.912 MeV, p_MeV = 29.7921 MeV, E1_MeV = 109.778 MeV, E2_MeV = 29.7921 MeV, K1_MeV = 4.11987 MeV, K2_MeV = 29.7921 MeV
Semi-empirical mass formula (liquid-drop binding energy)semi_empirical_mass_formula

The liquid-drop (Bethe-Weizsaecker) binding energy of a nucleus with Z protons and mass number A, its terms, the binding energy per nucleon, the atomic mass and the most stable Z for that A.

B = a_V A - a_S A^{2/3} - a_C\frac{Z(Z-1)}{A^{1/3}} - a_A\frac{(A-2Z)^2}{A} + \delta(A,Z)

Inputs

  • Z number of protons integer
  • A mass number integer

Returns

  • B_MeV binding energy [MeV]
  • B_per_A_MeV binding energy per nucleon [MeV]
  • mass_u atomic mass in u (Z m(1H) + N m_n - B/c^2)
  • volume_MeV volume term a_V A [MeV]
  • surface_MeV surface term a_S A^(2/3) [MeV]
  • coulomb_MeV Coulomb term a_C Z(Z - 1)/A^(1/3) [MeV]
  • asymmetry_MeV asymmetry term a_A (A - 2Z)^2/A [MeV]
  • pairing_MeV pairing term (+ even-even, 0 odd A, - odd-odd) [MeV]
  • Z_stable most stable (continuous) Z for this A, where dB/dZ = 0

Applies when

  • 1 <= Z <= A
  • A >= 2
  • a liquid-drop estimate: poor for light nuclei

Example

m.ask("Semi-empirical mass formula: Z = 26, A = 56")
→ B_MeV = 495.384 MeV, B_per_A_MeV = 8.84614 MeV, mass_u = 55.9316, volume_MeV = 882 MeV, surface_MeV = 260.543 MeV, coulomb_MeV = 120.796 MeV, asymmetry_MeV = 6.77143 MeV, pairing_MeV = 1.49399 MeV, Z_stable = 25.2797

Nuclear physics 6

Age from the remaining fraction (radioactive dating)radioactive_dating_age

The time needed for a radioactive sample to decay to a given fraction of its original amount (for example carbon-14 dating).

t = \frac{T_{1/2}}{\ln 2}\ln\frac{N_0}{N}

Inputs

  • fraction fraction of the original nuclei (or activity) remaining, 0 < f <= 1 (or a percentage)
  • T_half half-life [s]

Returns

  • t elapsed time (age) [s]
  • half_lives number of half-lives
  • decay_constant decay constant [1/s]

Applies when

  • 0 < fraction <= 1
  • T_half > 0

Example

m.ask("Radioactive dating: fraction = 0.25, T_half = 5730 yr")
→ t = 3.6165e+11 s, half_lives = 2, decay_constant = 3.83325e-12 1/s
Coulomb barrier between two nucleicoulomb_barrier

The Coulomb potential energy of two nuclei just touching, with radii R = r0 A^(1/3).

V_C = \frac{Z_1 Z_2 e^2}{4\pi\varepsilon_0\,r_0\left(A_1^{1/3} + A_2^{1/3}\right)}

Inputs

  • Z1 charge number of nucleus 1 integer
  • A1 mass number of nucleus 1 integer
  • Z2 charge number of nucleus 2 integer
  • A2 mass number of nucleus 2 integer
  • r0 radius parameter (typically 1.2 fm) [m]

Returns

  • V_MeV Coulomb barrier height [MeV]
  • R touching distance r0 (A1^(1/3) + A2^(1/3)) [m]
  • R_fm the same in fm [fm]

Applies when

  • 1 <= Z <= A
  • r0 > 0

Example

m.ask("Coulomb barrier: Z1 = 1, A1 = 1, Z2 = 1, A2 = 1, r0 = 1 fm")
→ V_MeV = 0.719982 MeV, R = 2e-15 m, R_fm = 2 fm
Decay of a named radionuclidenuclide_decay

The fraction of a named radionuclide (C-14, Co-60, I-131, U-238, ...) left after time t, with its tabulated half-life, decay constant and mean life.

\frac{N}{N_0} = 2^{-t/T_{1/2}}

Inputs

  • nuclide the radionuclide (e.g. C-14, Cs-137, I-131) choice
  • t elapsed time [s]

Returns

  • fraction fraction of the parent nuclide remaining
  • half_life half-life (ICRP-107) [s]
  • half_life_years half-life in Julian years
  • decay_constant decay constant [1/s]
  • mean_life mean life [s]
  • specific_activity_per_atom activity per original atom at time t (Bq) [1/s]

Applies when

  • t >= 0
  • one of the tabulated nuclides

Example

m.ask("Nuclide decay: nuclide = I-131, t = 1385976.96 s")
→ fraction = 0.25, half_life = 692988 s, half_life_years = 0.0219595, decay_constant = 1.00023e-06 1/s, mean_life = 999771 s, specific_activity_per_atom = 2.50057e-07 1/s
Parent-daughter decay chain (Bateman)decay_chain_parent_daughter

Numbers and activities of a parent and its radioactive daughter after time t, starting from pure parent (Bateman solution).

N_D(t) = N_0\frac{\lambda_P}{\lambda_D - \lambda_P}\left(e^{-\lambda_P t} - e^{-\lambda_D t}\right)

Inputs

  • T_half_P half-life of the parent [s]
  • T_half_D half-life of the daughter [s]
  • N0 initial number of parent nuclei
  • t elapsed time [s]

Returns

  • N_parent parent nuclei
  • N_daughter daughter nuclei
  • A_parent parent activity (Bq) [1/s]
  • A_daughter daughter activity (Bq) [1/s]
  • activity_ratio A_daughter/A_parent (tends to 1 in secular equilibrium)

Applies when

  • half-lives and N0 positive
  • t >= 0
  • no daughter at t = 0

Example

m.ask("Decay chain: T_half_P = 2 s, T_half_D = 1 s, N0 = 1, t = 2 s")
→ N_parent = 0.5, N_daughter = 0.25, A_parent = 0.173287 1/s, A_daughter = 0.173287 1/s, activity_ratio = 1
Q value and threshold energy of a nuclear reactionnuclear_reaction_threshold

Q value of a + X -> Y + b from the masses (in u) and, for an endothermic reaction, the minimum beam kinetic energy on a target at rest (relativistic).

Q = (m_a + m_X - m_Y - m_b)c^2,\quad K_{th} = -Q\,\frac{m_a + m_X + m_Y + m_b}{2 m_X}

Inputs

  • m_a projectile mass (u)
  • m_X target mass (u)
  • m_Y heavy product mass (u)
  • m_b light product mass (u)

Returns

  • Q_MeV Q value [MeV]
  • K_threshold_MeV threshold kinetic energy of the projectile (0 if exothermic) [MeV]
  • endothermic whether the reaction needs energy (Q < 0)

Applies when

  • masses >= 0
  • target at rest

Example

m.ask("Reaction threshold: m_a = 4.002603254, m_X = 14.003074004, m_Y = 16.999131757, m_b = 1.00782503207")
→ Q_MeV = -1.19188 MeV, K_threshold_MeV = 1.53261 MeV, endothermic = yes
Radioactive decay lawradioactive_decay_law

Nuclei remaining, fraction, decay constant, mean life and activity after time t, from the half-life and the initial number of nuclei.

N(t) = N_0\,2^{-t/T_{1/2}} = N_0 e^{-\lambda t},\quad A = \lambda N

Inputs

  • T_half half-life [s]
  • N0 initial number of nuclei
  • t elapsed time [s]

Returns

  • N nuclei remaining
  • fraction fraction remaining N/N0
  • decay_constant decay constant ln2/T_half [1/s]
  • mean_life mean life 1/lambda [s]
  • A0 initial activity (Bq) [1/s]
  • A activity at time t (Bq) [1/s]
  • half_lives number of half-lives elapsed

Applies when

  • T_half > 0
  • N0 > 0
  • t >= 0

Example

m.ask("Decay law: T_half = 5730 yr, N0 = 1e20, t = 11460 yr")
→ N = 2.5e+19, fraction = 0.25, decay_constant = 3.83325e-12 1/s, mean_life = 2.60875e+11 s, A0 = 3.83325e+08 1/s, A = 9.58312e+07 1/s, half_lives = 2

Particle physics 1

Mean decay length of a relativistic unstable particleparticle_decay_length

Lorentz factor, lab-frame lifetime and mean decay length beta gamma c tau of a pion, kaon, muon, hyperon, charm or bottom meson with momentum p.

L = \beta\gamma c\tau = \frac{p}{mc}\,c\tau

Inputs

  • particle the particle (pi+, K+, K_S0, K_L0, mu-, tau-, n, Lambda, ...) choice
  • p momentum in GeV/c

Returns

  • gamma Lorentz factor
  • beta v/c
  • beta_gamma beta gamma = p/(m c)
  • lifetime_lab mean lifetime in the lab [s]
  • mean_decay_length mean decay length beta gamma c tau [m]
  • proper_lifetime mean proper lifetime (PDG) [s]
  • mass_MeV mass (MeV/c^2, PDG)

Applies when

  • p >= 0
  • one of the tabulated particles

Example

m.ask("Decay length: particle = mu-, p = 0.1056583755")
→ gamma = 1.41421, beta = 0.707107, beta_gamma = 1, lifetime_lab = 3.107e-06 s, mean_decay_length = 658.638 m, proper_lifetime = 2.19698e-06 s, mass_MeV = 105.658

Photons and matter waves 7

Compton scatteringcompton_scattering

Wavelength and energy of a photon scattered by a free electron at rest through angle theta, and the electron's kinetic energy.

\lambda' - \lambda = \frac{h}{m_e c}\left(1 - \cos\theta\right)

Inputs

  • lam incident wavelength (pm, nm, m) [m]
  • theta scattering angle of the photon (deg or rad) [rad]

Returns

  • lambda_prime scattered wavelength [m]
  • lambda_prime_pm scattered wavelength in pm [pm]
  • shift_pm Compton shift lambda' - lambda in pm [pm]
  • E_in_keV incident photon energy [keV]
  • E_out_keV scattered photon energy [keV]
  • K_electron_keV kinetic energy of the recoil electron [keV]

Applies when

  • lambda > 0
  • 0 <= theta <= 180 deg

Example

m.ask("Compton scattering: lambda = 71 pm, theta = 90 deg")
→ lambda_prime = 7.34263e-11 m, lambda_prime_pm = 73.4263 pm, shift_pm = 2.42631 pm, E_in_keV = 17.4626 keV, E_out_keV = 16.8855 keV, K_electron_keV = 0.577036 keV
de Broglie wavelength of a moving particlede_broglie_wavelength_mv

The de Broglie wavelength lambda = h/(m v) of a particle of mass m moving at speed v, and the relativistic h/(gamma m v).

\lambda = \frac{h}{p} = \frac{h}{m v}

Inputs

  • m mass of the particle [kg]
  • v speed (may be written as a fraction of c) [m/s]

Returns

  • p momentum m v [kg*m/s]
  • lam de Broglie wavelength h/(m v) [m]
  • lambda_nm the same in nm [nm]
  • lambda_rel_nm relativistic wavelength h/(gamma m v) in nm [nm]
  • inv_lambda 1/lambda = m v/h in 1/m (well scaled for heavy bodies, whose lambda is tiny)
  • beta v/c

Applies when

  • m > 0
  • 0 < v < c

Example

m.ask("de Broglie wavelength of a moving particle: m = 9.1093837139e-31 kg, v = 1e6 m/s")
→ p = 9.10938e-25 kg*m/s, lam = 7.2739e-10 m, lambda_nm = 0.72739 nm, lambda_rel_nm = 0.727385 nm, inv_lambda = 1.37478e+09, beta = 0.00333564
de Broglie wavelength of an accelerated particlede_broglie_accelerated

The de Broglie wavelength of an electron or proton accelerated from rest through a voltage V, non-relativistic and relativistic.

\lambda = \frac{h}{p},\quad p = \frac{1}{c}\sqrt{K(K + 2mc^2)}

Inputs

  • V accelerating voltage [V]
  • particle the accelerated particle (charge e) choice

Returns

  • lambda_nonrel wavelength h/sqrt(2 m e V) [m]
  • lambda_nonrel_nm the same in nm [nm]
  • lambda_rel relativistic wavelength [m]
  • lambda_rel_nm the same in nm [nm]
  • p relativistic momentum [kg*m/s]
  • K_eV kinetic energy [eV]

Applies when

  • V > 0

Example

m.ask("de Broglie wavelength: V = 100 V, particle = electron")
→ lambda_nonrel = 1.22643e-10 m, lambda_nonrel_nm = 0.122643 nm, lambda_rel = 1.22637e-10 m, lambda_rel_nm = 0.122637 nm, p = 5.40301e-24 kg*m/s, K_eV = 100 eV
Minimum momentum uncertainty (Heisenberg)heisenberg_minimum_uncertainty

The smallest momentum and velocity uncertainty compatible with a position uncertainty dx: dp = hbar/(2 dx).

\Delta x\,\Delta p \ge \frac{\hbar}{2}

Inputs

  • dx position uncertainty (standard deviation) [m]
  • m mass of the particle [kg]

Returns

  • dp minimum momentum uncertainty [kg*m/s]
  • dp_eV_per_c the same in eV/c
  • dv minimum velocity uncertainty [m/s]

Applies when

  • dx > 0
  • m > 0

Example

m.ask("Minimum uncertainty: dx = 0.1 nm, m = 9.1093837139e-31 kg")
→ dp = 5.27286e-25 kg*m/s, dp_eV_per_c = 986.635, dv = 578838 m/s
Photoelectric effectphotoelectric_effect

Maximum kinetic energy of photoelectrons, stopping potential and threshold wavelength from the light's wavelength and the metal's work function.

K_{max} = \frac{hc}{\lambda} - W = e V_{stop}

Inputs

  • lam wavelength of the light (nm, m ...) [m]
  • W work function of the metal (eV, J) [J]

Returns

  • E_photon_eV photon energy [eV]
  • K_max_eV maximum kinetic energy of the photoelectrons [eV]
  • V_stop stopping potential [V]
  • lambda_threshold threshold (cut-off) wavelength [m]
  • lambda_threshold_nm threshold wavelength in nm [nm]
  • f_threshold threshold frequency [Hz]

Applies when

  • wavelength and work function positive
  • photon energy at least the work function

Example

m.ask("Photoelectric effect: lambda = 250 nm, W = 4.3 eV")
→ E_photon_eV = 4.95937 eV, K_max_eV = 0.659368 eV, V_stop = 0.659368 V, lambda_threshold = 2.88335e-07 m, lambda_threshold_nm = 288.335 nm, f_threshold = 1.03974e+15 Hz
Photon energy from wavelengthphoton_energy

The energy E = h c/lambda, frequency and momentum h/lambda of a photon of vacuum wavelength lambda.

E = h f = \frac{hc}{\lambda},\quad p = \frac{h}{\lambda}

Inputs

  • lam vacuum wavelength (nm, m ...) [m]

Returns

  • E photon energy in J [J]
  • E_eV photon energy in eV [eV]
  • f frequency c/lambda [Hz]
  • p photon momentum h/lambda [kg*m/s]

Applies when

  • lambda > 0
  • in vacuum

Example

m.ask("Photon energy: lambda = 500 nm")
→ E = 3.97289e-19 J, E_eV = 2.47968 eV, f = 5.99585e+14 Hz, p = 1.32521e-27 kg*m/s
Photon-number distribution of a coherent statecoherent_state_photon_statistics

The probability of n photons in a coherent (laser) state |alpha>, its mean photon number and variance (Poisson statistics).

P(n) = e^{-|\alpha|^2}\frac{|\alpha|^{2n}}{n!}

Inputs

  • alpha coherent amplitude |alpha|
  • n photon number integer

Returns

  • P_n probability of exactly n photons
  • mean_n mean photon number |alpha|^2
  • variance photon-number variance |alpha|^2
  • P_0 probability of no photons

Applies when

  • |alpha| >= 0
  • n >= 0

Example

m.ask("Coherent state: alpha = 2, n = 3")
→ P_n = 0.195367, mean_n = 4, variance = 4, P_0 = 0.0183156

Quantum gates 4

Bloch-sphere rotation of a single-qubit gate sequencegate_rotation_axis

The single rotation (axis n and angle) of the Bloch sphere that a sequence of single-qubit gates performs (global phase ignored).

U \simeq e^{-i\theta\,\hat n\cdot\vec\sigma/2} = \cos\tfrac{\theta}{2} I - i\sin\tfrac{\theta}{2}\,\hat n\cdot\vec\sigma

Inputs

  • gates gates applied left to right, e.g. 'H T Rz(pi/2) X' text

Returns

  • angle rotation angle in [0, pi] (rad) [rad]
  • angle_deg rotation angle in degrees
  • nx axis x
  • ny axis y
  • nz axis z

Applies when

  • gates from H, X, Y, Z, S, Sdg, T, Tdg, I, Rx(t), Ry(t), Rz(t), P(t)

Example

m.ask("Gate rotation: gates = H")
→ angle = 3.14159 rad, angle_deg = 180, nx = 0.707107, ny = 0, nz = 0.707107
State of a qubit after a sequence of gatessingle_qubit_circuit

The amplitudes, measurement probabilities and Bloch vector of a qubit after gates such as H, X, S, T and rotations act on |0>, |1>, |+>, ...

|\psi\rangle = U_k \cdots U_2 U_1 |\psi_0\rangle

Inputs

  • start initial state |0>, |1>, |+>, |->, |+i> or |-i> choice
  • gates gates applied left to right, e.g. 'H T Rz(pi/2) X' text

Returns

  • alpha_re Re alpha (global phase fixed: first non-zero amplitude real positive)
  • alpha_im Im alpha
  • beta_re Re beta
  • beta_im Im beta
  • p0 probability of measuring 0
  • p1 probability of measuring 1
  • bx Bloch x
  • by Bloch y
  • bz Bloch z

Applies when

  • gates from H, X, Y, Z, S, Sdg, T, Tdg, I, Rx(t), Ry(t), Rz(t), P(t)
  • at most 500 gates

Example

m.ask("Single-qubit circuit: start = 0; gates = H")
→ alpha_re = 0.707107, alpha_im = 0, beta_re = 0.707107, beta_im = 0, p0 = 0.5, p1 = 0.5, bx = 1, by = 0, bz = 0
Two-qubit circuit: probabilities and entanglementtwo_qubit_circuit

Measurement probabilities of |00>, |01>, |10>, |11> and the concurrence (entanglement) after a two-qubit gate sequence such as H0 CNOT01 (a Bell state).

|\Phi^+\rangle = \mathrm{CNOT}_{01}(H\otimes I)|00\rangle = \tfrac{1}{\sqrt2}(|00\rangle + |11\rangle)

Inputs

  • start initial basis state |q0 q1> choice
  • gates gates left to right: H0, X1, Rz0(t), ..., CNOT01 (control q0), CNOT10, CZ, SWAP text

Returns

  • p00 probability of |00>
  • p01 probability of |01>
  • p10 probability of |10>
  • p11 probability of |11>
  • concurrence concurrence 2|a00 a11 - a01 a10| (0 product, 1 maximally entangled)
  • p_q0_is_1 probability that q0 reads 1
  • p_q1_is_1 probability that q1 reads 1

Applies when

  • gates from the documented set
  • at most 500 gates

Example

m.ask("Two-qubit circuit: start = 00; gates = H0 CNOT01")
→ p00 = 0.5, p01 = 0, p10 = 0, p11 = 0.5, concurrence = 1, p_q0_is_1 = 0.5, p_q1_is_1 = 0.5

Quantum wells 10

Bound states of a finite square wellfinite_square_well

The number and energies of the bound states of a particle of mass m in a square well of depth V0 and width a.

z\tan z = \sqrt{z_0^2 - z^2},\quad -z\cot z = \sqrt{z_0^2 - z^2},\quad z_0 = \frac{a}{2\hbar}\sqrt{2mV_0}

Inputs

  • V0 depth of the well (eV, J) [J]
  • a width of the well [m]
  • m particle mass [kg]

Returns

  • n_bound number of bound states
  • E1_eV ground-state energy above the bottom of the well [eV]
  • energies_eV all bound-state energies above the bottom (eV), ascending
  • z0 well strength (a/2) sqrt(2 m V0)/hbar

Applies when

  • V0, a, m > 0
  • at most 127 bound states
  • no state exactly at the top of the well

Example

m.ask("Finite square well: V0 = 10 eV, a = 0.5 nm, m = 9.1093837139e-31 kg")
→ n_bound = 3, E1_eV = 0.961043 eV, energies_eV = [0.961042905305, 3.75528284707, 7.95049450895], z0 = 4.05022
Energy levels of a particle in a boxinfinite_well_levels

Energy E_n = n^2 h^2/(8 m L^2), momentum and de Broglie wavelength of level n of a particle in a one-dimensional box of width L.

E_n = \frac{n^2 h^2}{8 m L^2}

Inputs

  • m particle mass [kg]
  • L width of the box [m]
  • n quantum number (1, 2, 3, ...) integer

Returns

  • E energy of level n [J]
  • E_eV the same in eV [eV]
  • E1_eV ground-state energy [eV]
  • p magnitude of the momentum n pi hbar/L [kg*m/s]
  • wavelength de Broglie wavelength 2L/n [m]

Applies when

  • m > 0
  • L > 0
  • n >= 1
  • infinitely high walls

Example

m.ask("Particle in a box: m = 9.1093837139e-31 kg, L = 1 nm, n = 1")
→ E = 6.02467e-20 J, E_eV = 0.37603 eV, E1_eV = 0.37603 eV, p = 3.31304e-25 kg*m/s, wavelength = 2e-09 m
Photon from a particle-in-a-box transitioninfinite_well_transition

Energy, wavelength and frequency of the photon emitted when a particle in a box of width L drops from n_upper to n_lower.

\Delta E = \frac{(n_u^2 - n_\ell^2)\,h^2}{8 m L^2} = \frac{hc}{\lambda}

Inputs

  • m particle mass [kg]
  • L width of the box [m]
  • n_upper upper level integer
  • n_lower lower level integer

Returns

  • E_photon_eV photon energy [eV]
  • lam wavelength [m]
  • lambda_nm wavelength in nm [nm]
  • f frequency [Hz]

Applies when

  • n_upper > n_lower >= 1

Example

m.ask("Particle in a box transition: m = 9.1093837139e-31 kg, L = 1 nm, n_upper = 2, n_lower = 1")
→ E_photon_eV = 1.12809 eV, lam = 1.09906e-06 m, lambda_nm = 1099.06 nm, f = 2.72771e+14 Hz
Position and momentum spread in a boxinfinite_well_uncertainty

<x>, the position spread dx, the momentum spread dp and the product dx dp of level n of a particle in a box of width L.

\Delta x = L\sqrt{\frac{1}{12} - \frac{1}{2n^2\pi^2}},\quad \Delta p = \frac{n\pi\hbar}{L}

Inputs

  • n quantum number integer
  • L width of the box [m]

Returns

  • x_mean <x> (the centre) [m]
  • dx position spread [m]
  • dx_over_L dx/L
  • dp momentum spread n pi hbar/L [kg*m/s]
  • product_over_hbar dx dp / hbar (at least 1/2)

Applies when

  • n >= 1
  • L > 0

Example

m.ask("Particle in a box uncertainty: n = 1, L = 1 m")
→ x_mean = 0.5 m, dx = 0.180756 m, dx_over_L = 0.180756, dp = 3.31304e-34 kg*m/s, product_over_hbar = 0.567862
Probability beyond the classical turning points (harmonic oscillator)harmonic_oscillator_forbidden_probability

The probability that a harmonic oscillator in level n is found in the classically forbidden region |x| > A_n.

P = 1 - \int_{-\sqrt{2n+1}}^{\sqrt{2n+1}} |\psi_n(\xi)|^2\,d\xi

Inputs

  • n quantum number (0 to 60) integer

Returns

  • P_forbidden probability outside the turning points
  • P_allowed probability inside
  • xi_turning turning point in units of sqrt(hbar/(m omega))

Applies when

  • 0 <= n <= 60

Example

m.ask("Forbidden region probability: n = 0")
→ P_forbidden = 0.157299, P_allowed = 0.842701, xi_turning = 1
Probability of finding a particle in part of a boxinfinite_well_probability

The probability that a particle in level n of a box of width L is found between x1 and x2.

P = \int_{x_1}^{x_2} \frac{2}{L}\sin^2\frac{n\pi x}{L}\,dx

Inputs

  • n quantum number integer
  • L width of the box [m]
  • x1 left end of the interval (from the wall) [m]
  • x2 right end of the interval [m]

Returns

  • P probability
  • classical classical (uniform) probability (x2 - x1)/L

Applies when

  • 0 <= x1 < x2 <= L
  • n >= 1

Example

m.ask("Particle in a box probability: n = 1, L = 1 nm, x1 = 0.25 nm, x2 = 0.75 nm")
→ P = 0.81831, classical = 0.5
Quantum harmonic oscillator levelsharmonic_oscillator_levels

Energy (n + 1/2) hbar omega, zero-point energy, level spacing, classical amplitude and position spread of level n.

E_n = \left(n + \tfrac12\right)\hbar\omega

Inputs

  • m mass [kg]
  • omega angular frequency [rad/s]
  • n quantum number (0, 1, 2, ...) integer

Returns

  • E energy of level n [J]
  • E_eV the same in eV [eV]
  • E0_eV zero-point energy [eV]
  • spacing_eV level spacing hbar omega [eV]
  • amplitude classical turning point [m]
  • dx position spread sqrt(<x^2>) [m]

Applies when

  • m > 0
  • omega > 0
  • n >= 0

Example

m.ask("Harmonic oscillator: m = 1.67262192595e-27 kg, omega = 1e14 rad/s, n = 0")
→ E = 5.27286e-21 J, E_eV = 0.0329106 eV, E0_eV = 0.0329106 eV, spacing_eV = 0.0658212 eV, amplitude = 2.51096e-11 m, dx = 1.77551e-11 m
Reflection and transmission at a potential stepstep_potential

Reflection and transmission probabilities of a particle of energy E meeting a potential step of height V0 (V = 0 for x < 0, V0 for x > 0).

R = \left(\frac{k_1 - k_2}{k_1 + k_2}\right)^2,\quad T = \frac{4k_1k_2}{(k_1 + k_2)^2},\quad \frac{k_2}{k_1} = \sqrt{\frac{E - V_0}{E}}

Inputs

  • E kinetic energy of the incident particle (on the low side) [J]
  • V0 height of the step [J]

Returns

  • R reflection probability
  • T transmission probability (ratio of probability currents)
  • k2_over_k1 ratio of wavenumbers sqrt((E - V0)/E) (0 when E <= V0)
  • regime partial transmission (E > V0) or total reflection

Applies when

  • E > 0
  • V0 > 0
  • the particle comes from x < 0

Example

m.ask("Step potential: E = 4 eV, V0 = 3 eV")
→ R = 0.111111, T = 0.888889, k2_over_k1 = 0.5, regime = partial transmission (E > V0)
Transmission through a rectangular barrierbarrier_transmission

Transmission and reflection probabilities of a particle of energy E meeting a rectangular barrier of height V0 and width a (below or above the top).

T = \left[1 + \frac{V_0^2\sinh^2(\kappa a)}{4E(V_0 - E)}\right]^{-1},\quad \kappa = \frac{\sqrt{2m(V_0 - E)}}{\hbar}

Inputs

  • E kinetic energy of the incident particle [J]
  • V0 barrier height [J]
  • a barrier width [m]
  • m particle mass [kg]

Returns

  • T transmission probability
  • R reflection probability
  • kappa_a kappa a = a sqrt(2m(V0 - E))/hbar (0 above the barrier)
  • regime tunnelling (E < V0) or over the barrier

Applies when

  • E, V0, a, m > 0

Example

m.ask("Barrier transmission: E = 1 eV, V0 = 2 eV, a = 0.5 nm, m = 9.1093837139e-31 kg")
→ T = 0.0235471, R = 0.976453, kappa_a = 2.56158, regime = tunnelling (E < V0)
WKB tunnelling through a triangular barrier (field emission)wkb_field_emission

The WKB tunnelling exponent and probability of an electron at the Fermi level through the triangular barrier W - eFx of a metal in a field F.

T \approx \exp\!\left(-\frac{4\sqrt{2m_e}\,W^{3/2}}{3 e\hbar F}\right)

Inputs

  • W barrier height above the electron's energy (work function, eV) [J]
  • F applied electric field (V/m) [N/C]

Returns

  • exponent WKB exponent 2 integral kappa dx
  • T tunnelling probability exp(-exponent)
  • log10_T log10 of the probability
  • width barrier width W/(eF) [m]
  • width_nm width in nm [nm]

Applies when

  • W > 0
  • F > 0
  • WKB: exponent much larger than 1

Example

m.ask("Field emission: W = 4.5 eV, F = 5e9 V/m")
→ exponent = 13.0415, T = 2.16854e-06, log10_T = -5.66383, width = 9e-10 m, width_nm = 0.9 nm

Special relativity 13

Centre-of-mass energy of a fixed-target collisionfixed_target_cm_energy

sqrt(s) for a beam particle of mass m1 and total energy E1 striking a target of mass m2 at rest (natural units, GeV).

\sqrt{s} = \sqrt{m_1^2 c^4 + m_2^2 c^4 + 2 E_1 m_2 c^2}

Inputs

  • m1 beam particle mass (GeV/c^2)
  • E1 beam particle total energy (GeV)
  • m2 target mass (GeV/c^2)

Returns

  • sqrt_s centre-of-mass energy sqrt(s) (GeV)
  • available energy available for new particles, sqrt(s) - m1 - m2 (GeV)
  • beta_cm speed of the centre-of-mass frame / c
  • gamma_cm its Lorentz factor

Applies when

  • E1 >= m1 >= 0
  • m2 > 0

Example

m.ask("Centre-of-mass energy: m1 = 1, E1 = 7, m2 = 1")
→ sqrt_s = 4, available = 2, beta_cm = 0.866025, gamma_cm = 2
Invariant mass of two particlesinvariant_mass

The invariant mass M = sqrt((E1 + E2)^2 - |p1 + p2|^2) of two particles, in natural units (GeV, GeV/c, GeV/c^2).

M c^2 = \sqrt{(E_1 + E_2)^2 - |\vec p_1 + \vec p_2|^2 c^2}

Inputs

  • E1 energy of particle 1 (GeV)
  • p1 momentum of particle 1 (px, py, pz in GeV/c) vector
  • E2 energy of particle 2 (GeV)
  • p2 momentum of particle 2 (px, py, pz in GeV/c) vector

Returns

  • M invariant mass (GeV/c^2)
  • P magnitude of the total momentum (GeV/c)
  • beta_cm speed of the centre-of-mass frame / c
  • gamma_cm Lorentz factor of the centre-of-mass frame

Applies when

  • E >= |p| for each particle
  • a positive invariant mass

Example

m.ask("Invariant mass: E1 = 50; p1 = 30, 0, 40; E2 = 50; p2 = -30, 0, -40")
→ M = 100, P = 0, beta_cm = 0, gamma_cm = 1
Length contractionlength_contraction

The length L = L0/gamma of a rod moving along its length at speed v, given its proper length L0.

L = \frac{L_0}{\gamma} = L_0\sqrt{1 - v^2/c^2}

Inputs

  • L0 proper length (in the rod's rest frame) [m]
  • v speed of the rod (may be written as a fraction of c) [m/s]

Returns

  • L contracted length measured in the frame where the rod moves [m]
  • gamma Lorentz factor
  • shortening L0 - L [m]

Applies when

  • L0 > 0
  • 0 <= v < c

Example

m.ask("Length contraction: L0 = 100 m, v = 0.6 c")
→ L = 80 m, gamma = 1.25, shortening = 20 m
Lorentz factorlorentz_factor

The Lorentz factor gamma = 1/sqrt(1 - v^2/c^2) of a speed v.

\gamma = \frac{1}{\sqrt{1 - v^2/c^2}}

Inputs

  • v speed (may be written as a fraction of c, e.g. 0.8 c) [m/s]

Returns

  • gamma Lorentz factor
  • beta v/c
  • gamma_minus_1 gamma - 1 (computed without cancellation)

Applies when

  • 0 <= v < c

Example

m.ask("Lorentz factor: v = 0.6 c")
→ gamma = 1.25, beta = 0.6, gamma_minus_1 = 0.25
Relativistic aberration of lightrelativistic_aberration

The direction of a light ray seen from a frame moving at speed v along +x, given its direction theta (from +x) in the rest frame.

\cos\theta' = \frac{\cos\theta - \beta}{1 - \beta\cos\theta}

Inputs

  • theta direction of travel of the light in the rest frame, from the +x axis (rad or deg) [rad]
  • v speed of the moving frame along +x (may be a fraction of c) [m/s]

Returns

  • theta_prime direction of travel in the moving frame (rad) [rad]
  • theta_prime_deg the same angle in degrees
  • doppler_factor photon energy ratio E'/E

Applies when

  • 0 <= theta <= 180 deg
  • |v| < c

Example

m.ask("Aberration of light: theta = 90 deg, v = 0.6 c")
→ theta_prime = 2.2143 rad, theta_prime_deg = 126.87, doppler_factor = 1.25
Relativistic Doppler shiftrelativistic_doppler

The observed frequency of light from a source approaching or receding at speed v (along the line of sight).

f_{obs} = f\sqrt{\frac{1 \pm \beta}{1 \mp \beta}}

Inputs

  • f frequency in the source frame [Hz]
  • v relative speed (may be a fraction of c) [m/s]
  • motion whether source and observer approach or recede choice

Returns

  • f_obs observed frequency [Hz]
  • ratio f_obs / f
  • z redshift z = f/f_obs - 1 (negative for a blueshift)

Applies when

  • f > 0
  • 0 <= v < c

Example

m.ask("Relativistic Doppler shift: f = 1e14 Hz, v = 0.6 c, motion = approaching")
→ f_obs = 2e+14 Hz, ratio = 2, z = -0.5
Relativistic energy from momentumrelativistic_energy_from_momentum

Total and kinetic energy and speed of a particle of mass m with momentum p, from E^2 = (pc)^2 + (mc^2)^2.

E^2 = (pc)^2 + (mc^2)^2

Inputs

  • m rest mass [kg]
  • p momentum [kg*m/s]

Returns

  • E total energy [J]
  • K kinetic energy [J]
  • v speed [m/s]
  • beta v/c
  • gamma Lorentz factor
  • E_MeV total energy in MeV [MeV]
  • K_MeV kinetic energy in MeV [MeV]

Applies when

  • m > 0
  • p >= 0

Example

m.ask("Relativistic energy from momentum: m = 1 kg, p = 224844343.5 kg*m/s")
→ E = 1.12344e+17 J, K = 2.24689e+16 J, v = 1.79875e+08 m/s, beta = 0.6, gamma = 1.25, E_MeV = 7.01199e+29 MeV, K_MeV = 1.4024e+29 MeV
Relativistic momentum and energyrelativistic_momentum_energy

Momentum p = gamma m v, total energy E = gamma m c^2, kinetic energy (gamma - 1) m c^2 and rest energy of a mass m at speed v.

p = \gamma m v,\quad E = \gamma m c^2,\quad K = (\gamma - 1) m c^2

Inputs

  • m rest mass [kg]
  • v speed (may be written as a fraction of c) [m/s]

Returns

  • p relativistic momentum [kg*m/s]
  • E total energy [J]
  • K kinetic energy [J]
  • E0 rest energy m c^2 [J]
  • gamma Lorentz factor
  • E_MeV total energy in MeV [MeV]
  • K_MeV kinetic energy in MeV [MeV]
  • pc_MeV momentum times c in MeV [MeV]

Applies when

  • m > 0
  • 0 <= v < c

Example

m.ask("Relativistic momentum and energy: m = 1 kg, v = 0.8 c")
→ p = 3.99723e+08 kg*m/s, E = 1.49793e+17 J, K = 5.9917e+16 J, E0 = 8.98755e+16 J, gamma = 1.66667, E_MeV = 9.34931e+29 MeV, K_MeV = 3.73973e+29 MeV, pc_MeV = 7.47945e+29 MeV
Relativistic velocity additionrelativistic_velocity_addition

The velocity u = (u' + v)/(1 + u'v/c^2) of an object moving at u' in a frame that moves at v (signed, along x).

u = \frac{u' + v}{1 + u'v/c^2}

Inputs

  • u_prime velocity of the object in the moving frame (signed; may be a fraction of c) [m/s]
  • v velocity of the moving frame (signed; may be a fraction of c) [m/s]

Returns

  • u velocity of the object in the rest frame [m/s]
  • beta u/c

Applies when

  • |u'| <= c
  • |v| < c

Example

m.ask("Velocity addition: u_prime = 0.5 c, v = 0.5 c")
→ u = 2.39834e+08 m/s, beta = 0.8
Rest energy (mass-energy equivalence)rest_energy

The rest energy E = m c^2 of a mass m, in J, MeV and kWh.

E_0 = m c^2

Inputs

  • m rest mass (kg, g ...) [kg]

Returns

  • E rest energy in J [J]
  • E_MeV rest energy in MeV [MeV]
  • E_kWh rest energy in kWh

Applies when

  • m > 0

Example

m.ask("Rest energy: m = 9.1093837139e-31 kg")
→ E = 8.18711e-14 J, E_MeV = 0.510999 MeV, E_kWh = 2.2742e-20
Spacetime interval between two eventsspacetime_interval

The invariant interval s^2 = (c dt)^2 - dx^2 between two events, its type, and the proper time or proper distance.

s^2 = (c\,\Delta t)^2 - \Delta x^2

Inputs

  • dt time between the events (signed) [s]
  • dx distance between the events along x (signed) [m]

Returns

  • s2 interval s^2 = (c dt)^2 - dx^2 [m^2]
  • nature timelike, spacelike or lightlike
  • tau proper time (timelike; else 0) [s]
  • proper_length proper distance (spacelike; else 0) [m]

Applies when

  • the events are distinct

Example

m.ask("Spacetime interval: dt = 5 s, dx = 899377374 m")
→ s2 = 1.43801e+18 m^2, nature = timelike, tau = 4 s, proper_length = 0 m
Speed from relativistic kinetic energyrelativistic_speed_from_kinetic_energy

The speed, Lorentz factor and momentum of a particle of mass m with kinetic energy K.

\gamma = 1 + \frac{K}{mc^2},\quad v = c\sqrt{1 - 1/\gamma^2}

Inputs

  • m rest mass [kg]
  • K kinetic energy (J, eV, MeV ...) [J]

Returns

  • v speed [m/s]
  • beta v/c
  • gamma Lorentz factor
  • p momentum [kg*m/s]
  • pc_MeV momentum times c in MeV [MeV]

Applies when

  • m > 0
  • K >= 0

Example

m.ask("Speed from kinetic energy: m = 1 kg, K = 22468879468420441 J")
→ v = 1.79875e+08 m/s, beta = 0.6, gamma = 1.25, p = 2.24844e+08 kg*m/s, pc_MeV = 4.20719e+29 MeV
Time dilationtime_dilation

The time t = gamma t0 between two ticks of a clock that moves at speed v, given its proper time t0.

\Delta t = \gamma\,\Delta t_0 = \frac{\Delta t_0}{\sqrt{1 - v^2/c^2}}

Inputs

  • t0 proper time (measured by the moving clock) [s]
  • v speed of the clock (may be written as a fraction of c) [m/s]

Returns

  • t dilated time measured in the frame where the clock moves [s]
  • gamma Lorentz factor
  • difference t - t0 [s]

Applies when

  • t0 > 0
  • 0 <= v < c

Example

m.ask("Time dilation: t0 = 1 s, v = 0.6 c")
→ t = 1.25 s, gamma = 1.25, difference = 0.25 s

Spin and qubits 8

CHSH Bell-test value for the singlet statechsh_bell_test

Correlations E(a, b) = -cos(a - b) of spin measurements on a singlet pair and the CHSH combination S = E(a,b) - E(a,b') + E(a',b) + E(a',b').

S = E(a,b) - E(a,b') + E(a',b) + E(a',b'),\quad E(x,y) = -\cos(x - y)

Inputs

  • a Alice's first setting (angle in the x-z plane) [rad]
  • a2 Alice's second setting a' [rad]
  • b Bob's first setting [rad]
  • b2 Bob's second setting b' [rad]

Returns

  • S CHSH value
  • abs_S |S| (local hidden variables allow at most 2)
  • E_ab E(a, b)
  • E_ab2 E(a, b')
  • E_a2b E(a', b)
  • E_a2b2 E(a', b')
  • violates whether |S| exceeds 2

Applies when

  • the spin singlet state
  • measurement directions in one plane

Example

m.ask("CHSH: a = 0 deg, a2 = 90 deg, b = 45 deg, b2 = 135 deg")
→ S = -2.82843, abs_S = 2.82843, E_ab = -0.707107, E_ab2 = 0.707107, E_a2b = -0.707107, E_a2b2 = -0.707107, violates = yes
Fidelity and trace distance of two qubit statesqubit_fidelity

The (Uhlmann) fidelity and the trace distance between two qubit states given by their Bloch vectors r and s.

F = \tfrac12\left[1 + \vec r\cdot\vec s + \sqrt{(1 - |\vec r|^2)(1 - |\vec s|^2)}\right]

Inputs

  • r Bloch vector of the first state vector
  • s Bloch vector of the second state vector

Returns

  • F fidelity (Tr sqrt(sqrt(rho) sigma sqrt(rho)))^2
  • sqrt_F root fidelity
  • trace_distance trace distance |r - s|/2

Applies when

  • |r|, |s| <= 1

Example

m.ask("Qubit fidelity: r = 0, 0, 1; s = 1, 0, 0")
→ F = 0.5, sqrt_F = 0.707107, trace_distance = 0.707107
Larmor precession of a spin-1/2larmor_precession

Larmor angular frequency of an electron or proton spin in a field B, and the spin component along x after time t for a spin starting along +x.

\omega_L = |\gamma| B,\quad P_{+x}(t) = \cos^2\!\left(\tfrac{\omega_L t}{2}\right)

Inputs

  • particle the spin-1/2 particle choice
  • B magnetic field along z [T]
  • t time since the spin pointed along +x [s]

Returns

  • omega_L Larmor angular frequency |gamma| B [rad/s]
  • f_L Larmor frequency [Hz]
  • Sx_mean <sigma_x> at time t (mean spin along x in units of hbar/2)
  • P_plus_x probability of measuring spin up along +x at time t

Applies when

  • B > 0
  • t >= 0

Example

m.ask("Larmor precession: particle = proton, B = 1 T, t = 0 s")
→ omega_L = 2.67522e+08 rad/s, f_L = 4.25775e+07 Hz, Sx_mean = 1, P_plus_x = 1
Purity and entropy of a qubit statequbit_entropy_purity

Purity Tr(rho^2), von Neumann entropy (bits) and eigenvalues of the qubit density matrix with Bloch vector r.

\rho = \tfrac12(I + \vec r\cdot\vec\sigma),\quad S = -\sum_i \lambda_i\log_2\lambda_i

Inputs

  • r Bloch vector (rx, ry, rz), length at most 1 vector

Returns

  • length |r|
  • purity Tr(rho^2) = (1 + |r|^2)/2
  • S_bits von Neumann entropy in bits
  • lambda_max larger eigenvalue (1 + |r|)/2
  • lambda_min smaller eigenvalue (1 - |r|)/2

Applies when

  • |r| <= 1

Example

m.ask("Qubit entropy: r = 0.6, 0, 0")
→ length = 0.6, purity = 0.68, S_bits = 0.721928, lambda_max = 0.8, lambda_min = 0.2
Qubit state on the Bloch spherequbit_state_bloch

Normalised measurement probabilities, Bloch vector, and Bloch angles of the qubit state alpha|0> + beta|1> (amplitudes need not be normalised).

|\psi\rangle = \cos\tfrac{\theta}{2}|0\rangle + e^{i\phi}\sin\tfrac{\theta}{2}|1\rangle

Inputs

  • a_re real part of alpha
  • a_im imaginary part of alpha
  • b_re real part of beta
  • b_im imaginary part of beta

Returns

  • p0 probability of 0
  • p1 probability of 1
  • x Bloch x = <sigma_x>
  • y Bloch y = <sigma_y>
  • z Bloch z = <sigma_z>
  • theta polar angle (rad) [rad]
  • phi azimuth in [0, 2 pi) (0 when one amplitude is zero) [rad]
  • norm norm of the given amplitudes

Applies when

  • not both amplitudes zero

Example

m.ask("Qubit state: a_re = 0.6, a_im = 0, b_re = 0, b_im = 0.8")
→ p0 = 0.36, p1 = 0.64, x = 0, y = 0.96, z = -0.28, theta = 1.85459 rad, phi = 1.5708 rad, norm = 1
Rabi oscillation of a driven two-level systemrabi_oscillation

The probability of finding a two-level system (qubit) excited after driving it for time t with Rabi frequency Omega and detuning Delta.

P_e(t) = \frac{\Omega^2}{\Omega^2 + \Delta^2}\sin^2\!\left(\frac{\sqrt{\Omega^2 + \Delta^2}\,t}{2}\right)

Inputs

  • Omega Rabi angular frequency [rad/s]
  • Delta detuning (drive minus transition angular frequency) [rad/s]
  • t driving time [s]

Returns

  • P_excited excited-state probability
  • W generalised Rabi frequency sqrt(Omega^2 + Delta^2) [rad/s]
  • P_max largest excitation probability Omega^2/W^2
  • period oscillation period 2 pi/W [s]

Applies when

  • Omega > 0
  • t >= 0
  • rotating-wave approximation, starting in the ground state

Example

m.ask("Rabi oscillation: Omega = 1e6 rad/s, Delta = 0 rad/s, t = 1.5707963267948966 us")
→ P_excited = 0.5, W = 1e+06 rad/s, P_max = 1, period = 6.28319e-06 s
Spin rotation amplitude (Wigner small-d matrix)spin_rotation_wigner_d

The amplitude d^j_{m'm}(beta) = <j m'| exp(-i beta J_y/hbar) |j m> and the probability of finding m' after rotating |j m> by beta about y.

d^j_{m'm}(\beta) = \langle j m'|e^{-i\beta J_y/\hbar}|j m\rangle

Inputs

  • j angular momentum quantum number (whole or half-whole, at most 20)
  • mp final projection m'
  • m initial projection m
  • beta rotation angle about the y axis (deg or rad) [rad]

Returns

  • d Wigner small-d matrix element
  • probability probability |d|^2 of measuring m' along the original axis

Applies when

  • |m|, |m'| <= j
  • j <= 20

Example

m.ask("Spin rotation amplitude: j = 0.5, mp = 0.5, m = 0.5, beta = 90 deg")
→ d = 0.707107, probability = 0.5
Spin-1/2 measurement along an axisspin_half_measurement

Probabilities of spin up and down along a direction n (angles theta_n, phi_n) for a spin-1/2 state pointing along (theta, phi) on the Bloch sphere.

P_\uparrow = |\langle +_n|\psi\rangle|^2 = \tfrac12\left(1 + \hat r\cdot\hat n\right)

Inputs

  • theta polar angle of the state's Bloch vector [rad]
  • phi azimuth of the state's Bloch vector [rad]
  • theta_n polar angle of the measurement axis [rad]
  • phi_n azimuth of the measurement axis [rad]

Returns

  • P_up probability of +hbar/2 along n
  • P_down probability of -hbar/2 along n
  • expectation <sigma_n> (the mean spin along n in units of hbar/2)

Applies when

  • polar angles between 0 and 180 degrees

Example

m.ask("Spin measurement: theta = 60 deg, phi = 0 deg, theta_n = 0 deg, phi_n = 0 deg")
→ P_up = 0.75, P_down = 0.25, expectation = 0.5

Statistical physics 15

Bose-Einstein condensation temperaturebec_critical_temperature

The critical temperature below which an ideal Bose gas of density n and particle mass m forms a condensate.

T_c = \frac{2\pi\hbar^2}{m k_B}\left(\frac{n}{\zeta(3/2)}\right)^{2/3}

Inputs

  • n particle density [1/m^3]
  • m particle mass [kg]

Returns

  • T_c critical temperature [K]
  • lambda_c thermal wavelength at T_c [m]
  • n_lambda3 phase-space density at T_c, zeta(3/2)

Applies when

  • n > 0
  • m > 0
  • ideal gas, spin 0, uniform box

Example

m.ask("Condensation temperature: n = 1e20 m^-3, m = 1.443e-25 kg")
→ T_c = 3.98375e-07 K, lambda_c = 2.96719e-07 m, n_lambda3 = 2.61238
Bose-Einstein occupation of a modebose_einstein_occupation

The mean number of bosons in a single-particle state of energy E at temperature T and chemical potential mu (mu < E).

\bar n(E) = \frac{1}{e^{(E - \mu)/k_BT} - 1}

Inputs

  • E energy of the state [J]
  • mu chemical potential (0 for photons and phonons) [J]
  • T temperature [K]

Returns

  • n mean occupation 1/(e^x - 1)
  • x (E - mu)/kT
  • classical_limit Maxwell-Boltzmann value e^(-x)

Applies when

  • T > 0
  • E > mu

Example

m.solve("bose_einstein_occupation", E=2.870978885078724e-21, mu=0.0, T=300.0)
→ n = 1, x = 0.693147, classical_limit = 0.5
Chemical potential of an ideal Fermi gasfermi_gas_chemical_potential

The chemical potential of an ideal spin-1/2 Fermi gas of density n and particle mass m at temperature T, from degenerate to classical.

n = \frac{2}{\lambda_{th}^3}\,f_{3/2}\!\left(e^{\mu/k_BT}\right),\quad f_{3/2}(z) = -\mathrm{Li}_{3/2}(-z)

Inputs

  • n particle density [1/m^3]
  • T temperature [K]
  • m particle mass [kg]

Returns

  • mu_eV chemical potential [eV]
  • eta mu/kT
  • E_F_eV Fermi energy at T = 0 [eV]
  • mu_over_EF mu/E_F
  • T_over_TF T/T_F

Applies when

  • n, T, m > 0
  • T >= 0.02 T_F
  • |mu/kT| <= 60

Example

m.solve("fermi_gas_chemical_potential", n=1e+28, T=100000.0, m=9.1093837139e-31)
→ mu_eV = -23.2916 eV, eta = -2.70288, E_F_eV = 1.69253 eV, mu_over_EF = -13.7614, T_over_TF = 5.09139
Debye heat capacity of a soliddebye_heat_capacity

The molar heat capacity of a crystalline solid in the Debye model at temperature T.

C_V = 9R\left(\frac{T}{\Theta_D}\right)^3\int_0^{\Theta_D/T}\frac{x^4 e^x}{(e^x - 1)^2}\,dx

Inputs

  • T temperature [K]
  • theta_D Debye temperature [K]

Returns

  • C_molar molar heat capacity C_V [J/(mol*K)]
  • C_over_3R C_V / 3R (tends to 1 at high T)
  • debye_integral integral_0^(theta/T) x^4 e^x/(e^x - 1)^2 dx

Applies when

  • T > 0
  • theta_D > 0
  • theta_D/T <= 600

Example

m.ask("Debye heat capacity: T = 1 K, theta_D = 500 K")
→ C_molar = 1.55502e-05 J/(mol*K), C_over_3R = 6.23418e-07, debye_integral = 25.9758
Energy and photon density of blackbody radiationphoton_gas

Energy density, photon number density, mean photon energy and radiation pressure of thermal radiation at temperature T.

u = \frac{\pi^2 (k_BT)^4}{15(\hbar c)^3},\quad n = \frac{2\zeta(3)}{\pi^2}\left(\frac{k_BT}{\hbar c}\right)^3

Inputs

  • T temperature [K]

Returns

  • u energy density (J/m^3) [Pa]
  • n photon number density [1/m^3]
  • mean_E_eV mean photon energy [eV]
  • mean_E_over_kT mean photon energy in units of kT (2.701...)
  • pressure radiation pressure u/3 [Pa]

Applies when

  • T > 0

Example

m.ask("Photon gas: T = 2.725 K")
→ u = 4.17174e-14 Pa, n = 4.10501e+08 1/m^3, mean_E_eV = 0.000634297 eV, mean_E_over_kT = 2.70118, pressure = 1.39058e-14 Pa
Fermi energy of a free-electron gasfermi_energy_free_electrons

Fermi energy, temperature, wavenumber and speed of a free-electron gas with electron density n.

E_F = \frac{\hbar^2}{2m_e}\left(3\pi^2 n\right)^{2/3}

Inputs

  • n conduction-electron density (per m^3) [1/m^3]

Returns

  • E_F_eV Fermi energy [eV]
  • E_F Fermi energy in J [J]
  • T_F Fermi temperature E_F/k [K]
  • k_F Fermi wavenumber (3 pi^2 n)^(1/3) [1/m]
  • v_F Fermi speed [m/s]

Applies when

  • n > 0
  • free electrons with spin 1/2, T = 0

Example

m.ask("Fermi energy: n = 8.47e28 m^-3")
→ E_F_eV = 7.03276 eV, E_F = 1.12677e-18 J, T_F = 81611.8 K, k_F = 1.35863e+10 1/m, v_F = 1.57285e+06 m/s
Fermi energy of a metal from its densityfermi_energy_metal

Conduction-electron density and Fermi energy of a metal from its mass density, molar mass and valence (free-electron model).

n = \frac{z\rho N_A}{M},\quad E_F = \frac{\hbar^2}{2m_e}\left(3\pi^2 n\right)^{2/3}

Inputs

  • rho mass density of the metal [kg/m^3]
  • M molar mass (g/mol or kg/mol) [kg/mol]
  • z conduction electrons per atom (valence) integer

Returns

  • n conduction-electron density [1/m^3]
  • E_F_eV Fermi energy [eV]
  • T_F Fermi temperature [K]
  • v_F Fermi speed [m/s]

Applies when

  • rho, M > 0
  • z >= 1

Example

m.ask("Fermi energy of a metal: rho = 8960 kg/m^3, M = 63.546 g/mol, z = 1")
→ n = 8.49123e+28 1/m^3, E_F_eV = 7.04451 eV, T_F = 81748.1 K, v_F = 1.57417e+06 m/s
Fermi-Dirac occupation of a statefermi_dirac_occupation

The probability that a single-particle state of energy E is occupied by a fermion at temperature T and chemical potential mu.

f(E) = \frac{1}{e^{(E - \mu)/k_BT} + 1}

Inputs

  • E energy of the state [J]
  • mu chemical potential (Fermi level) [J]
  • T temperature [K]

Returns

  • f occupation probability 1/(e^x + 1)
  • one_minus_f probability the state is empty
  • x (E - mu)/kT

Applies when

  • T > 0

Example

m.ask("Fermi-Dirac occupation: E = 5 eV, mu = 5 eV, T = 300 K")
→ f = 0.5, one_minus_f = 0.5, x = 0
Fraction of blackbody radiation in a wavelength bandblackbody_band_fraction

The fraction of a blackbody's emitted power between two wavelengths at temperature T, and that band's radiant exitance.

F_{0\to\lambda} = \frac{15}{\pi^4}\int_{hc/\lambda k_BT}^{\infty}\frac{t^3}{e^t - 1}\,dt

Inputs

  • lam1 shorter wavelength [m]
  • lam2 longer wavelength [m]
  • T temperature [K]

Returns

  • F_band fraction of the total emission between lambda1 and lambda2
  • F_below_lam1 fraction emitted below lambda1
  • F_below_lam2 fraction emitted below lambda2
  • M_band radiant exitance in the band (blackbody) [W/m^2]

Applies when

  • 0 < lambda1 < lambda2
  • T > 0

Example

m.solve("blackbody_band_fraction", lam1=1e-12, lam2=1.0, T=5778.0)
→ F_band = 1, F_below_lam1 = 0, F_below_lam2 = 1, M_band = 6.32007e+07 W/m^2
Peak of blackbody radiation (Wien's displacement law)wien_peak

The wavelength and frequency at which a blackbody at temperature T radiates most strongly.

\lambda_{max} T = b = \frac{hc}{4.965\,k_B}

Inputs

  • T temperature of the blackbody [K]

Returns

  • lambda_max peak wavelength (of B_lambda) [m]
  • lambda_max_nm peak wavelength in nm [nm]
  • nu_max peak frequency (of B_nu; not c/lambda_max) [Hz]
  • b Wien's constant b = hc/(x k) [m*K]

Applies when

  • T > 0

Example

m.ask("Wien's displacement law: T = 5778 K")
→ lambda_max = 5.01518e-07 m, lambda_max_nm = 501.518 nm, nu_max = 3.39684e+14 Hz, b = 0.00289777 m*K
Quantum oscillator thermodynamics (Einstein model)einstein_oscillator

Mean quantum number, mean energy, heat capacity and entropy of a quantum harmonic oscillator, and the molar heat capacity of an Einstein solid.

C_V = 3R\left(\frac{\Theta_E}{T}\right)^2\frac{e^{\Theta_E/T}}{\left(e^{\Theta_E/T} - 1\right)^2}

Inputs

  • theta_E Einstein temperature hbar omega/k [K]
  • T temperature [K]

Returns

  • n_mean mean number of quanta 1/(e^x - 1)
  • U_eV mean energy including the zero-point energy [eV]
  • C_over_k heat capacity per oscillator in units of k
  • C_molar molar heat capacity of an Einstein solid 3R C/k [J/(mol*K)]
  • S_over_k entropy per oscillator in units of k

Applies when

  • theta_E > 0
  • T > 0

Example

m.ask("Einstein solid: theta_E = 300 K, T = 300 K")
→ n_mean = 0.581977, U_eV = 0.0279713 eV, C_over_k = 0.920674, C_molar = 22.9647 J/(mol*K), S_over_k = 1.04065
Radiated power (Stefan-Boltzmann law)stefan_boltzmann

Radiant exitance and total power emitted by a surface of area A, emissivity e at temperature T.

P = \varepsilon\sigma A T^4,\quad \sigma = \frac{2\pi^5 k_B^4}{15 h^3 c^2}

Inputs

  • T surface temperature [K]
  • emissivity emissivity (1 for a blackbody)
  • A radiating area [m^2]

Returns

  • sigma Stefan-Boltzmann constant 2 pi^5 k^4/(15 h^3 c^2) [W/(m^2*K^4)]
  • M radiant exitance e sigma T^4 [W/m^2]
  • P total radiated power [W]

Applies when

  • T > 0
  • A > 0
  • 0 < emissivity <= 1

Example

m.ask("Stefan-Boltzmann: T = 1000 K, emissivity = 1, A = 1 m^2")
→ sigma = 5.67037e-08 W/(m^2*K^4), M = 56703.7 W/m^2, P = 56703.7 W
Spectral radiance of a blackbody (Planck's law)planck_spectral_radiance

The spectral radiance B_lambda of a blackbody at temperature T and wavelength lambda, and the photon occupation number of that mode.

B_\lambda(T) = \frac{2hc^2}{\lambda^5}\,\frac{1}{e^{hc/(\lambda k_B T)} - 1}

Inputs

  • lam wavelength [m]
  • T temperature [K]

Returns

  • B_lambda spectral radiance (W per m^2 per sr per m of wavelength) [W/m^3]
  • B_lambda_per_nm spectral radiance in W/(m^2 sr nm)
  • occupation mean photon number 1/(e^x - 1)
  • x h c/(lambda k T)

Applies when

  • lambda > 0
  • T > 0

Example

m.ask("Planck's law: lambda = 500 nm, T = 5778 K")
→ B_lambda = 2.63757e+13 W/m^3, B_lambda_per_nm = 26375.7, occupation = 0.00692032, x = 4.98019
Thermal de Broglie wavelengththermal_de_broglie_wavelength

The thermal de Broglie wavelength h/sqrt(2 pi m k T) and the quantum concentration 1/lambda^3.

\lambda_{th} = \frac{h}{\sqrt{2\pi m k_B T}}

Inputs

  • m particle mass [kg]
  • T temperature [K]

Returns

  • lambda_th thermal de Broglie wavelength [m]
  • lambda_th_nm the same in nm [nm]
  • n_Q quantum concentration 1/lambda^3 [1/m^3]

Applies when

  • m > 0
  • T > 0

Example

m.ask("Thermal de Broglie wavelength: m = 9.1093837139e-31 kg, T = 300 K")
→ lambda_th = 4.30348e-09 m, lambda_th_nm = 4.30348 nm, n_Q = 1.25471e+25 1/m^3
Thermodynamics of a two-level systemtwo_level_thermodynamics

Partition function, Boltzmann populations, mean energy, heat capacity (Schottky) and entropy of a two-level system with gap dE and degeneracies g0, g1.

\frac{N_1}{N_0} = \frac{g_1}{g_0}e^{-\Delta E/k_BT},\quad \frac{C}{k_B} = x^2 p_0 p_1

Inputs

  • dE energy gap (eV, J) [J]
  • T temperature [K]
  • g0 degeneracy of the lower level integer
  • g1 degeneracy of the upper level integer

Returns

  • Z partition function g0 + g1 e^(-dE/kT)
  • p0 population of the lower level
  • p1 population of the upper level
  • ratio population ratio N1/N0 (Boltzmann factor)
  • U_eV mean energy above the lower level [eV]
  • C_over_k heat capacity per system in units of k
  • S_over_k entropy per system in units of k

Applies when

  • dE > 0
  • T > 0
  • g0, g1 >= 1

Example

m.ask("Two-level system: dE = 0.025 eV, T = 300 K, g0 = 1, g1 = 1")
→ Z = 1.38021, p0 = 0.72453, p1 = 0.27547, ratio = 0.380206, U_eV = 0.00688676 eV, C_over_k = 0.186648, S_over_k = 0.588624
Questions

Frequently asked

What does quantum-physics-ai999x do?

Quantum Physics answers questions in quantum physics: special relativity, photons and matter waves, the hydrogen atom, quantum wells and tunnelling, spin and qubits, quantum gates, nuclear and particle physics and statistical physics. Each answer gives the value with its unit, the steps and the formula in LaTeX.

How do I install quantum-physics-ai999x?

With pip: pip install quantum-physics-ai999x. The same files are on Hugging Face (hf download AI999X/quantum-physics-ai999x --local-dir quantum-physics-ai999x) and GitHub.

Does it run offline?

Yes. It is a Python package that runs on an ordinary CPU without a network connection (Python >=3.10); no GPU and no API key are needed.

How many capabilities does quantum-physics-ai999x have?

75 capabilities in 11 topics, including Statistical physics, Special relativity, Quantum wells, Spin and qubits, Hydrogen atom.

Which field and tasks does it cover?

Field: Physical Sciences. Tasks: Question Answering, Token Classification, Text Classification, Sentence Similarity, Feature Extraction.

What does an answer look like?

Asked "Lorentz factor: v = 0.8 c", it answers: gamma = 1.66667, beta = 0.8, gamma_minus_1 = 0.666667.

What happens when a question cannot be answered?

It says so and names what is missing or out of range, instead of guessing a number.

More from AI999X

Explore every model.