Posts
Fact checks
Some quantities are stated in more than one post; each has one accepted value, and every post that states it must round to it. Below that are the sentences in the posts that have been fact-checked, each with its verdict. The claims themselves, each checked by a program, are in the Claims channel.
Quantities stated across posts
| Quantity | Accepted value | Stated as | Posts | Agree |
|---|---|---|---|---|
| critical temperature of the square-lattice Ising model, 2/ln(1 + sqrt 2), in J/k_B | 2.269185314213022 | 2.26919, 2.269185314213022 | 1 | 2 / 2 |
| Onsager-Yang spontaneous magnetization at T = 1.8 J/k_B | 0.9568570172474183 | 0.95686, 0.956857 | 1 | 3 / 3 |
| fastest cold-beam two-stream growth rate, 1/(2 sqrt 2), in units of the plasma frequency | 0.3535533905932738 | 0.354, 0.35355, 0.353553 | 2 | 4 / 4 |
| real frequency of the Landau-damped Langmuir root at k lambda_D = 0.5, in omega_p | 1.4156618886045365 | 1.4156618886045364 | 1 | 1 / 1 |
| Landau damping rate at k lambda_D = 0.5, in omega_p | 0.15335946690960484 | 0.1534, 0.15335946690960483 | 1 | 2 / 2 |
| Gibbs overshoot as a fraction of the jump, Si(pi)/pi - 1/2 | 0.08948987223608362 | 8.95%, 0.0895 | 1 | 4 / 4 |
| the hartree in electronvolts | 27.211386245988 | 27.211, 27.2114 | 2 | 2 / 2 |
| the bohr in angstroms | 0.529177210903 | 0.5292 | 1 | 1 / 1 |
| RHF energy of water in 6-31G at the posts' geometry, hartree | -75.98394849810573 | -75.98394849810573 | 2 | 4 / 4 |
| double-precision machine epsilon, 2^-52 | 2.220446049250313e-16 | , | 2 | 3 / 3 |
| double-precision unit roundoff, 2^-53 | 1.1102230246251565e-16 | 1 | 1 / 1 | |
| ln 2 | 0.6931471805599453 | 0.7, 0.693 | 2 | 4 / 4 |
| years to double at 7% compounded once a year, ln 2 / ln 1.07 | 10.244768351058712 | 10.24 | 4 | 5 / 5 |
| years to double at 7% a year compounded monthly, ln 2 / (12 ln(1 + 0.07/12)) | 9.930955714667654 | 9.931 | 2 | 2 / 2 |
| largest mass of a star of free neutrons (Oppenheimer-Volkoff), solar masses | 0.7102 | 0.7102, 0.71, 0.71018029 | 1 | 4 / 4 |
Fact-checked sentences
1071 of 3036 sentences have a verdict (676 verified, 297 not-checkable, 98 plausible); 91 factual sentences and definitions are waiting.
- verified Forward Euler loses the planet
Forward Euler gains energy until the planet is unbound.
Explicit Euler steadily gains energy on the Kepler problem; here the run confirms it ends with E>0.
Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf
- verified Forward Euler loses the planet
Leapfrog's energy error stays under one percent, and it keeps the angular momentum to rounding.
Stormer-Verlet/leapfrog keeps energy bounded near its start and conserves angular momentum exactly for central forces; the 0.74% figure is the run's.
Wikipedia, Leapfrog integration (kick-drift-kick form; second order; symplectic, conserves a modified energy; preserves angular momentum), https://en.wikipedia.org/wiki/Leapfrog_integration; Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf
- not-checkable Forward Euler loses the planet
A planet goes around a sun that sits still at the origin.
Describes the model the program sets up (fixed sun at the origin).
- verified Forward Euler loses the planet
The only force on it is the sun's gravity, which pulls toward the origin, so its acceleration is
Gravity from a fixed point mass is a central attraction toward it.
Wikipedia, Kepler orbit (P = 2pi sqrt(a^3/mu); energy -mu/(2a); angular momentum constant for a central force), https://en.wikipedia.org/wiki/Kepler_orbit
- verified Forward Euler loses the planet
Newton's inverse-square law for a fixed central mass.
Wikipedia, Kepler orbit (P = 2pi sqrt(a^3/mu); energy -mu/(2a); angular momentum constant for a central force), https://en.wikipedia.org/wiki/Kepler_orbit
- not-checkable Forward Euler loses the planet
where is the planet's position, is the gravitational constant and is the sun's mass.
Defines the symbols in the formula.
- verified Forward Euler loses the planet
Kepler's third law then says one orbit takes time units.
P = 2pi sqrt(a^3/mu), which is 2pi for a = GM = 1.
Wikipedia, Kepler orbit (P = 2pi sqrt(a^3/mu); energy -mu/(2a); angular momentum constant for a central force), https://en.wikipedia.org/wiki/Kepler_orbit
- verified Forward Euler loses the planet
The eccentricity
ECCsays how stretched the ellipse is: 0 is a circle, and at 0.6 the closest approach to the sun (the perihelion) is and the farthest point is .Perihelion a(1-e) = 0.4 and aphelion a(1+e) = 1.6 for a = 1, e = 0.6.
Wikipedia, Kepler orbit (P = 2pi sqrt(a^3/mu); energy -mu/(2a); angular momentum constant for a central force), https://en.wikipedia.org/wiki/Kepler_orbit; Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf
- verified Forward Euler loses the planet
With only gravity acting, the planet's energy per unit mass, kinetic plus potential,
Specific orbital energy is kinetic plus potential per unit mass and is conserved.
Wikipedia, Vis-viva equation (v^2 = GM(2/r - 1/a); specific orbital energy -GM/2a), https://en.wikipedia.org/wiki/Vis-viva_equation
- verified Forward Euler loses the planet
Specific energy v^2/2 - GM/r with GM = 1.
Wikipedia, Vis-viva equation (v^2 = GM(2/r - 1/a); specific orbital energy -GM/2a), https://en.wikipedia.org/wiki/Vis-viva_equation
- verified Forward Euler loses the planet
has the same value at every moment of the true motion.
The specific orbital energy is constant along an exact Kepler orbit.
Wikipedia, Kepler orbit (P = 2pi sqrt(a^3/mu); energy -mu/(2a); angular momentum constant for a central force), https://en.wikipedia.org/wiki/Kepler_orbit; Wikipedia, Vis-viva equation (v^2 = GM(2/r - 1/a); specific orbital energy -GM/2a), https://en.wikipedia.org/wiki/Vis-viva_equation
- verified Forward Euler loses the planet
The planet starts at perihelion, at , moving straight up.
Same initial condition as Hairer-Lubich-Wanner's Kepler test: q0 = (1-e, 0), velocity perpendicular, at perihelion.
Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf
- verified Forward Euler loses the planet
It is negative because the planet is bound: it lacks the energy to climb out of the sun's pull.
Negative energy corresponds to a bound elliptical orbit.
Wikipedia, Kepler orbit (P = 2pi sqrt(a^3/mu); energy -mu/(2a); angular momentum constant for a central force), https://en.wikipedia.org/wiki/Kepler_orbit
- verified Forward Euler loses the planet
If a method pushed above zero, the simulated planet would leave and never come back.
E > 0 gives a hyperbolic trajectory that escapes to infinity.
Wikipedia, Kepler orbit (P = 2pi sqrt(a^3/mu); energy -mu/(2a); angular momentum constant for a central force), https://en.wikipedia.org/wiki/Kepler_orbit
- not-checkable Forward Euler loses the planet
A computer cannot follow the motion continuously.
Framing sentence about time stepping.
- not-checkable Forward Euler loses the planet
It jumps ahead by a time step , again and again.
Framing sentence about time stepping.
- verified Forward Euler loses the planet
Forward Euler is the simplest way to make each jump: take the velocity and the acceleration at the start of the step and pretend they stay fixed for the whole step,
Explicit Euler freezes the derivative at the start of the step.
Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf
- verified Forward Euler loses the planet
Explicit Euler for q' = v, v' = a(q).
Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf
- verified Forward Euler loses the planet
At perihelion the velocity points straight up and the pull points straight left, toward the sun.
From (0.4, 0) with velocity (0, 2), the velocity is along +y and the attraction along -x.
Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf
- verified Forward Euler loses the planet
The position update moves the planet along a straight line, up and off the curve, which leaves it a little farther from the sun, so the potential energy rises.
With r perpendicular to v, |r + h v|^2 = r^2 + h^2 v^2 > r^2, so the distance and the potential energy rise.
Direct symbolic expansion (sympy) done in this check; Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf
- verified Forward Euler loses the planet
The velocity update adds a sideways kick at right angles to the velocity, which makes the velocity longer, so the kinetic energy rises too.
With a perpendicular to v, |v + h a|^2 = v^2 + h^2 a^2 > v^2.
Direct symbolic expansion (sympy) done in this check; Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf
- verified Forward Euler loses the planet
Both parts go up.
Follows from the two preceding computations.
Direct symbolic expansion (sympy) done in this check
- verified Forward Euler loses the planet
Leapfrog does the same work per step, one evaluation of the force, in a different order.
Kick-drift-kick needs one new force evaluation per step, the same as Euler.
Wikipedia, Leapfrog integration (kick-drift-kick form; second order; symplectic, conserves a modified energy; preserves angular momentum), https://en.wikipedia.org/wiki/Leapfrog_integration
- verified Forward Euler loses the planet
Matches the kick-drift-kick form of leapfrog.
Wikipedia, Leapfrog integration (kick-drift-kick form; second order; symplectic, conserves a modified energy; preserves angular momentum), https://en.wikipedia.org/wiki/Leapfrog_integration
- not-checkable Forward Euler loses the planet
From the same starting point, one leapfrog step changes the energy by (
leap_one_step_change), 398 times less than Euler's step (step_ratio).Program output; tested (step_ratio 398, leap_one_step_change 1.246e-4).
- not-checkable Forward Euler loses the planet
That is not yet the difference that matters.
Transition.
- not-checkable Forward Euler loses the planet
If each of the 2000 steps added that much, ten orbits would add (
leap_if_errors_added).Run output; 2000 x 0.0001246 = 0.249.
- not-checkable Forward Euler loses the planet
What matters is whether the errors of many steps pile up or cancel.
Transition.
- verified Forward Euler loses the planet
After ten orbits Euler has added (
euler_final), so the planet's energy is (euler_end_energy): positive, which means the simulated planet is no longer in orbit at all.-0.5 + 0.546 = +0.046 > 0, and positive specific energy means an unbound (hyperbolic) path.
Wikipedia, Kepler orbit (P = 2pi sqrt(a^3/mu); energy -mu/(2a); angular momentum constant for a central force), https://en.wikipedia.org/wiki/Kepler_orbit
- not-checkable Forward Euler loses the planet
It is flying away.
Describes the simulated run.
- verified Forward Euler loses the planet
The real planet would go around forever.
An exact two-body Kepler ellipse is periodic.
Wikipedia, Kepler orbit (P = 2pi sqrt(a^3/mu); energy -mu/(2a); angular momentum constant for a central force), https://en.wikipedia.org/wiki/Kepler_orbit
- not-checkable Forward Euler loses the planet
The largest energy error leapfrog makes in ten orbits is (
leap_worst), which is of the orbit's (leap_worst_share) and almost seventy times less than .Program output; 0.003676/0.5 = 0.74% is tested (leap_worst_share), and 0.25/0.003676 = 68 is consistent.
- not-checkable Forward Euler loses the planet
Its errors do not add up.
Describes the run.
- not-checkable Forward Euler loses the planet
That leaves the planet on a larger orbit, one that takes of the original orbits to go around (
euler_orbit_period), so the next close pass to the sun comes near orbit 4.3 on the plot.Program output: euler_orbit_period = 4.3 (shown), and the energy series' second jump is between orbits 4.35 and 4.40 in this run.
- verified Forward Euler loses the planet
Each leapfrog step is the exact motion of a slightly different system, one whose energy function differs from the true by an amount that shrinks with .
Backward error analysis: Stormer-Verlet exactly conserves a modified Hamiltonian H + O(h^2) up to exponentially small terms (GNI Ch. IX).
Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf; Wikipedia, Leapfrog integration (kick-drift-kick form; second order; symplectic, conserves a modified energy; preserves angular momentum), https://en.wikipedia.org/wiki/Leapfrog_integration
- not-checkable Forward Euler loses the planet
A second conserved quantity makes the same point more directly.
Transition.
- verified Forward Euler loses the planet
The angular momentum per unit mass, , is constant for any force that points at the origin.
Angular momentum is conserved for any central force.
Wikipedia, Kepler orbit (P = 2pi sqrt(a^3/mu); energy -mu/(2a); angular momentum constant for a central force), https://en.wikipedia.org/wiki/Kepler_orbit
- verified Forward Euler loses the planet
Leapfrog should keep to rounding error.
Stormer-Verlet conserves angular momentum exactly for central forces, so only rounding remains.
Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf; Wikipedia, Leapfrog integration (kick-drift-kick form; second order; symplectic, conserves a modified energy; preserves angular momentum), https://en.wikipedia.org/wiki/Leapfrog_integration
- verified Forward Euler loses the planet
Euler moves the position and the velocity at the same time, from the old values; working out the product gives a change of per step, which is not zero.
Expanding (x+h vx)(vy+h ay) - (y+h vy)(vx+h ax) gives h(x ay - y ax) + h^2(vx ay - vy ax); the first term vanishes for a central force.
Direct symbolic expansion (sympy) done in this check
- not-checkable Forward Euler loses the planet
Leapfrog's drift is at the level of rounding error, (
momentum_drift), and the test holds it under .Program output: momentum_drift = 2.89e-15, tested under 1e-12.
- verified Forward Euler loses the planet
A method is order p if its error shrinks like : halve the step and the error drops by a factor of .
Standard definition of order p (global error O(h^p)).
Hairer, Lubich & Wanner, Geometric Numerical Integration, 2nd ed. (Springer 2006), Ch. I.2 (Kepler problem, e=0.6, q0=(1-e,0), p0=(0,sqrt((1+e)/(1-e))), period 2pi); lecture intro read at https://www.unige.ch/~hairer/poly_geoint/intro.pdf
- not-checkable Forward Euler loses the planet
The cell below runs leapfrog again with 400 steps per orbit and measures from the two worst errors:
Describes the program.
- not-checkable Forward Euler loses the planet
Formula the program uses to estimate the order.
- not-checkable Forward Euler loses the planet
leapfrog's error sits near 0.0036 for most of each orbit
Describes this program's test: the median of the 200 leapfrog samples is 0.003556 and 74% of them are within 5e-5 of it.
- verified The Gibbs overshoot never shrinks
Its Fourier series is : odd harmonics only, falling off like .
The square wave's series is 4/pi sum sin((2k-1)x)/(2k-1), odd harmonics with 1/k coefficients.
Wikipedia, Square wave: Fourier series 4/pi sum sin((2k-1)x)/(2k-1), odd harmonics only, https://en.wikipedia.org/wiki/Square_wave_(waveform)
- verified The Gibbs overshoot never shrinks
The sum of the first odd harmonics has its first peak at exactly , where the derivative first vanishes.
The derivative is 4/pi sum cos((2j+1)x) = (2/pi) sin(2mx)/sin x, first zero at x = pi/(2m); the peak sum is the midpoint rule for (2/pi) Si(pi) = 1.178980.
Wikipedia, Gibbs phenomenon (overshoot 0.089489872... of the jump; Wilbraham-Gibbs constant Si(pi)=1.851937...; first maximum at x0 + L/(2N); Fejer/sigma-approximation), https://en.wikipedia.org/wiki/Gibbs_phenomenon; Direct symbolic expansion (sympy) done in this check
- verified The Gibbs overshoot never shrinks
The overshoot is , which is of the jump from to .
The overshoot (2/pi)Si(pi) - 1 = 0.17898 is 0.0894899 of the jump of 2.
Wikipedia, Gibbs phenomenon (overshoot 0.089489872... of the jump; Wilbraham-Gibbs constant Si(pi)=1.851937...; first maximum at x0 + L/(2N); Fejer/sigma-approximation), https://en.wikipedia.org/wiki/Gibbs_phenomenon
- verified The Gibbs overshoot never shrinks
The peak sits at and is about that wide, so as grows it carries less and less area.
The first maximum is at L/(2N) from the jump and moves in as N grows, so its area shrinks.
Wikipedia, Gibbs phenomenon (overshoot 0.089489872... of the jump; Wilbraham-Gibbs constant Si(pi)=1.851937...; first maximum at x0 + L/(2N); Fejer/sigma-approximation), https://en.wikipedia.org/wiki/Gibbs_phenomenon
- verified The Gibbs overshoot never shrinks
In the mean-square sense the series converges: the integral of the squared error goes to zero.
The square wave is in L^2, so its Fourier series converges in mean square (Parseval).
Wikipedia, Gibbs phenomenon (overshoot 0.089489872... of the jump; Wilbraham-Gibbs constant Si(pi)=1.851937...; first maximum at x0 + L/(2N); Fejer/sigma-approximation), https://en.wikipedia.org/wiki/Gibbs_phenomenon; Wikipedia, Square wave: Fourier series 4/pi sum sin((2k-1)x)/(2k-1), odd harmonics only, https://en.wikipedia.org/wiki/Square_wave_(waveform)
- plausible The Gibbs overshoot never shrinks
But at the peak itself the error stays for every .
The peak error tends to 0.179 but is larger for small m (0.273 at m = 1, 0.182 at m = 5, 0.1798 at m = 10, computed here); 'stays near 0.179 however large m is' would be exact.
Wikipedia, Gibbs phenomenon (overshoot 0.089489872... of the jump; Wilbraham-Gibbs constant Si(pi)=1.851937...; first maximum at x0 + L/(2N); Fejer/sigma-approximation), https://en.wikipedia.org/wiki/Gibbs_phenomenon; Direct symbolic expansion (sympy) done in this check
- verified The Gibbs overshoot never shrinks
That is the difference between convergence in and uniform convergence, and a square wave, being discontinuous, has the first without the second.
A uniform limit of continuous partial sums would be continuous, so a discontinuous wave gives L^2 convergence without uniform convergence.
Wikipedia, Gibbs phenomenon (overshoot 0.089489872... of the jump; Wilbraham-Gibbs constant Si(pi)=1.851937...; first maximum at x0 + L/(2N); Fejer/sigma-approximation), https://en.wikipedia.org/wiki/Gibbs_phenomenon
- verified The Gibbs overshoot never shrinks
A smoothing filter (Fejér, Lanczos) trades the spike for a slower approach to the wave; nothing that keeps the partial sums as they are removes it.
Fejer summation (a positive kernel) removes the overshoot and Lanczos sigma factors reduce it.
Wikipedia, Gibbs phenomenon (overshoot 0.089489872... of the jump; Wilbraham-Gibbs constant Si(pi)=1.851937...; first maximum at x0 + L/(2N); Fejer/sigma-approximation), https://en.wikipedia.org/wiki/Gibbs_phenomenon; Wikipedia, Square wave: Fourier series 4/pi sum sin((2k-1)x)/(2k-1), odd harmonics only, https://en.wikipedia.org/wiki/Square_wave_(waveform)
- not-checkable The Gibbs overshoot never shrinks
The peak of a thousand harmonics, summed directly, matches the integral computed by Simpson's rule with 2000 panels to a millionth.
Describes the program's check; I computed that the m = 1000 peak differs from (2/pi)Si(pi) by 8.3e-8, consistent with it.
- not-checkable Which root does Newton's method find?
Near a root the answer is obvious.
Rhetorical lead-in.
- verified Which root does Newton's method find?
Along the lines between them it is a fractal: every boundary point touches all three basins.
The basins share a common boundary, the Julia set, and each point of it is an accumulation point of all three basins (Wada property).
Wikipedia, Newton fractal (the Fatou sets share a common boundary, the Julia set; each Julia-set point is an accumulation point of every basin), https://en.wikipedia.org/wiki/Newton_fractal
- verified Which root does Newton's method find?
Newton's step for is .
z - (z^3-1)/(3z^2) = (2z^3+1)/(3z^2) by direct algebra.
Wikipedia, Newton fractal (the Fatou sets share a common boundary, the Julia set; each Julia-set point is an accumulation point of every basin), https://en.wikipedia.org/wiki/Newton_fractal; Direct symbolic expansion (sympy) done in this check
- not-checkable How far a finite-difference Hamiltonian's levels sit below n + 1/2
How low is predictable.
Transition.
- verified How far a finite-difference Hamiltonian's levels sit below n + 1/2
The three-point second difference is , so the grid Hamiltonian is the true one plus .
The truncation term (h^2/12) f'''' gives -1/2 D2 = -1/2 d^2 - (h^2/24) d^4, and d^4 = p^4.
Central second difference: [f(x+h)-2f(x)+f(x-h)]/h^2 = f'' + (h^2/12) f'''' + O(h^4), Langtangen, Truncation Error Analysis (INF5620 notes), http://hplgit.github.io/INF5620/doc/pub/H14/trunc/html/._main_trunc001.html (via search summary)
- verified How far a finite-difference Hamiltonian's levels sit below n + 1/2
To first order the level moves by the expectation of that, and for the oscillator .
<n|p^4|n> = (3/4)(2n^2+2n+1); I computed the diagonal of p^4 with ladder-operator matrices for n = 0..5, and it matches.
<n|x^4|n> = (3/4)(hbar/m omega)^2 (2n^2+2n+1), confirmed numerically with ladder-operator matrices in this check; by x<->p symmetry of H the same holds for p^4 in units m=omega=hbar=1
- plausible How far a finite-difference Hamiltonian's levels sit below n + 1/2
The grid's error is a small perturbation of the Hamiltonian, so the perturbation theory used for the Stark shift predicts it.
The first-order shift -(h^2/24)(3/4)(2n^2+2n+1) = -(h^2/32)(2n^2+2n+1) follows; first-order perturbation theory is standard (e.g. Griffiths, Introduction to QM, Ch. 7), not accessed; from general knowledge.
Central second difference: [f(x+h)-2f(x)+f(x-h)]/h^2 = f'' + (h^2/12) f'''' + O(h^4), Langtangen, Truncation Error Analysis (INF5620 notes), http://hplgit.github.io/INF5620/doc/pub/H14/trunc/html/._main_trunc001.html (via search summary); <n|x^4|n> = (3/4)(hbar/m omega)^2 (2n^2+2n+1), confirmed numerically with ladder-operator matrices in this check; by x<->p symmetry of H the same holds for p^4 in units m=omega=hbar=1
- verified Pi from escape counts at the cusp of the Mandelbrot set
It tends to .
The pi-Theorem: lim sqrt(eps) N(eps) = pi for c = 1/4 + eps.
Klebanoff, 'pi in the Mandelbrot set', Fractals 9(4) (2001) 393-402, p. 395 pi-Theorem and Lemma 1 (dx/dt = (x-1/2)^2 + eps near the tangent fixed point x=1/2 of x^2+1/4), https://www.doc.ic.ac.uk/~jb/teaching/jmc/pi-in-mandelbrot.pdf
- verified Pi from escape counts at the cusp of the Mandelbrot set
At the map has a fixed point at where its slope is exactly 1, and the orbit from climbs toward it in ever smaller steps without ever passing it.
At c = 1/4 the graph of x^2 + 1/4 touches y = x at x = 1/2 (slope 1), and the orbit of 0 increases monotonically toward it.
Klebanoff, 'pi in the Mandelbrot set', Fractals 9(4) (2001) 393-402, p. 395 pi-Theorem and Lemma 1 (dx/dt = (x-1/2)^2 + eps near the tangent fixed point x=1/2 of x^2+1/4), https://www.doc.ic.ac.uk/~jb/teaching/jmc/pi-in-mandelbrot.pdf
- verified Pi from escape counts at the cusp of the Mandelbrot set
Raise by and the fixed point disappears, but near each step still moves only a little.
For eps > 0 there is no real fixed point, but most iterations are close to x = 1/2.
Klebanoff, 'pi in the Mandelbrot set', Fractals 9(4) (2001) 393-402, p. 395 pi-Theorem and Lemma 1 (dx/dt = (x-1/2)^2 + eps near the tangent fixed point x=1/2 of x^2+1/4), https://www.doc.ic.ac.uk/~jb/teaching/jmc/pi-in-mandelbrot.pdf
- verified Pi from escape counts at the cusp of the Mandelbrot set
The number of steps to get through is .
Lemma 1: the continuous passage time satisfies sqrt(eps) T(eps) -> pi, i.e. the integral of dw/(w^2+eps) is pi/sqrt(eps).
Klebanoff, 'pi in the Mandelbrot set', Fractals 9(4) (2001) 393-402, p. 395 pi-Theorem and Lemma 1 (dx/dt = (x-1/2)^2 + eps near the tangent fixed point x=1/2 of x^2+1/4), https://www.doc.ic.ac.uk/~jb/teaching/jmc/pi-in-mandelbrot.pdf
- verified The Runge phenomenon, where more points give a worse fit
Interpolate by a polynomial through equally spaced points and the error grows as you add points.
The classic Runge example: equispaced interpolation of 1/(1+25x^2) diverges near the ends.
Wikipedia, Runge's phenomenon (1/(1+25x^2) at equispaced nodes diverges; Lebesgue constant grows exponentially; Chebyshev nodes converge), https://en.wikipedia.org/wiki/Runge%27s_phenomenon
- verified The Runge phenomenon, where more points give a worse fit
The function has poles at .
1 + 25x^2 = 0 at x = +-i/5.
Wikipedia, Runge's phenomenon (1/(1+25x^2) at equispaced nodes diverges; Lebesgue constant grows exponentially; Chebyshev nodes converge), https://en.wikipedia.org/wiki/Runge%27s_phenomenon
- verified The Runge phenomenon, where more points give a worse fit
Polynomial interpolation in Chebyshev points converges like , where is the size of the largest ellipse with foci that the function is analytic inside.
Here 'size' means rho, the sum of the ellipse's semi-axes.
Trefethen, ATAP, Theorem 8.2 (Chebyshev interpolants of functions analytic in the Bernstein ellipse E_rho, foci +-1, semi-axes summing to rho, converge as O(rho^-n)); confirmed via search summary, https://people.maths.ox.ac.uk/~trefethen/trefethen_sample.pdf
- verified The Runge phenomenon, where more points give a worse fit
Both interpolants use the barycentric formula, which is stable in Chebyshev points.
Replaces disputed 1253cbdbe71f. The claim is now limited to Chebyshev points, where ATAP says the formula is stable.
Trefethen, Approximation Theory and Approximation Practice, Ch. 5, p. 37 (read from the PDF): barycentric interpolation in Chebyshev points 'is numerically stable'; (5.9) and (5.11)-(5.13) 'proved stable in floating point arithmetic for all x in [-1, 1]' [Rack & Reimer 1982, Higham 2004], https://people.maths.ox.ac.uk/trefethen/ATAP/ATAPfirst6chapters.pdf; posts/2026-09-21-runge-phenomenon.viv interpolate(): the second-kind formula sum(w f/(x-xj)) / sum(w/(x-xj))
- verified The Runge phenomenon, where more points give a worse fit
With equally spaced points the problem is ill-conditioned (its Lebesgue constant grows exponentially with ), and this formula adds rounding error of its own.
Replaces disputed 1253cbdbe71f. The program uses the second-kind formula (5.11) with equispaced weights (-1)^j C(n,j), so it adds error of its own on top of an exponentially ill-conditioned problem.
Trefethen, ATAP Ch. 5, p. 37: (5.11) 'is unstable even for interpolation when used with arbitrary points rather than points suitably clustered like Chebyshev points'; 'important to use (5.9) rather than (5.11) for computing interpolants through equispaced points', where 'the problem is probably so ill-conditioned', https://people.maths.ox.ac.uk/trefethen/ATAP/ATAPfirst6chapters.pdf; Chebfun example 'Lebesgue functions and Lebesgue constants' (read), after ATAP Ch. 15: 'for n equispaced points it is 2^n/(e n log(n))', https://www.chebfun.org/examples/approx/LebesgueConst.html
- not-checkable The eigenvalues of a random matrix fill Wigner's semicircle
They do not scatter.
Rhetorical lead-in.
- verified The eigenvalues of a random matrix fill Wigner's semicircle
They fill the semicircle , whatever distribution the entries came from.
Wigner's law holds for iid mean-zero entries of variance 1 (with mild moment conditions), with limit (1/2pi)sqrt(4-x^2); the next sentence says only the variance matters.
Petrov, Lectures on Random Matrices (2025), Lecture 2, Sec. 1 (Wigner matrices: iid entries mean 0 variance sigma^2; semicircle (1/2pi)sqrt(4-x^2) on [-2,2]; moments -> rooted planar trees, Sec. 2.2 Catalan numbers), https://lpetrov.cc/rmt25/rmt25-notes/rmt2025-l02.pdf; Wikipedia, Wigner semicircle distribution (R=2 even moments are Catalan numbers 1, 2, 5, 14), https://en.wikipedia.org/wiki/Wigner_semicircle_distribution
- plausible The eigenvalues of a random matrix fill Wigner's semicircle
The even moments of the semicircle are the Catalan numbers because counts closed walks that never cross themselves.
The even moments are Catalan numbers, but the walks that survive as N -> infinity are closed walks tracing a planar tree with each edge used exactly twice (non-crossing pairings); 'never cross themselves' is a loose description, and Tr H^2k/N counts all closed walks before the limit.
Petrov, Lectures on Random Matrices (2025), Lecture 2, Sec. 1 (Wigner matrices: iid entries mean 0 variance sigma^2; semicircle (1/2pi)sqrt(4-x^2) on [-2,2]; moments -> rooted planar trees, Sec. 2.2 Catalan numbers), https://lpetrov.cc/rmt25/rmt25-notes/rmt2025-l02.pdf; Wikipedia, Wigner semicircle distribution (R=2 even moments are Catalan numbers 1, 2, 5, 14), https://en.wikipedia.org/wiki/Wigner_semicircle_distribution
- verified Building a four-bit adder out of NAND gates
A NAND gate wires into NOT, AND, OR and XOR.
NAND is functionally complete; NOT, AND, OR, XOR are standard NAND constructions.
Wikipedia, NAND logic (NAND is functionally complete; NOT, AND, OR, XOR from NAND), https://en.wikipedia.org/wiki/NAND_logic
- verified Building a four-bit adder out of NAND gates
Those make a half adder, two half adders make a full adder, and four full adders in a row give 11 + 7 = 18.
A full adder is two half adders plus an OR gate on the carries; 11 + 7 = 18 = 10010 in binary with carry out.
Wikipedia, Adder (electronics) (full adder from two half adders and an OR; ripple-carry critical path 3 + 31x2 = 65 gate delays for 32 bits, i.e. 2 gate delays of carry propagation per full adder; carry-lookahead), https://en.wikipedia.org/wiki/Adder_(electronics)
- not-checkable Building a four-bit adder out of NAND gates
The program is built in five steps (rungs), each tested against the full truth table of the circuit it adds; the last checks all 256 sums of two four-bit numbers.
Describes the program; 16 x 16 = 256 pairs.
- plausible Building a four-bit adder out of NAND gates
That models a circuit at the level of logic gates, above transistors and below an instruction set.
Gate-level logic sits between device/transistor level and architecture in the usual abstraction stack (e.g. Harris & Harris, Digital Design and Computer Architecture, Ch. 1), not accessed; from general knowledge.
Wikipedia, NAND logic (NAND is functionally complete; NOT, AND, OR, XOR from NAND), https://en.wikipedia.org/wiki/NAND_logic
- verified Building a four-bit adder out of NAND gates
The last rung draws three pictures: the wiring of one column (one full adder), a timing diagram of that column as its three inputs count from 000 to 111, and the sum 11 + 7, where the carry has to pass through all four columns, one full-adder carry delay (two gate levels) each.
Replaces disputed ffbc4f4a407a. Each column's carry passes two gate levels (AND, OR); the say() line after the figure now says 'four carry delays'.
Wikipedia, 'Adder (electronics)', ripple-carry adder: '3 + 31 x 2 (for carry propagation in latter adders) = 65 gate delays', T_CRA(n) = 3D + (n-1)2D, https://en.wikipedia.org/wiki/Adder_(electronics); posts/2026-09-22-building-a-four-bit-adder-out-of-nand-gates.viv: full_carry = gate_or(half_carry(a, b), half_carry(gate_xor(a, b), cin)), an AND then an OR on the carry path
- verified Building a four-bit adder out of NAND gates
That delay is what makes this design slow, and it is what a carry-lookahead adder removes.
Ripple delay grows with width; carry-lookahead computes carries from generate/propagate signals to cut it.
Wikipedia, Adder (electronics) (full adder from two half adders and an OR; ripple-carry critical path 3 + 31x2 = 65 gate delays for 32 bits, i.e. 2 gate delays of carry propagation per full adder; carry-lookahead), https://en.wikipedia.org/wiki/Adder_(electronics)
- verified Building a four-bit adder out of NAND gates
Standard full-adder sum and carry equations.
Wikipedia, Adder (electronics) (full adder from two half adders and an OR; ripple-carry critical path 3 + 31x2 = 65 gate delays for 32 bits, i.e. 2 gate delays of carry propagation per full adder; carry-lookahead), https://en.wikipedia.org/wiki/Adder_(electronics)
- verified Building a four-bit adder out of NAND gates
That is why this is called a ripple-carry adder, and why a carry-lookahead adder computes the carries instead of passing them along.
Ripple-carry passes the carry column to column; carry-lookahead computes the carries directly.
Wikipedia, Adder (electronics) (full adder from two half adders and an OR; ripple-carry critical path 3 + 31x2 = 65 gate delays for 32 bits, i.e. 2 gate delays of carry propagation per full adder; carry-lookahead), https://en.wikipedia.org/wiki/Adder_(electronics)
- verified Building a four-bit adder out of NAND gates
The test checks all 256 pairs of four-bit numbers, the fifth bit (the carry out) included.
Replaces disputed ed69ce71a206.
posts/2026-09-22-building-a-four-bit-adder-out-of-nand-gates.viv, the ripple-adder test: r[0] + 16 * r[1] == a + b for a, b in 0..15 (256 pairs); the carry out is worth 16, the fifth bit
- not-checkable A cart-pole, balanced by a PD controller
The pole starts 15 degrees from upright.
Initial condition of this program (0.2618 rad = 15 degrees in the code).
- not-checkable A cart-pole, balanced by a PD controller
A controller that pushes the cart in proportion to the pole's angle and rate, and a little toward the origin, catches it in under two seconds and holds it.
Describes this simulation's outcome.
- not-checkable A cart-pole, balanced by a PD controller
At a fifth of the gains it falls.
Describes this simulation's outcome at gain 0.2.
- verified A cart-pole, balanced by a PD controller
The force is , with the cart terms small and positive: to move the cart left toward the origin, the controller must first lean the pole left, and the way to do that is a push to the right.
The cart-pole is non-minimum phase: moving the cart one way requires first moving it the other way to tilt the pole; with the library's sign convention, positive K_X pushes right when x > 0, which tips the pole left as described.
MathWorks, 'Control Systems in Practice, Part 6: What Are Non-Minimum Phase Systems?', https://www.mathworks.com/videos/control-systems-in-practice-part-6-what-are-non-minimum-phase-systems-1574922412196.html (read via search summary); lib/cartpole.viv in this repo (theta > 0 leans right; a positive force accelerates the cart right and makes thetadd negative)
- not-checkable A cart-pole, balanced by a PD controller
The gains are top-level constants, so
viv run --set K_THETA=30 ...tries another controller without editing the program.Describes the program's CLI and constants.
- not-checkable A cart-pole, balanced by a PD controller
Simulate from 15 degrees with the gains scaled by
gain; draw whendrawis true.Describes the program's run function.
- verified Compound interest
Interest added times a year is each time, applied times over years.
Periodic compounding applies rate r/n for nt periods: A = P(1+r/n)^(nt).
Wikipedia, 'Compound interest', periodic compounding A = P(1+r/n)^(nt) and continuous limit P e^(rt), https://en.wikipedia.org/wiki/Compound_interest
- verified Compound interest
Monthly beats annual by dollars here.
The two balances round to 1628.89 and 1647.01, and the arithmetic of those rounded balances is 18.12 (the unrounded gap is 18.11).
Wikipedia, 'Compound interest', periodic compounding A = P(1+r/n)^(nt), https://en.wikipedia.org/wiki/Compound_interest; Recomputed in Python 3 in this session: 1000*1.05**10 = 1628.8946, 1000*(1+0.05/12)**120 = 1647.0095
- verified Compound interest
Weekly beats monthly by less, daily by less again, and no matter how often the interest is added the balance never passes . Once the tests pass, try a few values of to see it approach that limit.
The balance increases with n toward the continuous-compounding limit P e^(rt) = 1000 e^0.5 = 1648.72; each increase in frequency gains less.
Wikipedia, 'Compound interest', periodic compounding A = P(1+r/n)^(nt) and continuous limit P e^(rt), https://en.wikipedia.org/wiki/Compound_interest; Recomputed in Python 3 (math.log, math.exp)
- verified Compound interest
years_to_doubleis the question the doubling-time post answers: is in the exponent, and taking the logarithm of both sides brings it down.Cross-reference to another post; the math (log power rule brings the exponent down) is standard.
Wikipedia, 'Logarithm', 'Logarithmic identities' (power rule) and 'Change of base', https://en.wikipedia.org/wiki/Logarithm
- verified Doubling time
Something growing 7% a year doubles in years, not : growth compounds.
ln 2 / ln 1.07 = 10.245 and 100/7 = 14.29; the naive linear estimate overstates the doubling time.
Wikipedia, 'Rule of 72', derivation (t = ln 2 / ln(1+r), ln(1+r) ~ r, ln 2 ~ 0.693) and rule of 70, https://en.wikipedia.org/wiki/Rule_of_72; Recomputed in Python 3 (math.log, math.exp)
- verified Doubling time
The logarithm is the tool that turns "how long until" into a division, and the rule of 70 is that division with and .
The rule of 70 follows from t = ln 2 / ln(1+r) with ln 2 ~ 0.7 and ln(1+r) ~ r.
Wikipedia, 'Rule of 72', derivation (t = ln 2 / ln(1+r), ln(1+r) ~ r, ln 2 ~ 0.693) and rule of 70, https://en.wikipedia.org/wiki/Rule_of_72
- verified Doubling time
Growth by a fixed fraction each year is .
Growth at fixed fraction r per period gives A0 (1+r)^t.
Wikipedia, 'Rule of 72', derivation (t = ln 2 / ln(1+r), ln(1+r) ~ r, ln 2 ~ 0.693) and rule of 70, https://en.wikipedia.org/wiki/Rule_of_72
- verified Doubling time
Asking when means solving for , and is in the exponent; the logarithm brings it down:
Doubling means (1+r)^t = 2; the log power rule brings t down.
Wikipedia, 'Logarithm', 'Logarithmic identities' (power rule) and 'Change of base', https://en.wikipedia.org/wiki/Logarithm
- verified Doubling time
t = ln 2 / ln(1+r), standard.
Wikipedia, 'Rule of 72', derivation (t = ln 2 / ln(1+r), ln(1+r) ~ r, ln 2 ~ 0.693) and rule of 70, https://en.wikipedia.org/wiki/Rule_of_72; Wikipedia, 'Logarithm', 'Logarithmic identities' (power rule) and 'Change of base', https://en.wikipedia.org/wiki/Logarithm
- verified Doubling time
Any base works, since a ratio of logs does not depend on the base.
Change of base: log_b x = log_k x / log_k b, so a ratio of logs is base-independent.
Wikipedia, 'Logarithm', 'Logarithmic identities' (power rule) and 'Change of base', https://en.wikipedia.org/wiki/Logarithm
- verified Doubling time
For small , and , so : the rule of 70.
ln 2 ~ 0.693 and ln(1+r) ~ r give t ~ 69.3/(100r), rounded to the rule of 70.
Wikipedia, 'Rule of 72', derivation (t = ln 2 / ln(1+r), ln(1+r) ~ r, ln 2 ~ 0.693) and rule of 70, https://en.wikipedia.org/wiki/Rule_of_72
- verified Doubling time
It is 2.4% off at 7% and 0.5% off at 3%, and a test checks both.
At 7%: rule gives 10.0 vs exact 10.245, 2.39% low; at 3%: 23.33 vs 23.45, 0.50% low.
Recomputed in Python 3 (math.log, math.exp)
- verified Doubling time
: the same thing with and .
Same approximation as the rule of 70 derivation.
Wikipedia, 'Rule of 72', derivation (t = ln 2 / ln(1+r), ln(1+r) ~ r, ln 2 ~ 0.693) and rule of 70, https://en.wikipedia.org/wiki/Rule_of_72
- verified LQR computes the cart-pole's gains from the Riccati equation
Linearize the same dynamics, choose how much each state error and each unit of push should cost, and the Riccati equation gives the gains instead.
LQR: linearize, choose Q and R, and the Riccati equation yields the optimal gain K.
Tedrake, Underactuated Robotics, ch. 'Linear Quadratic Regulators', sections 'Basic Derivation' (J* = x'Sx, K = R^-1 B'S) and 'Finite-horizon LQR' (Riccati ODE converges to the infinite-horizon solution), https://underactuated.csail.mit.edu/lqr.html; Wikipedia, 'Linear-quadratic regulator', infinite-horizon continuous-time section (K = R^-1 B'P, algebraic Riccati equation), citing Kwakernaak & Sivan (1972), https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic_regulator
- verified LQR computes the cart-pole's gains from the Riccati equation
Linearize the cart-pole about the upright and you have .
Linearization about an equilibrium gives z' = Az + Bu; K = R^-1 B'P with P solving the algebraic Riccati equation.
Tedrake, Underactuated Robotics, ch. 'Linear Quadratic Regulators', sections 'Basic Derivation' (J* = x'Sx, K = R^-1 B'S) and 'Finite-horizon LQR' (Riccati ODE converges to the infinite-horizon solution), https://underactuated.csail.mit.edu/lqr.html; Wikipedia, 'Linear-quadratic regulator', infinite-horizon continuous-time section (K = R^-1 B'P, algebraic Riccati equation), citing Kwakernaak & Sivan (1972), https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic_regulator
- verified LQR computes the cart-pole's gains from the Riccati equation
The only choices made by hand are and , and they state the tradeoff directly: angle error against cart position, and state error against force.
In LQR the only design choices are the weights Q and R; the gains follow from the Riccati solution.
Tedrake, Underactuated Robotics, ch. 'Linear Quadratic Regulators', sections 'Basic Derivation' (J* = x'Sx, K = R^-1 B'S) and 'Finite-horizon LQR' (Riccati ODE converges to the infinite-horizon solution), https://underactuated.csail.mit.edu/lqr.html
- not-checkable LQR computes the cart-pole's gains from the Riccati equation
and are not written out here.
Describes what the post shows.
- verified LQR computes the cart-pole's gains from the Riccati equation
comes from integrating the differential Riccati equation backwards until it stops changing, which takes only matrix multiplication and addition.
Tedrake states the finite-horizon Riccati ODE solution converges to the infinite-horizon solution as the horizon grows; with scalar R, the right-hand side needs only matrix products, sums and a scalar division.
Tedrake, Underactuated Robotics, ch. 'Linear Quadratic Regulators', sections 'Basic Derivation' (J* = x'Sx, K = R^-1 B'S) and 'Finite-horizon LQR' (Riccati ODE converges to the infinite-horizon solution), https://underactuated.csail.mit.edu/lqr.html
- verified LQR computes the cart-pole's gains from the Riccati equation
The hand-tuned gains also balance the pole; the Riccati gains are the ones that minimize the cost set by and .
LQR gains minimize the quadratic cost for the linearized system; that the hand-tuned gains also balance is shown by the run.
Tedrake, Underactuated Robotics, ch. 'Linear Quadratic Regulators', sections 'Basic Derivation' (J* = x'Sx, K = R^-1 B'S) and 'Finite-horizon LQR' (Riccati ODE converges to the infinite-horizon solution), https://underactuated.csail.mit.edu/lqr.html; Wikipedia, 'Linear-quadratic regulator', infinite-horizon continuous-time section (K = R^-1 B'P, algebraic Riccati equation), citing Kwakernaak & Sivan (1972), https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic_regulator
- not-checkable A Lennard-Jones liquid by molecular dynamics in two dimensions
The total energy never moves from its starting value by more than a thousandth of the kinetic energy, the speeds settle onto the Maxwell distribution at the temperature the kinetic energy says, and the pair correlation peaks where the potential is deepest.
Summary of this simulation's results, checked by its tests.
- verified A Lennard-Jones liquid by molecular dynamics in two dimensions
The box is periodic with the minimum-image rule, there is no cutoff (every pair, small), and the integrator is velocity Verlet, which is symplectic: the energy wobbles but does not drift.
Velocity Verlet is symplectic and second order, and its energy error oscillates without secular drift for smooth Hamiltonian systems. With minimum image and no cutoff, the pair force is truncated at the half-box, which can add small energy errors.
Hairer, Lubich, Wanner, 'Geometric numerical integration illustrated by the Stormer-Verlet method', Acta Numerica 12 (2003) 399-450; via Wikipedia 'Verlet integration', https://en.wikipedia.org/wiki/Verlet_integration
- verified A Lennard-Jones liquid by molecular dynamics in two dimensions
Momentum stays at zero to rounding, because every force has an equal and opposite partner.
Pairwise antisymmetric forces sum to zero, so velocity Verlet conserves total linear momentum exactly up to rounding; the code starts with zero total momentum.
Hairer, Lubich, Wanner, 'Geometric numerical integration illustrated by the Stormer-Verlet method', Acta Numerica 12 (2003) 399-450; via Wikipedia 'Verlet integration', https://en.wikipedia.org/wiki/Verlet_integration
- not-checkable A Lennard-Jones liquid by molecular dynamics in two dimensions
The fourth test checks the position and height of that peak.
Describes the post's test.
- not-checkable A Lennard-Jones liquid by molecular dynamics in two dimensions
The force loop is written with arrays: for each atom, the displacements to all the others are one array, the minimum image is one line, and the pair forces are a
powand two products.Describes the program's code.
- not-checkable A Lennard-Jones liquid by molecular dynamics in two dimensions
The post also shows a recorded run of the same program at 400 atoms and three times the steps (the
largesetting), compiled to C and run natively; 100 atoms takes a few seconds in a browser tab.Describes the recorded large-scale run; the 21-second runtime was dropped because nothing records it.
- not-checkable Building the derivative from its definition
The derivative is a good thing to build this way because each improvement is a few lines, and each has an error you can work out by hand before running anything.
Rhetorical motivation for the post's structure.
- verified Building the derivative from its definition
For f = x^3 the centered difference is 3x^2 + h^2, so (4(3x^2 + h^2/4) - (3x^2 + h^2))/3 = 3x^2, which is Richardson extrapolation.
Wikipedia, 'Richardson extrapolation', (4A(h/2) - A(h))/3 for t = 2, k0 = 2, citing Richardson & Gaunt (1927), https://en.wikipedia.org/wiki/Richardson_extrapolation
- verified Building the derivative from its definition
On a log-log plot they are lines of slope 1, 2 and 4, and the figure draws them from down to .
Forward, centered and extrapolated differences have errors O(h), O(h^2), O(h^4); the code's h = 0.4/2^i for i = 0..5 ends at 0.0125.
Wikipedia, 'Richardson extrapolation', (4A(h/2) - A(h))/3 for t = 2, k0 = 2, citing Richardson & Gaunt (1927), https://en.wikipedia.org/wiki/Richardson_extrapolation
- verified The geometric series adds up
The trick that gives the formula: multiply by and subtract.
Standard derivation of the finite geometric sum.
Wikipedia, 'Geometric series', closed form by multiplying by r and subtracting, https://en.wikipedia.org/wiki/Geometric_series
- verified The geometric series adds up
Every term cancels except the first of and the last of :
S_n - rS_n = a - ar^n: only the first term of S_n and the last of rS_n survive.
Wikipedia, 'Geometric series', closed form by multiplying by r and subtracting, https://en.wikipedia.org/wiki/Geometric_series
- verified The geometric series adds up
S_n = a(1 - r^n)/(1 - r) for n terms a..ar^(n-1).
Wikipedia, 'Geometric series', closed form by multiplying by r and subtracting, https://en.wikipedia.org/wiki/Geometric_series
- verified The geometric series adds up
The series takes 44 terms to get within 1% of its limit; the series takes 7.
Within 1% needs r^n < 0.01: n > 43.7 for r = 0.9 (44 terms) and n > 6.64 for r = 1/2 (7 terms).
Wikipedia, 'Geometric series', closed form by multiplying by r and subtracting, https://en.wikipedia.org/wiki/Geometric_series; Recomputed in Python 3 (math.log, math.exp)
- verified Two lines cross
Two straight lines, and , meet at one point unless they are parallel.
Two lines meet at a unique point exactly when the determinant is nonzero; the zero-determinant case includes coincident lines (infinitely many common points), which 'parallel' covers only informally.
Wikipedia, 'Cramer's rule', 2x2 case and the zero-determinant (parallel/coincident) discussion, https://en.wikipedia.org/wiki/Cramer%27s_rule
- plausible Two lines cross
Elimination, substitution, Cramer's rule: they are the same arithmetic in three arrangements, and any of them solves this.
All three methods solve the 2x2 system and reduce to the same ratios; 'same arithmetic' is an informal but fair description.
Wikipedia, 'Cramer's rule', 2x2 case and the zero-determinant (parallel/coincident) discussion, https://en.wikipedia.org/wiki/Cramer%27s_rule
- verified Two lines cross
The lines and cross at , and so do and : a different pair of lines through the same point.
3+2 = 5, 3-2 = 1, 2*3 + 3*2 = 12: both pairs pass through (3, 2).
Recomputed in Python 3 (math.log, math.exp)
- verified Two lines cross
A third pair crosses at , so an answer that always returns fails.
3*2 - 2*1 = 4 and 5*2 + 4*1 = 14, so the third pair crosses at (2, 1).
Recomputed in Python 3 (math.log, math.exp)
- verified Two lines cross
Slide one line until it is parallel to the other and the crossing runs off to infinity; something in the arithmetic must have gone to zero at that moment.
By Cramer's rule the solution is a ratio with the determinant in the denominator, which vanishes when the lines become parallel.
Wikipedia, 'Cramer's rule', 2x2 case and the zero-determinant (parallel/coincident) discussion, https://en.wikipedia.org/wiki/Cramer%27s_rule
- verified A swing-up policy trained offline
An acrobot is two links with one motor, at the elbow; the shoulder turns freely.
Tedrake: a two-link arm with an actuator at the elbow and none at the shoulder.
Tedrake, Underactuated Robotics, ch. 'Acrobots, Cart-Poles, and Quadrotors', sections 'The Acrobot' and 'LQR feedback', https://underactuated.csail.mit.edu/acrobot.html
- verified A swing-up policy trained offline
A linear controller can balance it only near upright, so from hanging down it first has to swing itself up.
LQR balancing is local to the upright; swing-up controllers bring the acrobot near the top and then switch to LQR.
Tedrake, Underactuated Robotics, ch. 'Acrobots, Cart-Poles, and Quadrotors', sections 'The Acrobot' and 'LQR feedback', https://underactuated.csail.mit.edu/acrobot.html; Tedrake, Underactuated Robotics, ch. 'Lyapunov Analysis', section 'Regions of attraction and LQR', https://underactuated.csail.mit.edu/lyapunov.html
- not-checkable A swing-up policy trained offline
The swing-up controller here was not derived: it is nine weights found offline by a cross-entropy search over 1600 simulated swings, run as compiled native code, and the page contains only those nine numbers.
Describes how the nine weights were produced offline; the search is not in the repository.
- verified A swing-up policy trained offline
The acrobot is like a gymnast on a high bar who can bend only at the hips.
Tedrake compares the acrobot to a gymnast on a bar controlling motion at the waist.
Tedrake, Underactuated Robotics, ch. 'Acrobots, Cart-Poles, and Quadrotors', sections 'The Acrobot' and 'LQR feedback', https://underactuated.csail.mit.edu/acrobot.html
- verified A swing-up policy trained offline
It is two links hinged end to end; the shoulder joint turns freely and the elbow has a motor.
Matches the standard acrobot definition.
Tedrake, Underactuated Robotics, ch. 'Acrobots, Cart-Poles, and Quadrotors', sections 'The Acrobot' and 'LQR feedback', https://underactuated.csail.mit.edu/acrobot.html
- verified A swing-up policy trained offline
Its state is and its input is a single torque, so the shoulder moves only through its coupling to the elbow.
State (q1, q2, q1dot, q2dot) with a single elbow torque; the torque reaches the shoulder only through dynamic coupling (gravity also acts on it).
Tedrake, Underactuated Robotics, ch. 'Acrobots, Cart-Poles, and Quadrotors', sections 'The Acrobot' and 'LQR feedback', https://underactuated.csail.mit.edu/acrobot.html
- verified A swing-up policy trained offline
A linear balancing controller works only near the upright, and the arm starts hanging straight down, far outside that region.
A linear controller's region of attraction on the nonlinear system is local, and hanging down is far from upright.
Tedrake, Underactuated Robotics, ch. 'Lyapunov Analysis', section 'Regions of attraction and LQR', https://underactuated.csail.mit.edu/lyapunov.html
- verified A swing-up policy trained offline
So it takes two controllers and a rule for when to switch from one to the other.
Swing-up plus switching to an LQR balancing controller near the top is the standard approach Tedrake describes.
Tedrake, Underactuated Robotics, ch. 'Acrobots, Cart-Poles, and Quadrotors', sections 'The Acrobot' and 'LQR feedback', https://underactuated.csail.mit.edu/acrobot.html
- verified A swing-up policy trained offline
Linearize the dynamics about the upright by central differences on the same
chain_ratethis page simulates, and the balancing gains come from the Riccati equation (the LQR method).Linearize about the upright and solve the Riccati equation for the LQR gains; the finite-difference and Schur details describe this program.
Tedrake, Underactuated Robotics, ch. 'Linear Quadratic Regulators', sections 'Basic Derivation' (J* = x'Sx, K = R^-1 B'S) and 'Finite-horizon LQR' (Riccati ODE converges to the infinite-horizon solution), https://underactuated.csail.mit.edu/lqr.html; Wikipedia, 'Linear-quadratic regulator', infinite-horizon continuous-time section (K = R^-1 B'P, algebraic Riccati equation), citing Kwakernaak & Sivan (1972), https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic_regulator
- verified A swing-up policy trained offline
The Riccati solution also gives the switching rule.
The LQR cost-to-go serves as a Lyapunov function whose sublevel sets estimate the region where balancing succeeds.
Tedrake, Underactuated Robotics, ch. 'Lyapunov Analysis', section 'Regions of attraction and LQR', https://underactuated.csail.mit.edu/lyapunov.html
- verified A swing-up policy trained offline
The Riccati matrix turns it into one number, , the cost the balancing controller expects to pay to bring the arm from back to upright (its cost-to-go).
For LQR, the optimal cost-to-go is J*(x) = x'Sx (for the linearized system).
Tedrake, Underactuated Robotics, ch. 'Linear Quadratic Regulators', sections 'Basic Derivation' (J* = x'Sx, K = R^-1 B'S) and 'Finite-horizon LQR' (Riccati ODE converges to the infinite-horizon solution), https://underactuated.csail.mit.edu/lqr.html
- verified A swing-up policy trained offline
When that number is small enough, the controller brings the arm upright within the torque limit; when it is larger, the controller can fail.
Replaces disputed 38646ff9b4c8. Below the level the controller succeeds; above it it can fail, not must.
Tedrake, Underactuated Robotics, ch. 'Lyapunov Analysis' (read): sublevel sets of a Lyapunov function are invariant and serve as inner approximations of the region of attraction, 'guaranteed to be contained within the true region of attraction', https://underactuated.mit.edu/lyapunov.html; posts/2026-09-23-a-swing-up-policy-trained-offline-and-flown-in-the-tab.viv: bisection along 300 directions reports only the smallest failing level, 23.0, so states with larger cost-to-go succeed in other directions
- not-checkable A swing-up policy trained offline
To find how small is small enough (the switching level), the full nonlinear model with the torque limit was simulated offline from states along random directions in the four-dimensional state space, bisecting on the cost-to-go along each, and the level was set below the smallest one at which the controller failed.
Describes the offline procedure that set the switching level; the search is not in the repository, and the program only uses V_SWITCH = 20.
- not-checkable A swing-up policy trained offline
It is not derived.
Describes this post's controller.
- verified A swing-up policy trained offline
The nine weights come from a cross-entropy search: sample forty policies from a Gaussian, simulate each one, refit the Gaussian to the best six, and repeat forty times.
Sample from a Gaussian, evaluate, refit to the elite samples, repeat is the cross-entropy method; 40 x 40 = 1600 simulations.
de Boer, Kroese, Mannor, Rubinstein, 'A Tutorial on the Cross-Entropy Method', Ann. Oper. Res. 134 (2005) 19-67; via Wikipedia 'Cross-entropy method', https://en.wikipedia.org/wiki/Cross-entropy_method
- not-checkable A swing-up policy trained offline
That is 1600 simulated swings, run as Viv compiled to native code.
Describes how the weights were produced offline (40 policies x 40 rounds = 1600); the search is not in the repository.
- not-checkable A swing-up policy trained offline
At the end of the six seconds this page simulates, the two joint angles add up to 0.0045 radians from upright and are still closing; with twelve seconds instead of six they reach .
Results of this program's run.
- not-checkable A swing-up policy trained offline
What it does not do.
Section heading.
- not-checkable A swing-up policy trained offline
The weights were trained from one starting position, and they fail from a nearby one.
Describes this program's behavior.
- plausible A transformer trained with Muon
The task is to output the previous token, which a transformer can do only by learning to look one position back.
With random tokens, predicting the previous token requires attending to the position one back; this follows from the task design.
Wikipedia, 'Attention (machine learning)', scaled dot-product attention and causal mask, pointing to Vaswani et al., 'Attention Is All You Need' (2017), https://en.wikipedia.org/wiki/Attention_(machine_learning)
- verified A transformer trained with Muon
It is trained by Muon, an optimizer that orthogonalizes the momentum with five Newton-Schulz steps before stepping along it.
Jordan: Muon post-processes the momentum update with about 5 Newton-Schulz steps, replacing it with the nearest semi-orthogonal matrix.
K. Jordan, 'Muon: An optimizer for hidden layers in neural networks' (2024), https://kellerjordan.github.io/posts/muon/
- not-checkable A transformer trained with Muon
In the attention matrix it ends with, each position puts its weight on the one before it.
Describes this program's trained attention matrix.
- verified A transformer trained with Muon
A transformer reads a sequence of tokens (symbols from a fixed list, the vocabulary) and, at every position, predicts a token.
Fair description of a decoder-style transformer predicting a token at each position.
Wikipedia, 'Attention (machine learning)', scaled dot-product attention and causal mask, pointing to Vaswani et al., 'Attention Is All You Need' (2017), https://en.wikipedia.org/wiki/Attention_(machine_learning)
- plausible A transformer trained with Muon
What lets it use the rest of the sequence is attention: each position computes a weighted average over the positions before it, and the weights are learned.
Informal: with a causal mask each position averages over itself and earlier positions, and the weights are computed from learned query/key projections rather than learned directly.
Wikipedia, 'Attention (machine learning)', scaled dot-product attention and causal mask, pointing to Vaswani et al., 'Attention Is All You Need' (2017), https://en.wikipedia.org/wiki/Attention_(machine_learning)
- not-checkable A transformer trained with Muon
Everything runs in this browser tab, forward and backward, with no machine-learning framework.
Describes where this program runs.
- verified A transformer trained with Muon
Muon is the optimizer used in the modded-nanogpt speedrun, a public contest to train a small GPT as fast as possible.
The modded-nanogpt speedrun trains a GPT to 3.28 FineWeb validation loss on 8xH100 as fast as possible, and Muon has been its optimizer since October 2024.
KellerJordan/modded-nanogpt README, https://github.com/KellerJordan/modded-nanogpt; K. Jordan, 'Muon: An optimizer for hidden layers in neural networks' (2024), https://kellerjordan.github.io/posts/muon/
- not-checkable A transformer trained with Muon
Sequences of six tokens from a vocabulary of six.
Describes this task.
- not-checkable A transformer trained with Muon
At every position the model must name the token before it.
Describes this task.
- plausible A transformer trained with Muon
The tokens are random, so the token at a position says nothing about the one before it, and a model that cannot look at other positions can do no better than guessing.
Not accessed; from general knowledge: if tokens are independent and uniform, the current token carries no information about the previous one, so a position-local model can only guess.
Wikipedia, 'Attention (machine learning)', scaled dot-product attention and causal mask, pointing to Vaswani et al., 'Attention Is All You Need' (2017), https://en.wikipedia.org/wiki/Attention_(machine_learning)
- not-checkable A transformer trained with Muon
(Position zero is the one exception; the section on what guessing scores comes back to it.)
Forward reference within the post.
- not-checkable A transformer trained with Muon
Dis the width of the vector that stands for each token inside the model,Hthe width of the attention head's vectors, andMU,LRandSTEPSare the optimizer's settings, explained where they are used.Defines the program's variables.
- not-checkable A transformer trained with Muon
Sixteen sequences of six random tokens.
Describes the program's data (NSEQ=16, T=6).
- verified A transformer trained with Muon
The random numbers come from a linear congruential generator: multiply by a large constant, add another constant, keep the remainder.
Replaces disputed 6819903a5a85.
Wikipedia, 'Linear congruential generator': X_{n+1} = (a X_n + c) mod m, with the glibc/ISO C constants a = 1103515245, c = 12345, m = 2^31, https://en.wikipedia.org/wiki/Linear_congruential_generator; posts/2026-09-23-a-transformer-trained-by-muon-in-this-tab.viv line 64: rng = mod(1103515245.0 * rng + 12345.0, 2147483648.0)
- not-checkable A transformer trained with Muon
The target at each position is the token one step back; position zero has nothing before it, so it names itself.
Describes the program's targets; matches targ[s,t] = toks[s, max(t-1,0)].
- not-checkable A transformer trained with Muon
The targets are the tokens shifted one place to the right, with the first token repeated at the front.
Restates the program's targets.
- not-checkable A transformer trained with Muon
At each position the model outputs six numbers, one per token, called logits.
Definition of the model's output; the usage of 'logits' for pre-softmax scores is standard.
- verified A transformer trained with Muon
A softmax turns them into probabilities: exponentiate each and divide by the sum.
Matches the standard definition of softmax.
Wikipedia, 'Softmax function' (definition: exponentiate each element, divide by the sum), https://en.wikipedia.org/wiki/Softmax_function
- verified A transformer trained with Muon
The loss is the cross-entropy, where is the probability given to the right token, averaged over every position.
Mean negative log-probability of the correct class is the standard cross-entropy loss; it is 0 at p=1 and diverges as p->0.
Wikipedia, 'Cross-entropy' (loss as negative log-likelihood; minimized when predicted distribution equals the true one, Gibbs' inequality), https://en.wikipedia.org/wiki/Cross-entropy
- verified A transformer trained with Muon
A model that knows nothing about the answer does best by spreading its probability evenly, for every token.
With the correct token uniformly random, expected cross-entropy is minimized by the uniform prediction (Gibbs' inequality), giving log 6.
Wikipedia, 'Cross-entropy' (loss as negative log-likelihood; minimized when predicted distribution equals the true one, Gibbs' inequality), https://en.wikipedia.org/wiki/Cross-entropy
- not-checkable A transformer trained with Muon
That is the loss to beat.
Rhetoric.
- verified A transformer trained with Muon
A model that sees only the current token could do slightly better than this by getting position zero right, since its answer is its own token, but it would still be guessing at the other five positions out of six.
Position zero's target is its own token, so a current-token model can score it perfectly while the other five stay at log 6: loss about (5/6) log 6 = 1.49 < 1.79.
Wikipedia, 'Cross-entropy' (loss as negative log-likelihood; minimized when predicted distribution equals the true one, Gibbs' inequality), https://en.wikipedia.org/wiki/Cross-entropy
- plausible A transformer trained with Muon
Only attention to the previous position gets the loss near zero.
Follows from the task: the target at t>0 is independent of every token except t-1, so only a model that reads position t-1 can drive the loss near zero; not accessed as a single reference, from general reasoning.
Haviv, Ram, Press, Izsak, Levy, 'Transformer Language Models without Positional Encodings Still Learn Positional Information' (2022), arXiv:2203.16634
- not-checkable A transformer trained with Muon
Six weight matrices, all learned:
Describes this model's parameters.
- not-checkable A transformer trained with Muon
the token embedding
E, : a row of eight numbers for each token;Describes this model's parameters (V=6, D=8).
- not-checkable A transformer trained with Muon
the position embedding
P, : a row for each position;Describes this model's parameters (T=6, D=8).
- not-checkable A transformer trained with Muon
the attention head's three projections
Wq,WkandWv, each;Describes this model's parameters (D=H=8).
- not-checkable A transformer trained with Muon
the output projection
Wo, , which turns the head's output into six logits.Describes this model's parameters (H=8, V=6).
- not-checkable A transformer trained with Muon
lib/paramskeeps all six in one flat vector, so the gradient is one vector too and the optimizer's memory is two more.Describes lib/params and lib/optim; optim_state does allocate two parameter-length vectors (Muon uses the first).
- not-checkable A transformer trained with Muon
Each matrix starts as the corner of a fixed pseudo-random matrix, scaled down so that the first logits are small and the first guesses near even.
Describes the program's initialization (test_matrix corners scaled by 0.5/0.3).
- verified A transformer trained with Muon
The model's input at position is a row of eight numbers: the token embedding's row for the token there, plus the position embedding's row for .
Adding a position embedding to the token embedding is the standard transformer input; the program does exactly this.
Vaswani et al., 'Attention Is All You Need' (2017), arXiv:1706.03762, Sec. 3.5: positional encodings are added to the input embeddings
- plausible A transformer trained with Muon
The position row is the only place the model learns where a token sits.
True for this one-layer model, where attention scores see position only through P; Haviv et al. show the causal mask itself can leak position information in deeper models, but it is not learned.
Haviv, Ram, Press, Izsak, Levy, 'Transformer Language Models without Positional Encodings Still Learn Positional Information' (2022), arXiv:2203.16634
- plausible A transformer trained with Muon
Without it, the six positions would look the same to the attention head.
Without P the keys depend only on the token, so the head cannot single out the previous position; the causal mask still differs by row (Haviv et al.), so 'look the same' holds for the scores, not for the mask.
Haviv, Ram, Press, Izsak, Levy, 'Transformer Language Models without Positional Encodings Still Learn Positional Information' (2022), arXiv:2203.16634
- verified A transformer trained with Muon
Each position's row is multiplied by three matrices to make a query , a key and a value .
Queries, keys and values are learned linear projections of the input.
Vaswani et al., 'Attention Is All You Need' (2017), arXiv:1706.03762, Sec. 3.2.1 (softmax(QK^T/sqrt(d_k))V) and 3.2.2 (learned linear projections of queries, keys, values)
- verified A transformer trained with Muon
Position scores every position by how well its query matches that key, .
Scaled dot-product attention divides q.k by sqrt(d_k), here H.
Vaswani et al., 'Attention Is All You Need' (2017), arXiv:1706.03762, Sec. 3.2.1 (softmax(QK^T/sqrt(d_k))V) and 3.2.2 (learned linear projections of queries, keys, values)
- verified A transformer trained with Muon
The scores of positions after are set to (the causal mask: a position may not look ahead).
Causal masking sets scores for later positions to -inf before the softmax.
Vaswani et al., 'Attention Is All You Need' (2017), arXiv:1706.03762, Sec. 3.2.3: decoder self-attention masks illegal (leftward) connections by setting softmax inputs to -inf
- not-checkable A transformer trained with Muon
The attention matrix is where the model's looking shows.
Rhetoric about this post's figure.
- not-checkable A transformer trained with Muon
To solve the task, row has to put its weight on column .
Statement about this post's task (for rows i >= 1).
- not-checkable A transformer trained with Muon
Everywhere it may, evenly.
Describes this run's attention_before output.
- not-checkable A transformer trained with Muon
There is no preference for the position before.
Describes this run's attention_before output.
- not-checkable A transformer trained with Muon
Everything above the diagonal is exactly zero: that is the mask.
Describes this run's output; exp(-inf)=0 makes masked entries exactly zero.
- not-checkable A transformer trained with Muon
The head's output times
Wogives the logits, and cross-entropy scores them against the targets.Describes the program's forward pass.
- not-checkable A transformer trained with Muon
That is the forward pass.
Transition.
- verified A transformer trained with Muon
It runs the forward steps in reverse.
Backpropagation propagates derivatives backward, one layer at a time, from output to input.
Wikipedia, 'Backpropagation' (chain rule, propagating derivatives backward one layer at a time from output to input), https://en.wikipedia.org/wiki/Backpropagation
- verified A transformer trained with Muon
An embedding's gradient goes only to the rows that were looked up.
An embedding lookup is a row selection, so only the selected rows get nonzero gradient; this is why frameworks can return it as a sparse tensor.
Wikipedia, 'Backpropagation' (chain rule, propagating derivatives backward one layer at a time from output to input), https://en.wikipedia.org/wiki/Backpropagation; PyTorch docs, torch.nn.Embedding (sparse=True gives a sparse gradient w.r.t. weight), https://docs.pytorch.org/docs/2.14/generated/torch.nn.Embedding.html
- not-checkable A transformer trained with Muon
The training loss is the mean over all sixteen sequences, and the gradient is the sum of theirs.
Describes loss_and_gradient: mean loss over 16 sequences, gradient summed (not averaged).
- not-checkable A transformer trained with Muon
The accuracy is the fraction of the 96 positions where the token the model rates most likely is the right one.
Defines this program's accuracy metric over 16 x 6 = 96 positions.
- not-checkable A transformer trained with Muon
The accuracy starts at (
start_accuracy), 14 of the 96 positions, about what luck gives.Describes this run; 14/96 = 0.1458 matches start_accuracy, and 1/6 of 96 is 16.
- verified A transformer trained with Muon
Plain gradient descent steps each weight against its gradient.
Gradient descent update w := w - eta grad.
Wikipedia, 'Stochastic gradient descent', sections on the update w := w - eta grad Q and on momentum, https://en.wikipedia.org/wiki/Stochastic_gradient_descent
- not-checkable A transformer trained with Muon
Muon adds one thing.
Transition.
- plausible A transformer trained with Muon
Then no direction of the weight matrix gets a much larger step than any other, however lopsided the gradient was.
Jordan describes orthogonalization as raising the scale of small ('rare') directions in the update; 'no direction gets a much larger step' holds up to the approximate singular values Muon's five steps leave (0.45-1.17 in this run).
K. Jordan, 'Muon: An optimizer for hidden layers in neural networks' (2024), https://kellerjordan.github.io/posts/muon/
- verified A transformer trained with Muon
It does this with five steps of a Newton-Schulz iteration, a matrix polynomial,
Muon applies five Newton-Schulz iterations, a quintic matrix polynomial, to the momentum.
K. Jordan, 'Muon: An optimizer for hidden layers in neural networks' (2024), https://kellerjordan.github.io/posts/muon/
- verified A transformer trained with Muon
Jordan's tuned coefficients are (3.4445, -4.7750, 2.0315) for aX + b(XX^T)X + c(XX^T)^2X.
K. Jordan, 'Muon: An optimizer for hidden layers in neural networks' (2024), https://kellerjordan.github.io/posts/muon/; Amsel et al., 'The Polar Express' (2025), Sec. 1.2, https://arxiv.org/html/2505.16932
- verified A transformer trained with Muon
The classical Newton-Schulz polynomial, with coefficients , and , converges to exactly 1 but slowly; Muon's coefficients are tuned to get close fast.
The classical quintic Newton-Schulz polynomial is (15x - 10x^3 + 3x^5)/8, which converges to polar(M); Polar Express notes Jordan's coefficients do not converge but plateau (error about 0.3).
Amsel et al., 'The Polar Express' (2025), Sec. 1.2, https://arxiv.org/html/2505.16932
- not-checkable A transformer trained with Muon
A training step computes the loss and gradient over all sixteen sequences, then takes one Muon step.
Describes the program's training step.
- not-checkable A transformer trained with Muon
After step thirty the loss does not slide down steadily.
Describes this run's loss curve.
- not-checkable A transformer trained with Muon
It sits at a few thousandths and then jumps.
Describes this run's loss curve.
- not-checkable A transformer trained with Muon
Full-length steps get down fast and then keep stepping over the minimum.
Interpretation of this run's comparison of constant and decaying step sizes.
- not-checkable A transformer trained with Muon
Nothing in the setup mentions the previous position.
Describes the program's setup.
- not-checkable A transformer trained with Muon
The model gets a position embedding and a loss.
Describes the program's setup.
- not-checkable A transformer trained with Muon
The picture is the attention matrix: a bright line just below the diagonal, position zero's weight on itself in the top corner, and zeros above the diagonal, which are the causal mask, not something learned.
Describes this post's figure.
- plausible A transformer trained with Muon
A subtly wrong backward pass still runs and can still make the loss fall for a while, so training alone would not reveal the error.
CS231n motivates gradient checks by the fact that an incorrect analytic gradient can go unnoticed during training; the specific 'loss can still fall' claim is from general knowledge.
Stanford CS231n notes, 'Neural Networks Part 3', Gradient checks (centered difference (f(x+h)-f(x-h))/2h), https://cs231n.github.io/neural-networks-3/
- plausible Solving the Riccati equation without integrating it
Every LQR controller comes from a quadratic matrix equation, and the tempting way to solve it is to integrate the differential version backwards until it stops moving.
Infinite-horizon LQR gains come from the algebraic Riccati equation (finite-horizon ones from the differential equation, discrete-time from the DARE, so 'every' is loose); Laub lists integrating the Riccati differential equation among competing approaches.
Wikipedia, 'Linear-quadratic regulator' (finite-horizon Riccati differential equation solved backward in time; infinite horizon gives the algebraic Riccati equation; K = R^-1 B^T P), https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic_regulator; A. J. Laub, 'A Schur method for solving algebraic Riccati equations', IEEE Trans. Autom. Control AC-24(6):913-921 (1979), Theorems 4-5 and Sec. IV-A; http://eceweb1.rutgers.edu/~gajic/pdffiles/519KalmanFiltering/LaubARE_SchurMethod.pdf
- not-checkable Solving the Riccati equation without integrating it
The gains of a linear-quadratic regulator come out of
Sentence fragment leading into the formula.
- verified Solving the Riccati equation without integrating it
Standard continuous-time algebraic Riccati equation, with W in the role of Q.
Wikipedia, 'Algebraic Riccati equation' (CARE form; Hamiltonian [[A,-BR^-1B^T],[-Q,-A^T]]; P = U21 U11^-1 from the stable invariant subspace), https://en.wikipedia.org/wiki/Algebraic_Riccati_equation; Wikipedia, 'Linear-quadratic regulator' (finite-horizon Riccati differential equation solved backward in time; infinite horizon gives the algebraic Riccati equation; K = R^-1 B^T P), https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic_regulator
- verified Solving the Riccati equation without integrating it
quadratic in the matrix .
The CARE is quadratic in P via the P B R^-1 B^T P term.
Wikipedia, 'Algebraic Riccati equation' (CARE form; Hamiltonian [[A,-BR^-1B^T],[-Q,-A^T]]; P = U21 U11^-1 from the stable invariant subspace), https://en.wikipedia.org/wiki/Algebraic_Riccati_equation
- verified Solving the Riccati equation without integrating it
There is an obvious way to solve it: run backwards from zero until it stops changing.
The Riccati differential equation integrated backward from a terminal P converges to the stabilizing ARE solution under stabilizability/detectability; Laub mentions this approach.
Wikipedia, 'Linear-quadratic regulator' (finite-horizon Riccati differential equation solved backward in time; infinite horizon gives the algebraic Riccati equation; K = R^-1 B^T P), https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic_regulator; A. J. Laub, 'A Schur method for solving algebraic Riccati equations', IEEE Trans. Autom. Control AC-24(6):913-921 (1979), Theorems 4-5 and Sec. IV-A; http://eceweb1.rutgers.edu/~gajic/pdffiles/519KalmanFiltering/LaubARE_SchurMethod.pdf
- plausible Solving the Riccati equation without integrating it
The closed loop it produces decays like , so the Riccati flow settles over roughly seven hundred seconds, and eighty seconds of backward integration gets nowhere near.
A_cl = -0.001 - 0.001*0.414 = -0.00141 is correct, but the Riccati flow near P converges at rate 2|A_cl| (time constant ~354 s); my integration of the scalar flow from zero gives P at 18% of 414 at 80 s, 84% at 700 s and 98% at 1500 s, so 'roughly seven hundred seconds' is an order-of-magnitude timescale.
Wikipedia, 'Linear-quadratic regulator' (finite-horizon Riccati differential equation solved backward in time; infinite horizon gives the algebraic Riccati equation; K = R^-1 B^T P), https://en.wikipedia.org/wiki/Linear%E2%80%93quadratic_regulator
- verified Solving the Riccati equation without integrating it
The fix is to solve a linear eigenvalue problem instead.
Laub's method replaces the quadratic equation with an invariant-subspace (eigenvalue) computation on the Hamiltonian matrix.
A. J. Laub, 'A Schur method for solving algebraic Riccati equations', IEEE Trans. Autom. Control AC-24(6):913-921 (1979), Theorems 4-5 and Sec. IV-A; http://eceweb1.rutgers.edu/~gajic/pdffiles/519KalmanFiltering/LaubARE_SchurMethod.pdf
- verified Solving the Riccati equation without integrating it
Stack and the two weights into the Hamiltonian
The Hamiltonian is 2n x 2n, built from A, B R^-1 B^T and the state weight.
Wikipedia, 'Algebraic Riccati equation' (CARE form; Hamiltonian [[A,-BR^-1B^T],[-Q,-A^T]]; P = U21 U11^-1 from the stable invariant subspace), https://en.wikipedia.org/wiki/Algebraic_Riccati_equation; A. J. Laub, 'A Schur method for solving algebraic Riccati equations', IEEE Trans. Autom. Control AC-24(6):913-921 (1979), Theorems 4-5 and Sec. IV-A; http://eceweb1.rutgers.edu/~gajic/pdffiles/519KalmanFiltering/LaubARE_SchurMethod.pdf
- verified Solving the Riccati equation without integrating it
Matches the standard Hamiltonian [[A, -BR^-1B^T], [-Q, -A^T]].
Wikipedia, 'Algebraic Riccati equation' (CARE form; Hamiltonian [[A,-BR^-1B^T],[-Q,-A^T]]; P = U21 U11^-1 from the stable invariant subspace), https://en.wikipedia.org/wiki/Algebraic_Riccati_equation; A. J. Laub, 'A Schur method for solving algebraic Riccati equations', IEEE Trans. Autom. Control AC-24(6):913-921 (1979), Theorems 4-5 and Sec. IV-A; http://eceweb1.rutgers.edu/~gajic/pdffiles/519KalmanFiltering/LaubARE_SchurMethod.pdf
- verified Solving the Riccati equation without integrating it
whose spectrum is symmetric about the imaginary axis: every eigenvalue is matched by , so exactly of the are stable.
Eigenvalues come in pairs lambda, -lambda (with conjugates). 'Exactly n are stable' also needs no imaginary-axis eigenvalues, which Laub's stabilizability/detectability assumptions guarantee; the sentence leaves that condition out.
Wikipedia, 'Hamiltonian matrix' (characteristic polynomial even: lambda, -lambda, conj(lambda), -conj(lambda) are all eigenvalues), https://en.wikipedia.org/wiki/Hamiltonian_matrix; A. J. Laub, 'A Schur method for solving algebraic Riccati equations', IEEE Trans. Autom. Control AC-24(6):913-921 (1979), Theorems 4-5 and Sec. IV-A; http://eceweb1.rutgers.edu/~gajic/pdffiles/519KalmanFiltering/LaubARE_SchurMethod.pdf
- verified Solving the Riccati equation without integrating it
No quadratic equation is solved.
The Schur method needs an ordered real Schur form plus one linear solve (P = X2 X1^-1); no quadratic equation is solved.
A. J. Laub, 'A Schur method for solving algebraic Riccati equations', IEEE Trans. Autom. Control AC-24(6):913-921 (1979), Theorems 4-5 and Sec. IV-A; http://eceweb1.rutgers.edu/~gajic/pdffiles/519KalmanFiltering/LaubARE_SchurMethod.pdf
- plausible Solving the Riccati equation without integrating it
Computing that basis is the main work.
Laub's method has two steps, the ordered real Schur form of the 2n x 2n matrix and an n x n linear solve; the first is the O((2n)^3) QR iteration and dominates the cost (standard operation counts, not quoted directly).
A. J. Laub, 'A Schur method for solving algebraic Riccati equations', IEEE Trans. Autom. Control AC-24(6):913-921 (1979), Theorems 4-5 and Sec. IV-A; http://eceweb1.rutgers.edu/~gajic/pdffiles/519KalmanFiltering/LaubARE_SchurMethod.pdf
- verified Solving the Riccati equation without integrating it
It is done by reducing to real Schur form (block upper triangular) and moving the stable blocks to the top left.
Laub Theorem 4 and Sec. IV-A: reduce to real Schur form (quasi-upper-triangular) with the stable eigenvalues ordered into S11 at the top left.
A. J. Laub, 'A Schur method for solving algebraic Riccati equations', IEEE Trans. Autom. Control AC-24(6):913-921 (1979), Theorems 4-5 and Sec. IV-A; http://eceweb1.rutgers.edu/~gajic/pdffiles/519KalmanFiltering/LaubARE_SchurMethod.pdf
- verified Solving the Riccati equation without integrating it
The animation below shows that reduction: the eleven subdiagonal entries of the Hessenberg matrix, driven to zero by Francis's implicit double-shift QR iteration, one turn of its outer loop at a time.
A 12 x 12 Hessenberg matrix has 11 subdiagonal entries; the double Francis QR drives them toward zero (Laub cites the double Francis QR). The animation itself belongs to the post.
Wikipedia, 'QR algorithm' (Hessenberg reduction, Francis double shift, deflation when a subdiagonal entry is small, quadratic convergence, real Schur form with 2x2 blocks), https://en.wikipedia.org/wiki/QR_algorithm; A. J. Laub, 'A Schur method for solving algebraic Riccati equations', IEEE Trans. Autom. Control AC-24(6):913-921 (1979), Theorems 4-5 and Sec. IV-A; http://eceweb1.rutgers.edu/~gajic/pdffiles/519KalmanFiltering/LaubARE_SchurMethod.pdf
- verified Solving the Riccati equation without integrating it
Its size over four successive turns is , , , : the exponent doubles each time, which is the quadratic convergence a good shift gives.
The listed values have exponents -2.5, -6.1, -12.7, -26.4, roughly doubling each time, consistent with quadratic convergence of a shifted QR subdiagonal. The last value is an orphan number, not linked to a test.
Wikipedia, 'QR algorithm' (Hessenberg reduction, Francis double shift, deflation when a subdiagonal entry is small, quadratic convergence, real Schur form with 2x2 blocks), https://en.wikipedia.org/wiki/QR_algorithm
- verified Solving the Riccati equation without integrating it
When an entry reaches rounding level, the matrix splits there into two smaller problems and the iteration moves on to the block above.
Deflation: once a subdiagonal entry is negligible the problem splits into independent smaller eigenproblems.
Wikipedia, 'QR algorithm' (Hessenberg reduction, Francis double shift, deflation when a subdiagonal entry is small, quadratic convergence, real Schur form with 2x2 blocks), https://en.wikipedia.org/wiki/QR_algorithm
- not-checkable Solving the Riccati equation without integrating it
The matrix sign function, another way to get from , is more than thirty times worse on at least one.
Compares results of this post's run; the matrix sign function is a standard alternative Riccati solver, but the 'thirty times worse' figure comes only from this program.
- not-checkable The tension in each of two ropes holding up a box
A box of weight W hangs from two ropes that make angles θ₁ and θ₂ with the ceiling.
Sets up the problem.
- verified The tension in each of two ropes holding up a box
Balancing the sideways pulls and the upward pulls gives the tension in each rope in terms of W and the angles.
Horizontal and vertical force balance give two equations for the two tensions.
OpenStax, University Physics Vol. 1, Sec. 6.1, Example 6.1 (traffic light: T1 cos30 = T2 cos45, T1 sin30 + T2 sin45 = w; net force zero because acceleration is zero), https://openstax.org/books/university-physics-volume-1/pages/6-1-solving-problems-with-newtons-laws
- verified The tension in each of two ropes holding up a box
A box's weight is the force gravity pulls it down with: its mass times , measured in newtons (N).
w = mg with g = 9.80 m/s^2; the standard value 9.80665 m/s^2 rounds to this.
OpenStax, University Physics Vol. 1, Sec. 5.6 'Common Forces' (tension is a pulling force along a flexible connector; Example 5.13 T = w/(2 sin theta); g = 9.80 m/s^2), https://openstax.org/books/university-physics-volume-1/pages/5-6-common-forces
- verified The tension in each of two ropes holding up a box
The box pulls straight down with its weight .
Weight acts straight down with magnitude W.
OpenStax, University Physics Vol. 1, Sec. 5.6 'Common Forces' (tension is a pulling force along a flexible connector; Example 5.13 T = w/(2 sin theta); g = 9.80 m/s^2), https://openstax.org/books/university-physics-volume-1/pages/5-6-common-forces
- verified The tension in each of two ropes holding up a box
The left rope pulls up and to the left along its own length with some force , and the right rope pulls up and to the right with .
Each rope pulls along its own length, away from the knot.
OpenStax, University Physics Vol. 1, Sec. 5.6 'Common Forces' (tension is a pulling force along a flexible connector; Example 5.13 T = w/(2 sin theta); g = 9.80 m/s^2), https://openstax.org/books/university-physics-volume-1/pages/5-6-common-forces
- verified The tension in each of two ropes holding up a box
A rope can only pull along itself; that pull is what tension means.
OpenStax: tension is a pulling force acting along a stretched flexible connector.
OpenStax, University Physics Vol. 1, Sec. 5.6 'Common Forces' (tension is a pulling force along a flexible connector; Example 5.13 T = w/(2 sin theta); g = 9.80 m/s^2), https://openstax.org/books/university-physics-volume-1/pages/5-6-common-forces
- not-checkable The tension in each of two ropes holding up a box
Now require that nothing moves.
Transition.
- verified The tension in each of two ropes holding up a box
Sideways: the left rope's sideways pull must cancel the right rope's:
Same form as Example 6.1's horizontal equation.
OpenStax, University Physics Vol. 1, Sec. 6.1, Example 6.1 (traffic light: T1 cos30 = T2 cos45, T1 sin30 + T2 sin45 = w; net force zero because acceleration is zero), https://openstax.org/books/university-physics-volume-1/pages/6-1-solving-problems-with-newtons-laws
- verified The tension in each of two ropes holding up a box
Up and down: the two upward parts together must hold up the weight:
Same form as Example 6.1's vertical equation.
OpenStax, University Physics Vol. 1, Sec. 6.1, Example 6.1 (traffic light: T1 cos30 = T2 cos45, T1 sin30 + T2 sin45 = w; net force zero because acceleration is zero), https://openstax.org/books/university-physics-volume-1/pages/6-1-solving-problems-with-newtons-laws
- verified The tension in each of two ropes holding up a box
Two equations, two unknowns, and .
Two linear equations in T1 and T2, solved simultaneously as in Example 6.1.
OpenStax, University Physics Vol. 1, Sec. 6.1, Example 6.1 (traffic light: T1 cos30 = T2 cos45, T1 sin30 + T2 sin45 = w; net force zero because acceleration is zero), https://openstax.org/books/university-physics-volume-1/pages/6-1-solving-problems-with-newtons-laws
- not-checkable The tension in each of two ropes holding up a box
The function below is those two equations written as code.
Describes the program's function.
- not-checkable The tension in each of two ropes holding up a box
Given candidate tensions, it adds up the three forces and reports how much is left over.
Describes the program's function.
- verified The tension in each of two ropes holding up a box
When both ropes make the same angle , the sideways equation says .
Equal angles give equal cosines, so the horizontal balance gives T1 = T2 (Example 5.13's symmetric case).
OpenStax, University Physics Vol. 1, Sec. 5.6 'Common Forces' (tension is a pulling force along a flexible connector; Example 5.13 T = w/(2 sin theta); g = 9.80 m/s^2), https://openstax.org/books/university-physics-volume-1/pages/5-6-common-forces
- verified The tension in each of two ropes holding up a box
The up-and-down equation becomes , so
OpenStax Example 5.13 gives T = w/(2 sin theta) for the symmetric case.
OpenStax, University Physics Vol. 1, Sec. 5.6 'Common Forces' (tension is a pulling force along a flexible connector; Example 5.13 T = w/(2 sin theta); g = 9.80 m/s^2), https://openstax.org/books/university-physics-volume-1/pages/5-6-common-forces
- verified The tension in each of two ropes holding up a box
From the sideways equation, .
Horizontal balance T1 cos(theta1) = T2 cos(theta2), as in Example 6.1.
OpenStax, University Physics Vol. 1, Sec. 6.1, Example 6.1 (traffic light on two wires: T1cos30=T2cos45, T1sin30+T2sin45=w), https://openstax.org/books/university-physics-volume-1/pages/6-1-solving-problems-with-newtons-laws
- verified The tension in each of two ropes holding up a box
Each rope's tension has the other rope's angle on top.
Solving the two balance equations gives T1 = W cos(theta2)/sin(theta1+theta2); checked algebraically.
OpenStax, University Physics Vol. 1, Sec. 6.1, Example 6.1 (traffic light on two wires: T1cos30=T2cos45, T1sin30+T2sin45=w), https://openstax.org/books/university-physics-volume-1/pages/6-1-solving-problems-with-newtons-laws
- verified The tension in each of two ropes holding up a box
At and the general formula gives (
tension_at_30_degrees), the same as the symmetric case.cos30/sin60 = 1, so T = W = 98 N for a 10 kg load; matches the symmetric result.
OpenStax, University Physics Vol. 1, Sec. 6.1, Example 6.1 (traffic light on two wires: T1cos30=T2cos45, T1sin30+T2sin45=w), https://openstax.org/books/university-physics-volume-1/pages/6-1-solving-problems-with-newtons-laws
- not-checkable The tension in each of two ropes holding up a box
The formulas came from a few lines of algebra, and algebra can go wrong.
Transition motivating the cross-check.
- verified The tension in each of two ropes holding up a box
A rope pulled perfectly flat would need infinite tension, because none of its pull would point up.
OpenStax Example 4.6: an infinite tension would result if the wire were horizontal.
OpenStax, College Physics 2e, Sec. 4.5, Example 4.6 (tightrope: T = w/(2 sin theta); infinite tension if horizontal), https://openstax.org/books/college-physics-2e/pages/4-5-normal-tension-and-other-examples-of-forces
- verified The tension in each of two ropes holding up a box
That is why a clothesline sags: no rope can be pulled tight enough to be straight while holding anything.
Follows from T = w/(2 sin theta) diverging at theta = 0, as OpenStax states for the tightrope.
OpenStax, College Physics 2e, Sec. 4.5, Example 4.6 (tightrope: T = w/(2 sin theta); infinite tension if horizontal), https://openstax.org/books/college-physics-2e/pages/4-5-normal-tension-and-other-examples-of-forces
- not-checkable The tension in each of two ropes holding up a box
Problems measure the angle in two ways, and mixing them up is a common mistake.
Rhetorical lead-in about angle conventions.
- verified The tension in each of two ropes holding up a box
If the angle is measured from the vertical instead of the ceiling, then , and becomes : The ropes at above the ceiling are at from the vertical.
With phi = 90 deg - theta, sin(theta) = cos(phi), so T = W/(2 cos phi); 30 deg from horizontal is 60 deg from vertical.
OpenStax, College Physics 2e, Sec. 4.5, Example 4.6 (tightrope: T = w/(2 sin theta); infinite tension if horizontal), https://openstax.org/books/college-physics-2e/pages/4-5-normal-tension-and-other-examples-of-forces
- not-checkable The tension in each of two ropes holding up a box
It does: (
tension_from_the_vertical).Reports the program's output.
- not-checkable The tension in each of two ropes holding up a box
Before using a formula, check which angle the problem gives you.
Advice to the reader.
- not-checkable The tension in each of two ropes holding up a box
Three quick checks find many mistakes.
Transition.
- verified The tension in each of two ropes holding up a box
If the two angles are equal, and should be equal.
OpenStax: tensions are equal if and only if the angles on either side are the same.
OpenStax, University Physics Vol. 1, Sec. 6.1, Example 6.1 (traffic light on two wires: T1cos30=T2cos45, T1sin30+T2sin45=w), https://openstax.org/books/university-physics-volume-1/pages/6-1-solving-problems-with-newtons-laws
- not-checkable The tension in each of two ropes holding up a box
A sign hangs from two wires at and above the horizontal.
Problem setup.
- verified The tension in each of two ropes holding up a box
The steeper wire carries more, as before.
36.6 N > 25.9 N; the steeper wire carries more, consistent with T1/T2 = cos(theta2)/cos(theta1).
OpenStax, University Physics Vol. 1, Sec. 6.1, Example 6.1 (traffic light on two wires: T1cos30=T2cos45, T1sin30+T2sin45=w), https://openstax.org/books/university-physics-volume-1/pages/6-1-solving-problems-with-newtons-laws
- verified Doubling time breaks at tiny rates and at negative ones
At a rate of a year it is off by a relative ; at it says the money never doubles; at it says the money doubled 13.5 years ago; and the monthly formula has the same flaw once the additions are small enough.
Checked in Python: relative error 8.9e-5 at 1e-12, log(1+1e-16) = 0 giving infinity, and ln2/ln0.95 = -13.5; the monthly formula has the same log(1+r/n) rounding.
D. Goldberg, What Every Computer Scientist Should Know About Floating-Point Arithmetic, Theorem 4 (ln(1+x) via x ln(1+x)/((1+x)-1)) and Table D-1 (double p=53), https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html; Local check: Python float, Decimal(1+1e-12)=1.0000000000010000889..., log(1+1e-12)/1e-12-1=8.9e-5, 1+1e-16==1, ln2/ln0.95=-13.51
- not-checkable Doubling time breaks at tiny rates and at negative ones
The site runs those four tests on the reviewed program and checks that each one fails there.
Describes the site's test mechanism.
- verified Doubling time breaks at tiny rates and at negative ones
A double carries about 16 digits, so the in is stored as , and the logarithm of the sum is off in its fifth digit.
Double has 53 bits (~16 digits); in Python (1 + 1e-12) - 1 = 1.000088900582341e-12, so the stored 1e-12 is 1.00009e-12 and log(1 + 1e-12) is off by 8.9e-5 relative, the fifth digit.
D. Goldberg, What Every Computer Scientist Should Know About Floating-Point Arithmetic, Theorem 4 (ln(1+x) via x ln(1+x)/((1+x)-1)) and Table D-1 (double p=53), https://docs.oracle.com/cd/E19957-01/806-3568/ncg_goldberg.html; Local check: Python float, Decimal(1+1e-12)=1.0000000000010000889..., log(1+1e-12)/1e-12-1=8.9e-5, 1+1e-16==1, ln2/ln0.95=-13.51
- not-checkable Doubling time, fixed for tiny and negative rates
The logarithm of is computed without the rounding that lost the small rates, and a rate that is not positive gets an infinite doubling time.
Describes what the program's fix does.
- not-checkable Doubling time, fixed for tiny and negative rates
The fix makes two changes.
Transition.
- not-checkable Doubling time, fixed for tiny and negative rates
First,
ln_one_pluscomputes for small without losing it to rounding.Describes the program's function; the method is Goldberg's Theorem 4.
- not-checkable Hartree-Fock for water
Water in the STO-3G basis, from the basis to the restricted Hartree-Fock energy, using
lib/hf, a library whose tests compare it against PySCF.Describes the program and its library tests.
- not-checkable Hartree-Fock for water
The overlap , kinetic energy and nuclear attraction matrices.
Fragment naming matrices the program computes.
- not-checkable Hartree-Fock for water
lib/hfhas more than one implementation of each (three for and , two for ).Describes the library's implementations.
- plausible Hartree-Fock for water
The electron repulsion integrals , 406 of them once the eightfold permutation symmetry is used.
Not accessed; from general knowledge: with eightfold symmetry the unique ERIs for N=7 number M(M+1)/2 with M = N(N+1)/2 = 28, which is 406.
Local check: 7 functions -> 28 pairs -> 28*29/2 = 406
- verified Hartree-Fock for water
Two independent methods compute them: McMurchie-Davidson, which expands each product of Gaussians in Hermite Gaussians, and Head-Gordon-Pople, which runs the Obara-Saika vertical recurrence and then the horizontal one.
Fermann-Valeev Sec. 7: MD uses recurrences over Hermite Gaussians; HGP combines the Obara-Saika VRR with the HRR.
L. McMurchie and E. Davidson, One- and two-electron integrals over Cartesian Gaussian functions, J. Comput. Phys. 26, 218 (1978), https://ui.adsabs.harvard.edu/abs/1978JCoPh..26..218M/abstract; M. Head-Gordon and J. A. Pople, J. Chem. Phys. 89, 5777 (1988), abstract: Obara-Saika RR plus a new RR applied outside contraction loops, https://ui.adsabs.harvard.edu/abs/1988JChPh..89.5777H/abstract; J. T. Fermann and E. F. Valeev, Fundamentals of Molecular Integrals Evaluation, Sec. 7 (MD over Hermite Gaussians; OS VRR eq. 7.23 and HRR eq. 7.24), https://arxiv.org/abs/2007.12057
- plausible Hartree-Fock for water
They share no recurrence.
The MD Hermite recurrences and the OS VRR/HRR are different relations, though both start from the Boys function F_m(T), which is usually evaluated with its own recurrence.
J. T. Fermann and E. F. Valeev, Fundamentals of Molecular Integrals Evaluation, Sec. 7 (MD over Hermite Gaussians; OS VRR eq. 7.23 and HRR eq. 7.24), https://arxiv.org/abs/2007.12057
- verified Hartree-Fock for water
It solves repeatedly until the change in energy and the commutator both fall below their tolerances, and is the formula above.
The SCF loop stops on both the energy change and the commutator norm.
lib/hf/rhf.viv hf_scf_loop (read): stops when it > 1, |E - E_prev| < etol and err < gtol, err = den_error; lib/hf/density.viv den_error (read): max |F'P' - P'F'| in the orthogonal basis, the commutator
- not-checkable Hartree-Fock for water
The figure moves the two hydrogens along their O-H bonds, keeping the angle, and reruns the whole calculation at five more bond lengths, using only the default implementations.
Describes the program's figure.
- not-checkable Hartree-Fock for water
Each energy is checked against PySCF at the same geometry.
Describes the program's checks.
- verified Hartree-Fock for water
The stored geometry has O-H at 0.958 angstrom, close to the experimental bond length, so STO-3G makes the bond about 3 percent too long.
Experimental re(OH) = 0.958 A; 0.987/0.958 = 1.030, so about 3 percent too long.
NIST CCCBDB, experimental geometry of H2O: rOH = 0.958 A, angle 104.48 deg (Hoy and Bunker 1979), https://cccbdb.nist.gov/expgeom2x.asp?casno=7732185
- verified LOBPCG finds the lowest states of a particle in a box
The grid Hamiltonian is then a symmetric matrix with rows.
24 x 24 = 576 unknowns; the five-point Laplacian with Dirichlet boundaries is symmetric.
Wikipedia, Eigenvalues and eigenvectors of the second derivative, Dirichlet case: lambda_j = -(4/h^2) sin^2(pi j/(2(n+1))), https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors_of_the_second_derivative
- verified LOBPCG finds the lowest states of a particle in a box
Its eigenvalues are known exactly, so every number the solver produces can be checked.
The Dirichlet discrete Laplacian has closed-form eigenvalues; in 2-D they are sums of the 1-D ones.
Wikipedia, Eigenvalues and eigenvectors of the second derivative, Dirichlet case: lambda_j = -(4/h^2) sin^2(pi j/(2(n+1))), https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors_of_the_second_derivative
- not-checkable LOBPCG finds the lowest states of a particle in a box
The mode with half-waves across and down has energy
Lead-in to a formula.
- verified LOBPCG finds the lowest states of a particle in a box
1-D eigenvalue (2 - 2cos(j pi/(n+1)))/h^2 with n+1 = 25; the 2-D sum times 1/2 for H = -(1/2) Laplacian.
Wikipedia, Eigenvalues and eigenvectors of the second derivative, Dirichlet case: lambda_j = -(4/h^2) sin^2(pi j/(2(n+1))), https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors_of_the_second_derivative
- verified LOBPCG finds the lowest states of a particle in a box
a little below the continuous box's .
(4/h^2) sin^2(x/2) < x^2/h^2, so each discrete eigenvalue sits below pi^2 (j^2+k^2)/2.
Wikipedia, Eigenvalues and eigenvectors of the second derivative, Dirichlet case: lambda_j = -(4/h^2) sin^2(pi j/(2(n+1))), https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors_of_the_second_derivative
- verified LOBPCG finds the lowest states of a particle in a box
We want the lowest six: , then and , which have the same energy, then , then and , again a pair.
Computed from the formula: (1,1), (1,2)=(2,1), (2,2), (1,3)=(3,1), then (2,3).
Wikipedia, Eigenvalues and eigenvectors of the second derivative, Dirichlet case: lambda_j = -(4/h^2) sin^2(pi j/(2(n+1))), https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors_of_the_second_derivative
- not-checkable LOBPCG finds the lowest states of a particle in a box
We want six of them.
Statement of the goal.
- verified LOBPCG finds the lowest states of a particle in a box
Worse, the matrix has to exist: numbers, of which at most five per row are not zero.
A five-point stencil gives at most five nonzeros per row of a 576 x 576 matrix.
Wikipedia, Eigenvalues and eigenvectors of the second derivative, Dirichlet case: lambda_j = -(4/h^2) sin^2(pi j/(2(n+1))), https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors_of_the_second_derivative
- not-checkable LOBPCG finds the lowest states of a particle in a box
In this program that is
apply_box, a few whole-array shifts.Describes the program.
- verified LOBPCG finds the lowest states of a particle in a box
In the plane-wave DFT code on this site it is two FFTs and a projector sum, and the difference is measured: silicon with the matrix built and diagonalized at every k-point takes several times as long as with this solver (the timings, native on one core, are in
dft/README.md).Dense takes about 8 times as long as the LOBPCG engine for silicon; the table is in dft/README.md.
dft/README.md timing table (read): Si, one core of an Apple M2 Pro, dense 55 s, iterative (LOBPCG) 7 s
- verified LOBPCG finds the lowest states of a particle in a box
The Rayleigh quotient of a vector is .
Standard definition x^H H x / x^H x.
Wikipedia, Rayleigh quotient (definition x*Mx/x*x; weighted average of eigenvalues; min = lambda_min), https://en.wikipedia.org/wiki/Rayleigh_quotient; D. Bindel, CS 6210 notes, Rayleigh quotients revisited (Fall 2012): derivative of rho_A, rho a weighted average of eigenvalues, lambda_min = min rho, Courant-Fischer, block Rayleigh quotient V*AV, https://www.cs.cornell.edu/~bindel/class/cs6210-f12/notes/lec29.pdf
- verified LOBPCG finds the lowest states of a particle in a box
An average is smallest when all the weight sits on the smallest value, so the minimum of over all vectors is , reached at the ground state.
Bindel: rho is a weighted average of eigenvalues and lambda_min = min rho.
Wikipedia, Rayleigh quotient (definition x*Mx/x*x; weighted average of eigenvalues; min = lambda_min), https://en.wikipedia.org/wiki/Rayleigh_quotient; D. Bindel, CS 6210 notes, Rayleigh quotients revisited (Fall 2012): derivative of rho_A, rho a weighted average of eigenvalues, lambda_min = min rho, Courant-Fischer, block Rayleigh quotient V*AV, https://www.cs.cornell.edu/~bindel/class/cs6210-f12/notes/lec29.pdf
- verified LOBPCG finds the lowest states of a particle in a box
Finding the lowest eigenvector is therefore a minimization.
Variational characterization lambda_min = min rho.
D. Bindel, CS 6210 notes, Rayleigh quotients revisited (Fall 2012): derivative of rho_A, rho a weighted average of eigenvalues, lambda_min = min rho, Courant-Fischer, block Rayleigh quotient V*AV, https://www.cs.cornell.edu/~bindel/class/cs6210-f12/notes/lec29.pdf
- verified LOBPCG finds the lowest states of a particle in a box
The gradient of is .
Differentiating rho by the quotient rule gives gradient 2(Hx - rho x)/(x^H x) for real symmetric H.
D. Bindel, CS 6210 notes, Rayleigh quotients revisited (Fall 2012): derivative of rho_A, rho a weighted average of eigenvalues, lambda_min = min rho, Courant-Fischer, block Rayleigh quotient V*AV, https://www.cs.cornell.edu/~bindel/class/cs6210-f12/notes/lec29.pdf
- plausible LOBPCG finds the lowest states of a particle in a box
The vector is the residual: it is zero exactly when is an eigenvector, and its norm bounds how far is from the nearest eigenvalue.
Bindel notes small residual means nearby eigenvalue; the exact bound min|lambda - rho| <= ||r||/||x|| (Parlett, Thm 4.5.1) not accessed; from general knowledge.
D. Bindel, CS 6210 notes, Rayleigh quotients revisited (Fall 2012): derivative of rho_A, rho a weighted average of eigenvalues, lambda_min = min rho, Courant-Fischer, block Rayleigh quotient V*AV, https://www.cs.cornell.edu/~bindel/class/cs6210-f12/notes/lec29.pdf
- verified LOBPCG finds the lowest states of a particle in a box
So the direction downhill costs one application of , and the residual's norm tells you when to stop.
The gradient needs only Hx; residual norm is the natural stopping test.
D. Bindel, CS 6210 notes, Rayleigh quotients revisited (Fall 2012): derivative of rho_A, rho a weighted average of eigenvalues, lambda_min = min rho, Courant-Fischer, block Rayleigh quotient V*AV, https://www.cs.cornell.edu/~bindel/class/cs6210-f12/notes/lec29.pdf
- verified LOBPCG finds the lowest states of a particle in a box
For the lowest several states, carry several vectors at once, kept orthonormal.
Block methods carry several orthonormal vectors (block Rayleigh quotient V*AV with V*V = I).
A. V. Knyazev, Toward the Optimal Preconditioned Eigensolver: LOBPCG, SIAM J. Sci. Comput. 23(2), 517-541 (2001), as summarized at https://en.wikipedia.org/wiki/LOBPCG (span{x, w, previous}, Rayleigh-Ritz, CG generalization); D. Bindel, CS 6210 notes, Rayleigh quotients revisited (Fall 2012): derivative of rho_A, rho a weighted average of eigenvalues, lambda_min = min rho, Courant-Fischer, block Rayleigh quotient V*AV, https://www.cs.cornell.edu/~bindel/class/cs6210-f12/notes/lec29.pdf
- verified LOBPCG finds the lowest states of a particle in a box
The lowest eigenvalues are what the Rayleigh quotients add up to at the minimum, and the vectors that reach it span the lowest eigenvectors.
Ky Fan: min trace over orthonormal k-frames equals the sum of the k smallest eigenvalues, attained by the lowest invariant subspace (when there is a gap).
Ky Fan (1949) trace minimization: min tr(U H U*) over UU*=I_k equals the sum of the k smallest eigenvalues, as stated in Liang, Wang, Zhang, On generalizing trace minimization principles, https://archive.ymsc.tsinghua.edu.cn/pacm_download/278/12759-liwz2023.pdf (search summary)
- verified LOBPCG finds the lowest states of a particle in a box
Steepest descent would move each vector along its residual, , with chosen to make as small as possible.
Steepest descent with exact line search along the residual (gradient) direction.
J. R. Shewchuk, An Introduction to the Conjugate Gradient Method Without the Agonizing Pain, Sec. 6 and Fig. 8 (zigzag path because each gradient is orthogonal to the previous one), https://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf
- verified LOBPCG finds the lowest states of a particle in a box
Choosing that is itself a small eigenvalue problem.
Minimizing rho over span{x, r} is a 2 x 2 Rayleigh-Ritz eigenproblem.
A. V. Knyazev, Toward the Optimal Preconditioned Eigensolver: LOBPCG, SIAM J. Sci. Comput. 23(2), 517-541 (2001), as summarized at https://en.wikipedia.org/wiki/LOBPCG (span{x, w, previous}, Rayleigh-Ritz, CG generalization); D. Bindel, CS 6210 notes, Rayleigh quotients revisited (Fall 2012): derivative of rho_A, rho a weighted average of eigenvalues, lambda_min = min rho, Courant-Fischer, block Rayleigh quotient V*AV, https://www.cs.cornell.edu/~bindel/class/cs6210-f12/notes/lec29.pdf
- verified LOBPCG finds the lowest states of a particle in a box
For any set of orthonormal vectors (as rows), the best combinations of them are found by forming the small matrix and diagonalizing it; its eigenvalues are the lowest Rayleigh quotients available in the span of (Ritz values) and its eigenvectors say which combinations reach them (Ritz vectors).
Rayleigh-Ritz: projected matrix V*AV; its eigenvalues are Ritz values, eigenvectors give Ritz vectors.
D. Bindel, CS 6210 notes, Rayleigh quotients revisited (Fall 2012): derivative of rho_A, rho a weighted average of eigenvalues, lambda_min = min rho, Courant-Fischer, block Rayleigh quotient V*AV, https://www.cs.cornell.edu/~bindel/class/cs6210-f12/notes/lec29.pdf; A. V. Knyazev, Toward the Optimal Preconditioned Eigensolver: LOBPCG, SIAM J. Sci. Comput. 23(2), 517-541 (2001), as summarized at https://en.wikipedia.org/wiki/LOBPCG (span{x, w, previous}, Rayleigh-Ritz, CG generalization)
- verified LOBPCG finds the lowest states of a particle in a box
This is called Rayleigh-Ritz.
Standard name, used in LOBPCG.
A. V. Knyazev, Toward the Optimal Preconditioned Eigensolver: LOBPCG, SIAM J. Sci. Comput. 23(2), 517-541 (2001), as summarized at https://en.wikipedia.org/wiki/LOBPCG (span{x, w, previous}, Rayleigh-Ritz, CG generalization)
- verified LOBPCG finds the lowest states of a particle in a box
LOBPCG searches a bigger span.
LOBPCG uses span{x, w, p}, larger than steepest descent's span{x, w}.
A. V. Knyazev, Toward the Optimal Preconditioned Eigensolver: LOBPCG, SIAM J. Sci. Comput. 23(2), 517-541 (2001), as summarized at https://en.wikipedia.org/wiki/LOBPCG (span{x, w, previous}, Rayleigh-Ritz, CG generalization)
- verified LOBPCG finds the lowest states of a particle in a box
x, the current approximations,
First LOBPCG block: current approximations.
A. V. Knyazev, Toward the Optimal Preconditioned Eigensolver: LOBPCG, SIAM J. Sci. Comput. 23(2), 517-541 (2001), as summarized at https://en.wikipedia.org/wiki/LOBPCG (span{x, w, previous}, Rayleigh-Ritz, CG generalization)
- plausible LOBPCG finds the lowest states of a particle in a box
w, their residuals, made orthogonal to x and scaled to unit length, and
Second block is the (preconditioned) residual; orthogonalizing it against x and normalizing is an implementation choice for stability, which the LOBPCG article mentions.
A. V. Knyazev, Toward the Optimal Preconditioned Eigensolver: LOBPCG, SIAM J. Sci. Comput. 23(2), 517-541 (2001), as summarized at https://en.wikipedia.org/wiki/LOBPCG (span{x, w, previous}, Rayleigh-Ritz, CG generalization)
- verified LOBPCG finds the lowest states of a particle in a box
The third block is the conjugate-gradient idea.
LOBPCG is a generalization of preconditioned CG to eigenproblems; p plays the role of the CG direction.
A. V. Knyazev, Toward the Optimal Preconditioned Eigensolver: LOBPCG, SIAM J. Sci. Comput. 23(2), 517-541 (2001), as summarized at https://en.wikipedia.org/wiki/LOBPCG (span{x, w, previous}, Rayleigh-Ritz, CG generalization)
- verified LOBPCG finds the lowest states of a particle in a box
Steepest descent on a long, narrow valley zigzags from wall to wall, because each new step undoes part of the last one.
Shewchuk Fig. 8: steepest descent zigzags because each gradient is orthogonal to the previous one.
J. R. Shewchuk, An Introduction to the Conjugate Gradient Method Without the Agonizing Pain, Sec. 6 and Fig. 8 (zigzag path because each gradient is orthogonal to the previous one), https://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf
- verified LOBPCG finds the lowest states of a particle in a box
"Locally optimal" means that instead of a formula for the step it takes the best point in the span of all three.
LOBPCG's update is the Rayleigh-Ritz maximizer/minimizer over span{x, w, previous step}, which is what 'locally optimal' refers to.
Wikipedia, 'LOBPCG' (pointer to Knyazev, SIAM J. Sci. Comput. 23(2), 517-541, 2001), https://en.wikipedia.org/wiki/LOBPCG
- plausible LOBPCG finds the lowest states of a particle in a box
The spares are there because the highest vectors in a block converge slowest: nothing above them in the block keeps them separated from the rest of the spectrum.
Wikipedia notes larger blocks help when some eigenvectors converge slower; the rate for the k-th vector depends on its gap to the first vector outside the block, so extra vectors speed the top wanted ones. The exact phrasing is informal; source only partly accessed.
Wikipedia, 'LOBPCG' (pointer to Knyazev, SIAM J. Sci. Comput. 23(2), 517-541, 2001), https://en.wikipedia.org/wiki/LOBPCG
- verified LOBPCG finds the lowest states of a particle in a box
Degenerate pairs need no special treatment: any combination of and is an eigenvector with the same energy, and the block converges to some orthonormal pair spanning that plane.
Any combination of degenerate eigenvectors is an eigenvector, and block LOBPCG is noted to handle multiple and clustered eigenvalues well.
Wikipedia, 'LOBPCG' (pointer to Knyazev, SIAM J. Sci. Comput. 23(2), 517-541, 2001), https://en.wikipedia.org/wiki/LOBPCG; Direct check: E_jk is symmetric in j,k, so (1,2) and (2,1) are degenerate
- plausible LOBPCG finds the lowest states of a particle in a box
The P in the name is for preconditioner: replace by an approximation to , which points closer to the correction needed.
LOBPCG applies a preconditioner T to the residual (w = T r); approximating (H - sigma)^{-1} is the usual heuristic, though Wikipedia does not state that exact form. Partly from general knowledge.
Wikipedia, 'LOBPCG' (pointer to Knyazev, SIAM J. Sci. Comput. 23(2), 517-541, 2001), https://en.wikipedia.org/wiki/LOBPCG
- not-checkable LOBPCG finds the lowest states of a particle in a box
The DFT engine uses one built from the kinetic energy.
Describes the site's DFT engine.
- verified LOBPCG finds the lowest states of a particle in a box
It stays in the Rayleigh-Ritz step, though, so it still improves from the other states' directions.
This is soft locking: locked vectors skip the residual computation but stay in the Rayleigh-Ritz step, as Wikipedia describes (after Knyazev et al., BLOPEX).
Wikipedia, 'LOBPCG' (pointer to Knyazev, SIAM J. Sci. Comput. 23(2), 517-541, 2001), https://en.wikipedia.org/wiki/LOBPCG
- verified LOBPCG finds the lowest states of a particle in a box
The eigenvalues get good much sooner than the vectors do.
Eigenvectors are stationary points of the Rayleigh quotient, so eigenvalue estimates converge about quadratically faster than the vectors.
Wikipedia, 'Rayleigh quotient' (stationary points at eigenvectors; min is lambda_min), https://en.wikipedia.org/wiki/Rayleigh_quotient
- not-checkable LOBPCG finds the lowest states of a particle in a box
At step 50 the worst residual norm is and the worst eigenvalue error is .
Numbers from this run.
- verified LOBPCG finds the lowest states of a particle in a box
That is because is flat at an eigenvector: an error in the vector moves the Rayleigh quotient by about .
Eigenvectors are critical points of the Rayleigh quotient, so a first-order vector error changes it only at second order.
Wikipedia, 'Rayleigh quotient' (stationary points at eigenvectors; min is lambda_min), https://en.wikipedia.org/wiki/Rayleigh_quotient
- not-checkable LOBPCG finds the lowest states of a particle in a box
The levels also sit where they should relative to the continuous box.
Transition to the next sentence's check.
- verified LOBPCG finds the lowest states of a particle in a box
The five-point stencil drops the term of the second derivative's Taylor series, which lowers each level by about ; the measured shifts match that to within half a percent.
The leading error of the second difference gives a downward shift h^2 (j pi)^4/24 per direction for H = -1/2 Laplacian; the next term changes that by at most 0.47% for the listed levels. Taylor expansion done here, not read from a textbook.
Taylor series: 2 - 2cos(theta) = theta^2 - theta^4/12 + theta^6/360; checked numerically for (j,k) up to (1,3), h = 1/25
- verified Muon orthogonalizes the update
Five Newton-Schulz steps get close to that without an SVD.
Muon uses 5 Newton-Schulz steps to approximately orthogonalize the update without an SVD.
Keller Jordan, 'Muon: An optimizer for hidden layers in neural networks' (blog, 2024), https://kellerjordan.github.io/posts/muon/
- verified Muon orthogonalizes the update
When the singular values are lopsided, the few large ones get nearly all of the movement and the small ones almost none.
Follows from the previous sentence; movement along each pair is proportional to its singular value.
Algebra: -lr G = -lr sum_i s_i u_i v_i^T
- not-checkable Muon orthogonalizes the update
The problem here is built to show that.
Describes this post's test problem.
- not-checkable Muon orthogonalizes the update
A direction the inputs barely excite gets a gradient ten thousand times weaker than the loudest one, and SGD's step along it is ten thousand times shorter.
Describes this problem: S S^T has eigenvalues 1 to 1e-4, so for the same error the gradient along the quietest direction is 1e-4 times smaller.
- plausible Muon orthogonalizes the update
Muon does it one direction of the matrix at a time, and those directions need not line up with the entries.
Orthogonalization acts on the singular directions of the whole matrix, which are generally not aligned with the coordinate axes. The comparison with Adam is the post's own.
Keller Jordan, 'Muon: An optimizer for hidden layers in neural networks' (blog, 2024), https://kellerjordan.github.io/posts/muon/
- verified Muon orthogonalizes the update
The coefficients (3.4445, -4.7750, 2.0315) match Jordan's quintic Newton-Schulz iteration.
Keller Jordan, 'Muon: An optimizer for hidden layers in neural networks' (blog, 2024), https://kellerjordan.github.io/posts/muon/
- verified Muon orthogonalizes the update
The directions never move.
Follows from the previous sentence, as long as p(s) stays positive, which it does for these coefficients on (0, 1.2].
Algebra: odd polynomial p(X) = U p(S) V^T
- verified Muon orthogonalizes the update
The coefficients were tuned for speed near zero.
Jordan picks the coefficients to maximize a = p'(0), the growth rate for small singular values, while keeping the converged values in a band.
Keller Jordan, 'Muon: An optimizer for hidden layers in neural networks' (blog, 2024), https://kellerjordan.github.io/posts/muon/
- not-checkable Muon orthogonalizes the update
On the first gradient here, the singular values after dividing by the norm are
Introduces this run's numbers.
- not-checkable Muon orthogonalizes the update
and after five steps they are
Introduces this run's numbers.
- not-checkable Muon orthogonalizes the update
The five largest are in the band.
About this run's output, compared with the band the library measures.
- not-checkable Muon orthogonalizes the update
Each gets its best starting step size from the same grid,
0.01 * 2^gforg = 0, ..., 10, judged by how far it ends from the true map in the Frobenius norm.Describes this program's step-size sweep.
- not-checkable Muon orthogonalizes the update
Muon's entry is a range because its result depends on rounding.
Describes this run.
- verified Muon orthogonalizes the update
Newton-Schulz enlarges a small singular value by up to about 485 times, whatever put it there, and a rounding error in the momentum is no exception.
Replaces disputed a8d2c7d04c6a.
3.4445^5 = 484.876 (computed); p(s)/s = a + b s^2 + c s^4 with b < 0 is at most a = 3.4445 for small s, so five steps enlarge by at most about 485; posts/2026-09-24-muon-orthogonalizes-the-update.viv test: measured ratio 484.872
- not-checkable Muon orthogonalizes the update
The quietest input direction shows why.
Transition.
- not-checkable Muon orthogonalizes the update
Measured by training loss instead, Muon is behind.
Result of this run.
- plausible Muon orthogonalizes the update
The quiet directions are the ones the loss hardly counts, so an optimizer can leave them alone and still reach a low loss.
Follows from the form of the loss: an error along a direction with eigenvalue 1e-4 adds little to it.
Not accessed; from general knowledge: loss |(W - W*) S|^2/2 weights the error along each input direction by that direction's eigenvalue of S S^T (down to 1e-4)
- plausible Muon orthogonalizes the update
Getting them right matters once the model sees inputs that point along them more than the training inputs did.
If test inputs have larger components along the quiet directions, the error left in those directions shows up in the output.
Not accessed; from general knowledge (generalization under covariate shift)
- not-checkable Muon orthogonalizes the update
The optimizers are in
lib/optim, over the parameter layout oflib/params, and the Newton-Schulz iteration is inlib/polar.Describes the library layout.
- not-checkable Muon orthogonalizes the update
The transformer post in this channel trains with the same
muonstep.Refers to another post on the site.
- not-checkable Newton's method doubles the correct digits
A notebook: the prose between the cells says what each one is for, and each cell's output appears under it.
Describes the post format.
- verified Newton's method doubles the correct digits
Already is close to 2.
Arithmetic is correct.
Arithmetic: 1.5 x 1.5 = 2.25; x_1 = 1 - (1-2)/2 = 1.5 is the first Newton step from x_0 = 1; Wikipedia, 'Newton's method' (quadratic convergence, error relation), https://en.wikipedia.org/wiki/Newton%27s_method
- verified Newton's method doubles the correct digits
The identity holds exactly; it is the f''/(2f') e^2 error relation Wikipedia gives, with f = x^2 - 2.
Algebra: x - (x^2-2)/(2x) - sqrt2 = (x^2 - 2 sqrt2 x + 2)/(2x) = (x - sqrt2)^2/(2x); Wikipedia, 'Newton's method' (quadratic convergence, error relation), https://en.wikipedia.org/wiki/Newton%27s_method
- verified Newton's method doubles the correct digits
An error of becomes , then : the number of correct digits doubles.
e_{n+1} = e_n^2/(2 x_n): 1e-6/2.8304 = 3.53e-7, then (3.53e-7)^2/2.8284 = 4.4e-14; the program tests both steps.
Wikipedia, 'Newton's method' (quadratic convergence, error relation), https://en.wikipedia.org/wiki/Newton%27s_method; Direct computation: (1e-3)^2/(2 sqrt2) = 3.5e-7, then (3.5e-7)^2/(2 sqrt2) = 4.4e-14
- verified Newton's method doubles the correct digits
Far from the root the ratio is with still far from ; by the fourth step it matches to four digits.
The ratio is exactly 1/(2x_n), and by the fourth step x_3 agrees with sqrt 2 to about six digits, so four digits is correct.
Algebra from the identity above: e_{n+1}/e_n^2 = 1/(2 x_n) exactly; x_3 = 1.4142157 differs from sqrt2 by 1.5e-6 relative; Wikipedia, 'Newton's method' (quadratic convergence, error relation), https://en.wikipedia.org/wiki/Newton%27s_method
- verified Newton's method doubles the correct digits
Bisection keeps an interval where changes sign and halves it.
Bisection keeps a sign-change interval and halves it each step.
Wikipedia, 'Bisection method', https://en.wikipedia.org/wiki/Bisection_method
- verified Newton's method doubles the correct digits
After halvings of the midpoint is within of the root, one binary digit per step, and that guarantee is all it has: it never fails, and it never speeds up.
The bound and the guaranteed-but-linear convergence match the standard description.
Wikipedia, 'Bisection method', https://en.wikipedia.org/wiki/Bisection_method; Arithmetic: after k halvings the interval has width 2^-k, so its midpoint is within 2^-(k+1) of the root
- not-checkable Newton's method doubles the correct digits
Newton's curve bends down; bisection's is a straight line.
Describes the post's figure (log error against step).
- verified The rule of 72 against the rule of 70
Above a rate of 4.90% a year it is closer to the exact doubling time than the rule of 70, and below that the rule of 70 is closer; at 8% the rule of 72 is off by 0.07%.
The crossover and the error at 8% check out; Wikipedia says the rule of 72 is best near 6-10% and the rule of 70 at lower rates.
Wikipedia, 'Rule of 72' (exact t = ln2/ln(1+r); t ~ 69.3/r + 0.35; divisors of 72), https://en.wikipedia.org/wiki/Rule_of_72; Direct computation: 100 r ln2/ln(1+r) = 71 at r = 0.049018; at r = 0.08 the exact time is 9.0065 years, so 9 is off by 0.072%
- not-checkable The rule of 72 against the rule of 70
The original four tests are kept word for word.
Describes the post's tests.
- verified The rule of 72 against the rule of 70
Both rules approximate .
The exact doubling time is ln 2 / ln(1 + r).
Wikipedia, 'Rule of 72' (exact t = ln2/ln(1+r); t ~ 69.3/r + 0.35; divisors of 72), https://en.wikipedia.org/wiki/Rule_of_72
- verified The rule of 72 against the rule of 70
Expanding the logarithm one more term gives , so the exact time, multiplied by , is not a constant: it is 69.3 plus about .
100 r t is approximately 69.3 + 34.7 r, matching Wikipedia's t ~ 69.3/R + 0.35 with R in percent.
Wikipedia, 'Rule of 72' (exact t = ln2/ln(1+r); t ~ 69.3/r + 0.35; divisors of 72), https://en.wikipedia.org/wiki/Rule_of_72; Series: ln(1+r) = r - r^2/2 + ..., so ln2/ln(1+r) = (ln2/r)(1 + r/2 + ...)
- verified The rule of 72 against the rule of 70
At 3% that is 70.3, and 70 is the closer rule; at 8% it is 72.1, and 72 is.
The first-order formula gives 70.3 and 72.1, and the exact values are 70.35 and 72.05, so the conclusions hold.
Direct computation: 100 r ln2/ln(1+r) = 70.35 at r = 0.03 and 72.05 at r = 0.08; Wikipedia, 'Rule of 72' (exact t = ln2/ln(1+r); t ~ 69.3/r + 0.35; divisors of 72), https://en.wikipedia.org/wiki/Rule_of_72
- verified The rule of 72 against the rule of 70
: the same thing with and .
Same approximation as the rule of 70 derivation.
Wikipedia, 'Rule of 72', derivation (t = ln 2 / ln(1+r), ln(1+r) ~ r, ln 2 ~ 0.693) and rule of 70, https://en.wikipedia.org/wiki/Rule_of_72
- verified The rule of 72 against the rule of 70
: the version for mental arithmetic, since 72 divides by 2, 3, 4, 6, 8, 9 and 12.
Wikipedia lists 72's small divisors as 1, 2, 3, 4, 6, 8, 9, 12 and gives this as the reason for the choice.
Wikipedia, 'Rule of 72' (exact t = ln2/ln(1+r); t ~ 69.3/r + 0.35; divisors of 72), https://en.wikipedia.org/wiki/Rule_of_72
- verified Two methods compute water's 6-31G integrals
McMurchie-Davidson and Head-Gordon-Pople compute the same 4186 electron repulsion integrals for water in the 6-31G basis by different recurrences.
MD uses Hermite-Gaussian recurrences, HGP uses the OS VRR plus HRR; the 4186 count follows from 13 functions and eightfold symmetry.
J. T. Fermann and E. F. Valeev, 'Fundamentals of Molecular Integrals Evaluation', arXiv:2007.12057, Sec. 7 (MD, OS VRR eq. 7.23, HGP HRR eq. 7.24); Count: 13 functions -> 91 pairs -> 91*92/2 = 4186 unique integrals
- not-checkable Two methods compute water's 6-31G integrals
They agree to rounding, each matches PySCF, and each one alone gives PySCF's Hartree-Fock energy.
Results of this program's tests against PySCF.
- plausible Two methods compute water's 6-31G integrals
The electron repulsion integrals are most of the cost of a Hartree-Fock calculation and the easiest place for a bug that does not announce itself.
Fermann and Valeev treat ERI evaluation as the computational core of Gaussian-basis methods; 'most of the cost' holds for conventional HF on small molecules but depends on the algorithm. The second half is rhetorical.
J. T. Fermann and E. F. Valeev, 'Fundamentals of Molecular Integrals Evaluation', arXiv:2007.12057, Sec. 7 (MD, OS VRR eq. 7.23, HGP HRR eq. 7.24)
- not-checkable Two methods compute water's 6-31G integrals
lib/hfcomputes them more than one way and compares the answers.Describes the library.
- verified Two methods compute water's 6-31G integrals
This post takes the two methods the library cross-checks by default and runs each one alone on water in 6-31G: 13 basis functions and 4186 integrals after the eightfold permutation symmetry.
9 + 2 + 2 = 13 basis functions, and n(n+1)/2 pairs taken pairwise gives 4186 unique integrals.
Basis Set Exchange, 6-31G: O has [3s2p] = 9 functions, H has [2s] = 2 each (not re-accessed; general knowledge); Count: 91 pairs -> 4186
- verified Two methods compute water's 6-31G integrals
McMurchie-Davidson writes each product of two Gaussians as a sum of Hermite Gaussians.
In McMurchie-Davidson, the product of two Cartesian Gaussians is expanded in Hermite Gaussians with E coefficients (Asadchev-Valeev eq. 8).
A. Asadchev and E. F. Valeev, 'Implementation of McMurchie-Davidson algorithm for Gaussian AO integrals suited for SIMD processors', arXiv:2506.12501, eqs. 8, 25, 32-33; J. T. Fermann and E. F. Valeev, 'Fundamentals of Molecular Integrals Evaluation', arXiv:2007.12057, Sec. 7 (MD, OS VRR eq. 7.23, HGP HRR eq. 7.24)
- verified Two methods compute water's 6-31G integrals
The integral becomes two matrix products over those expansions and the Hermite Coulomb integrals at the distance between the two product centers.
The ERI is the bra and ket E-coefficient expansions contracted against Hermite Coulomb integrals R_{t+tau,u+nu,v+phi}(alpha, R_PQ) (eq. 25), and implementations write these contractions as matrix products (eqs. 32-33).
A. Asadchev and E. F. Valeev, 'Implementation of McMurchie-Davidson algorithm for Gaussian AO integrals suited for SIMD processors', arXiv:2506.12501, eqs. 8, 25, 32-33
- verified Two methods compute water's 6-31G integrals
Head-Gordon-Pople starts from Obara and Saika's vertical recurrence, which builds up the angular momentum on one center of each pair, primitive by primitive.
HGP's VRR (eq. 7.23) is the OS relation with b = d = 0, building [e0|f0] on centers A and C for each primitive combination.
J. T. Fermann and E. F. Valeev, 'Fundamentals of Molecular Integrals Evaluation', arXiv:2007.12057, Sec. 7 (MD, OS VRR eq. 7.23, HGP HRR eq. 7.24)
- verified Two methods compute water's 6-31G integrals
A horizontal recurrence then moves it onto the other center once per contracted shell quartet.
The HRR (eq. 7.24) moves angular momentum from A and C to B and D and depends only on geometry, so it is applied after contraction.
J. T. Fermann and E. F. Valeev, 'Fundamentals of Molecular Integrals Evaluation', arXiv:2007.12057, Sec. 7 (MD, OS VRR eq. 7.23, HGP HRR eq. 7.24)
- plausible Two methods compute water's 6-31G integrals
They share no recurrence.
The MD Hermite recurrences and the OS VRR/HRR are different relations, though both start from the Boys function F_m(T), which is usually evaluated with its own recurrence.
J. T. Fermann and E. F. Valeev, Fundamentals of Molecular Integrals Evaluation, Sec. 7 (MD over Hermite Gaussians; OS VRR eq. 7.23 and HRR eq. 7.24), https://arxiv.org/abs/2007.12057
- verified Two methods compute water's 6-31G integrals
Both take the Boys function from
lib/hf/boys, which is checked on its own against mpmath values (tools/boys_reference.py).lib/hf/boys is held against a table of mpmath values written by tools/boys_reference.py.
tools/boys_reference.py docstring (read): emits lib/hfref/boys.viv, F_n(x) from mpmath at 40 digits, rounded once to double; lib/hf/boys.viv header (read): 'The mpmath table in lib/hfref/boys (written by tools/boys_reference.py)'
- not-checkable Two methods compute water's 6-31G integrals
About 60 percent of the integrals come out as the same double from both methods, bit for bit: 2483 of the 4186.
Result of this run (2483/4186 = 59.3%).
- not-checkable Two methods compute water's 6-31G integrals
The exact count depends on the last bit of
exp, so a different math library would change it.Claim about this program's floating-point behavior.
- plausible Two methods compute water's 6-31G integrals
The screened McMurchie-Davidson code skips any shell quartet whose Schwarz bound is under , so a few integrals no larger than are exactly zero in its set.
Schwarz screening bounds every skipped integral by the threshold. The 3e-20 figure comes from this run.
Not accessed; from general knowledge: Schwarz inequality |(ab|cd)| <= sqrt((ab|ab)(cd|cd)), Haser and Ahlrichs, J. Comput. Chem. 10, 104 (1989)
- not-checkable Two methods compute water's 6-31G integrals
Finding which implementation is wrong.
Heading.
- verified Two methods compute water's 6-31G integrals
For an even count the program takes the upper of the two middle values as the median.
Replaces disputed 595adbee782e: names the upper-median convention.
lib/hf/sweep.viv sw_table_median: sort(col); C[i] = col[floor(nstrat / 2.0)], the upper middle value for an even count
- verified Two methods compute water's 6-31G integrals
With two implementations that is the larger value, so a disagreement is detected but the blame falls on whichever one gave the lower value.
Replaces disputed 595adbee782e.
lib/hf/sweep.viv sw_table_median (upper middle value of the sorted column; for two values, the larger); posts/2026-09-24-two-integral-families.viv, its test of the blame with two implementations
- plausible Two methods compute water's 6-31G integrals
With three, the median is a correct value.
If only one of three implementations is wrong, the middle value is one of the two correct ones. The sentence assumes a single faulty member.
Not accessed; from general knowledge (median of three / triple modular redundancy)
- not-checkable Two methods compute water's 6-31G integrals
The last part of the program adds a third implementation that returns the Head-Gordon-Pople integrals with integral 2000, which is , multiplied by .
Describes this program's fault injection.
- verified Two methods compute water's 6-31G integrals
That makes it larger, so with only two implementations the median is the wrong value and the correct one takes the blame.
Scaling a negative number by 1 - 1e-9 makes it larger. Under the library's upper-median rule the altered value then becomes the median of the pair.
Arithmetic: -0.117 x (1 - 1e-9) = -0.117 + 1.17e-10 > -0.117
- not-checkable A random walk spreads as 2Dt and turns Gaussian
Every tolerance is a multiple of a measured spread.
Describes this post's tolerances.
- verified A random walk spreads as 2Dt and turns Gaussian
Diffusion is what a drop of ink does in still water: it spreads, and the width of the spread grows as the square root of time.
Point-source solution of the diffusion equation is a Gaussian with variance 2Dt, so its width grows as sqrt(t).
Wikipedia, 'Fick's laws of diffusion' (second law, point-source Gaussian, MSD = 2nDt), https://en.wikipedia.org/wiki/Fick%27s_laws_of_diffusion
- verified A random walk spreads as 2Dt and turns Gaussian
The equation for the concentration is , and a drop that starts at one point becomes a Gaussian of variance .
Fick's second law in 1D; point-source Gaussian with MSD = 2Dt in one dimension.
Wikipedia, 'Fick's laws of diffusion' (second law, point-source Gaussian, MSD = 2nDt), https://en.wikipedia.org/wiki/Fick%27s_laws_of_diffusion
- plausible A random walk spreads as 2Dt and turns Gaussian
The constant , the diffusion constant, is a property of the ink and the water.
D depends on the solute and solvent, but also on temperature (Stokes-Einstein), which the sentence leaves out; acceptable as informal.
Wikipedia, 'Fick's laws of diffusion' (second law, point-source Gaussian, MSD = 2nDt), https://en.wikipedia.org/wiki/Fick%27s_laws_of_diffusion
- plausible A random walk spreads as 2Dt and turns Gaussian
Steps are independent, so after steps the variances add: .
Variances of independent variables add, so Var(sum of n steps) = n sigma^2; standard probability (not accessed as a separate source; from general knowledge).
Wikipedia, 'Central limit theorem', Lindeberg-Levy statement (finite variance), https://en.wikipedia.org/wiki/Central_limit_theorem
- verified A random walk spreads as 2Dt and turns Gaussian
MSD = 2Dt in 1D (Fick's laws page); with sigma^2 = 0.01 and dt = 0.01, D = sigma^2/(2 dt) = 0.5 by arithmetic.
Wikipedia, 'Fick's laws of diffusion' (second law, point-source Gaussian, MSD = 2nDt), https://en.wikipedia.org/wiki/Fick%27s_laws_of_diffusion
- verified A random walk spreads as 2Dt and turns Gaussian
The mean squared displacement (MSD) grows linearly, and its slope is .
MSD = 2Dt: linear in t with slope 2D in one dimension.
Wikipedia, 'Fick's laws of diffusion' (second law, point-source Gaussian, MSD = 2nDt), https://en.wikipedia.org/wiki/Fick%27s_laws_of_diffusion
- plausible A random walk spreads as 2Dt and turns Gaussian
Nothing about the shape of one step enters, only its variance.
<x^2> = n sigma^2 holds for any zero-mean step distribution with finite variance; follows from additivity of variances.
Wikipedia, 'Central limit theorem', Lindeberg-Levy statement (finite variance), https://en.wikipedia.org/wiki/Central_limit_theorem
- not-checkable A random walk spreads as 2Dt and turns Gaussian
The reference's 2000 runs spread by 0.0451 there, so the formula holds.
Compares the post's standard error with the reference's run-to-run spread (0.04465 vs 0.0451, linked).
- not-checkable A random walk spreads as 2Dt and turns Gaussian
After one step the walkers are spread evenly over : a flat distribution, not a bell.
Describes this program's step distribution (uniform on [-a, a]).
- verified A random walk spreads as 2Dt and turns Gaussian
The central limit theorem says the sum of many independent steps is Gaussian whatever one step looks like, and the diffusion equation's solution is that Gaussian.
CLT (finite variance required, holds for the uniform step) gives a Gaussian limit for the scaled sum, matching the diffusion equation's Gaussian solution; wording is informal but correct here.
Wikipedia, 'Central limit theorem', Lindeberg-Levy statement (finite variance), https://en.wikipedia.org/wiki/Central_limit_theorem; Wikipedia, 'Fick's laws of diffusion' (second law, point-source Gaussian, MSD = 2nDt), https://en.wikipedia.org/wiki/Fick%27s_laws_of_diffusion
- verified A random walk spreads as 2Dt and turns Gaussian
A number that measures it is the excess kurtosis, .
Excess kurtosis = kurtosis - 3; for zero-mean x this is <x^4>/<x^2>^2 - 3.
Wikipedia, 'Kurtosis' (excess kurtosis; uniform -6/5, normal 0; excess kurtosis of a sum of n iid variables is 1/n times one's), https://en.wikipedia.org/wiki/Kurtosis
- verified A random walk spreads as 2Dt and turns Gaussian
For a sum of independent steps it is exactly : the fourth cumulant grows as , the squared variance as .
Excess kurtosis of a sum of n iid variables is (1/n) times one variable's; uniform gives -6/5, so -1.2/n (cumulant additivity).
Wikipedia, 'Kurtosis' (excess kurtosis; uniform -6/5, normal 0; excess kurtosis of a sum of n iid variables is 1/n times one's), https://en.wikipedia.org/wiki/Kurtosis
- plausible A random walk spreads as 2Dt and turns Gaussian
Each bar is , the Poisson spread of a count.
Poisson sqrt(count) is the usual error bar; with a fixed number of walkers the count is binomial, variance Np(1-p), close to Poisson for small bin probabilities. Not accessed; from general knowledge.
Wikipedia, 'Pearson's chi-squared test' (statistic, mean = df, variance = 2 df), https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test
- verified A random walk spreads as 2Dt and turns Gaussian
The agreement at step 200 is measured by Pearson's chi-square, over the bins, with the count the Gaussian predicts.
Pearson's statistic is sum (O - E)^2 / E.
Wikipedia, 'Pearson's chi-squared test' (statistic, mean = df, variance = 2 df), https://en.wikipedia.org/wiki/Pearson%27s_chi-squared_test
- not-checkable BFGS against gradient descent on the Rosenbrock valley
Both methods start at on Rosenbrock's function and use the same backtracking line search; they differ only in the direction they search along.
Describes this program's setup.
- verified BFGS against gradient descent on the Rosenbrock valley
Rosenbrock function with a = 1, b = 100.
Rosenbrock, H.H. (1960), Computer Journal 3(3):175-184, via Wikipedia 'Rosenbrock function', https://en.wikipedia.org/wiki/Rosenbrock_function
- verified BFGS against gradient descent on the Rosenbrock valley
is a standard test for minimizers.
Introduced by Rosenbrock (1960) and used as a performance test problem for optimization algorithms.
Rosenbrock, H.H. (1960), Computer Journal 3(3):175-184, via Wikipedia 'Rosenbrock function', https://en.wikipedia.org/wiki/Rosenbrock_function
- verified BFGS against gradient descent on the Rosenbrock valley
The floor of the valley is nearly flat and the walls are steep, so the downhill direction points mostly at the opposite wall, not along the valley toward the minimum.
Long, narrow, flat-floored parabolic valley; gradient descent zigzags across such valleys.
Rosenbrock, H.H. (1960), Computer Journal 3(3):175-184, via Wikipedia 'Rosenbrock function', https://en.wikipedia.org/wiki/Rosenbrock_function; Wikipedia, 'Gradient descent' (update x - eta grad f; zigzag in narrow valleys such as Rosenbrock; rate set by condition number), https://en.wikipedia.org/wiki/Gradient_descent
- not-checkable BFGS against gradient descent on the Rosenbrock valley
Both methods here step from to for a direction .
Describes both methods in this program.
- verified BFGS against gradient descent on the Rosenbrock valley
Gradient descent takes .
Steepest descent direction is -grad f.
Wikipedia, 'Gradient descent' (update x - eta grad f; zigzag in narrow valleys such as Rosenbrock; rate set by condition number), https://en.wikipedia.org/wiki/Gradient_descent
- verified BFGS against gradient descent on the Rosenbrock valley
BFGS takes , where is its running estimate of the inverse of the Hessian, the matrix of second derivatives.
BFGS direction p = -H grad f with H approximating the inverse Hessian.
Nocedal & Wright, Numerical Optimization (2006), ch. 6, via Wikipedia 'BFGS algorithm' (p = -H grad f, H approximates inverse Hessian, secant equation), https://en.wikipedia.org/wiki/Broyden%E2%80%93Fletcher%E2%80%93Goldfarb%E2%80%93Shanno_algorithm
- not-checkable BFGS against gradient descent on the Rosenbrock valley
The reference is a Python twin of the same algorithm (
posts/refs/bfgs-against-gradient-descent-on-rosenbrock.py, output beside it).Describes the post's reference script.
- verified BFGS against gradient descent on the Rosenbrock valley
Gradient descent goes downhill, and on this function downhill is across the valley.
Gradient points across the narrow valley; gradient descent zigzags across it.
Wikipedia, 'Gradient descent' (update x - eta grad f; zigzag in narrow valleys such as Rosenbrock; rate set by condition number), https://en.wikipedia.org/wiki/Gradient_descent; Rosenbrock, H.H. (1960), Computer Journal 3(3):175-184, via Wikipedia 'Rosenbrock function', https://en.wikipedia.org/wiki/Rosenbrock_function
- not-checkable BFGS against gradient descent on the Rosenbrock valley
There is one exception here.
Transition.
- verified BFGS against gradient descent on the Rosenbrock valley
Near the minimum is close to a quadratic, with Hessian .
Hessian of (1-x)^2+100(y-x^2)^2 at (1,1): f_xx = 2-400(y-x^2)+1200x^2 = 802, f_xy = -400x = -400, f_yy = 200 (direct differentiation, checked numerically).
Rosenbrock, H.H. (1960), Computer Journal 3(3):175-184, via Wikipedia 'Rosenbrock function', https://en.wikipedia.org/wiki/Rosenbrock_function
- not-checkable BFGS against gradient descent on the Rosenbrock valley
Its eigenvalues are 1001.6 and 0.399: the valley is 2508 times steeper across than along (
kappa).Program result; tested (eigenvalues 0.39936 and 1001.60, kappa = 2508.0).
- verified BFGS against gradient descent on the Rosenbrock valley
For a quadratic with Hessian , .
For a quadratic, the gradient change is B s, the basis of the secant equation B_{k+1} s_k = y_k.
Nocedal & Wright, Numerical Optimization (2006), ch. 6, via Wikipedia 'BFGS algorithm' (p = -H grad f, H approximates inverse Hessian, secant equation), https://en.wikipedia.org/wiki/Broyden%E2%80%93Fletcher%E2%80%93Goldfarb%E2%80%93Shanno_algorithm
- not-checkable BFGS against gradient descent on the Rosenbrock valley
Here it is 0.305 at iteration 31, between 0.013 and 0.033 for the next three, and at iteration 35.
Error ratios from this run, linked to tests; the 0.013 and 0.033 bounds are program output.
- not-checkable BFGS against gradient descent on the Rosenbrock valley
The last five errors match the Python twin's to the last bit.
Describes agreement between this program and its Python twin.
- not-checkable BFGS against gradient descent on the Rosenbrock valley
The first figure draws both paths over three level curves of (at 1, 5, and 24.2, the level through the start) and the valley floor .
Describes the figure; f(-1.2, 1) = 4.84 + 19.36 = 24.2 by arithmetic.
- not-checkable BFGS against gradient descent on the Rosenbrock valley
Gradient descent's line shows its first 20 iterates, then every 200th: the long straight segment is the jump across the bend, and each later point stands for 200 small zigzags near .
Describes the figure.
- not-checkable BFGS against gradient descent on the Rosenbrock valley
BFGS lands on the floor and follows the curve of the valley around to the minimum.
Describes the figure.
- not-checkable BFGS against gradient descent on the Rosenbrock valley
The second figure is the distance to against the iteration number, both on log axes.
Describes the figure.
- plausible BFGS against gradient descent on the Rosenbrock valley
Gradient descent's line bends down only slowly, a constant factor per step.
Gradient descent converges linearly (a constant factor per step, set by the condition number) near the minimum; the sentence also describes the figure.
Wikipedia, 'Gradient descent' (update x - eta grad f; zigzag in narrow valleys such as Rosenbrock; rate set by condition number), https://en.wikipedia.org/wiki/Gradient_descent
- not-checkable BFGS against gradient descent on the Rosenbrock valley
BFGS's plunges in its last few steps.
Describes the figure.
- verified Black-Scholes by Monte Carlo, against the closed form
A call option is the right, not the obligation, to buy a stock at a fixed price , the strike, on a fixed date years away.
Right but not obligation to buy at the strike; fixed-date exercise is the European style.
Wikipedia, 'Call option' (right not obligation to buy at strike; payoff max(S_T - X, 0)), https://en.wikipedia.org/wiki/Call_option
- verified Black-Scholes by Monte Carlo, against the closed form
If the stock then trades at the holder buys at and gains ; otherwise the option expires unused.
Payoff at expiry is S_T - K if S_T > K, otherwise zero (ignoring the premium).
Wikipedia, 'Call option' (right not obligation to buy at strike; payoff max(S_T - X, 0)), https://en.wikipedia.org/wiki/Call_option
- verified Black-Scholes by Monte Carlo, against the closed form
Its payoff is .
Call payoff max(S_T - X, 0).
Wikipedia, 'Call option' (right not obligation to buy at strike; payoff max(S_T - X, 0)), https://en.wikipedia.org/wiki/Call_option
- verified Black-Scholes by Monte Carlo, against the closed form
Black, Scholes and Merton (1973) showed that if the stock price follows geometric Brownian motion (random percentage changes, with volatility per square-root year), a portfolio of the stock and cash can reproduce the option's payoff exactly, so the option must cost what that portfolio costs.
Black & Scholes (JPE 1973) and Merton (Bell J. Econ. 1973): under GBM a dynamically hedged stock/cash portfolio replicates the option, fixing its price.
Wikipedia, 'Black-Scholes model' (call formula with d1, d2; GBM assumption; replication/hedging argument; risk-neutral valuation), https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model
- not-checkable Black-Scholes by Monte Carlo, against the closed form
The answer is the formula above, with the standard normal cumulative distribution and
Formula fragment introducing N and d1.
- verified Black-Scholes by Monte Carlo, against the closed form
Standard d1 and d2 = d1 - sigma sqrt(T).
Wikipedia, 'Black-Scholes model' (call formula with d1, d2; GBM assumption; replication/hedging argument; risk-neutral valuation), https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model
- verified Black-Scholes by Monte Carlo, against the closed form
The same argument gives a second way to compute it: the price is the average payoff, discounted at the interest rate , over stock prices that grow on average at rather than at the stock's actual expected return:
Risk-neutral valuation: price = discounted expected payoff with the stock drifting at r.
Wikipedia, 'Black-Scholes model' (call formula with d1, d2; GBM assumption; replication/hedging argument; risk-neutral valuation), https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model; Wikipedia, 'Monte Carlo methods in finance' (error ~ 1/sqrt(N), quadrupling paths halves error, rate independent of dimension, preferred with many state variables), https://en.wikipedia.org/wiki/Monte_Carlo_methods_in_finance
- verified Black-Scholes by Monte Carlo, against the closed form
GBM under the risk-neutral measure: S_T = S_0 exp((r - sigma^2/2)T + sigma sqrt(T) Z).
Wikipedia, 'Black-Scholes model' (call formula with d1, d2; GBM assumption; replication/hedging argument; risk-neutral valuation), https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model
- verified Black-Scholes by Monte Carlo, against the closed form
The average is an unbiased estimate of the price, and by the central limit theorem its error is close to normal with standard deviation , the standard error, where is the standard deviation of one payoff.
Sample mean is unbiased and by the CLT its error is approximately normal with sd sigma_Y/sqrt(N).
Wikipedia, 'Monte Carlo methods in finance' (error ~ 1/sqrt(N), quadrupling paths halves error, rate independent of dimension, preferred with many state variables), https://en.wikipedia.org/wiki/Monte_Carlo_methods_in_finance; Wikipedia, 'Central limit theorem', Lindeberg-Levy statement (finite variance), https://en.wikipedia.org/wiki/Central_limit_theorem
- verified Black-Scholes by Monte Carlo, against the closed form
Quadrupling halves the error, whatever the dimension of the problem; that rate is the reason Monte Carlo is used for options on many assets, where grids cannot be.
Error ~ 1/sqrt(N), quadrupling paths halves the error, rate independent of dimension, preferred with many state variables.
Wikipedia, 'Monte Carlo methods in finance' (error ~ 1/sqrt(N), quadrupling paths halves error, rate independent of dimension, preferred with many state variables), https://en.wikipedia.org/wiki/Monte_Carlo_methods_in_finance
- plausible Black-Scholes by Monte Carlo, against the closed form
has a closed form too.
The lognormal moments give sigma_Y in closed form (see next sentence); derived, not looked up in a separate source.
Wikipedia, 'Black-Scholes model' (call formula with d1, d2; GBM assumption; replication/hedging argument; risk-neutral valuation), https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model
- plausible Black-Scholes by Monte Carlo, against the closed form
The payoff's second moment needs , and , and .
Checked by derivation: E[S_T^2 1{S_T>K}] = S_0^2 e^{(2r+sigma^2)T} N(d2 + 2 sigma sqrt T) = ... N(d1 + sigma sqrt T); E[S_T 1] = S_0 e^{rT} N(d1); P = N(d2). Not accessed in a text; from general knowledge plus derivation.
Wikipedia, 'Black-Scholes model' (call formula with d1, d2; GBM assumption; replication/hedging argument; risk-neutral valuation), https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model
- plausible Black-Scholes by Monte Carlo, against the closed form
Here : one payoff varies by more than the price itself, since 44% of the time it is zero.
sigma_Y is linked; the 44% is P(S_T < K) = N(-d2) = N(-0.15) = 0.440 for the post's d2 = 0.15 (computed, not a looked-up value).
Wikipedia, 'Black-Scholes model' (call formula with d1, d2; GBM assumption; replication/hedging argument; risk-neutral valuation), https://en.wikipedia.org/wiki/Black%E2%80%93Scholes_model
- not-checkable Black-Scholes by Monte Carlo, against the closed form
At each it compares the estimate with the formula.
Describes this program.
- not-checkable Black-Scholes by Monte Carlo, against the closed form
The reference repeated this with 2000 runs of numpy's generator and found slopes of , so the test allows .
Reports the reference's run statistics and the test tolerance (3 x 0.019 = 0.057).
- not-checkable Burgers' equation in nonconservative form puts the shock in the wrong place
Upwinding the second form moves it at 0.5132, on 400, 800 and 1600 cells alike, so refining the grid does not fix it.
Program results linked to tests.
- verified Burgers' equation in nonconservative form puts the shock in the wrong place
Burgers' equation is the simplest model of a nonlinear wave: each value of travels at speed , so faster parts catch up with slower ones and the profile steepens until it breaks into a jump, a shock.
Inviscid Burgers: each value travels at speed u, characteristics cross and a shock forms; Cameron calls it a simplified model.
Wikipedia, 'Burgers' equation' (inviscid form; wave with speed u; characteristics cross and form shocks), https://en.wikipedia.org/wiki/Burgers%27_equation; M. Cameron, 'Notes on Burgers's equation' (UMD), eqs. (6)-(8) Rankine-Hugoniot, sec. 6.1 Example 1 (nonconservative upwind gives s = 0), sec. 6.2 telescoping, sec. 6.6 Godunov, https://www.math.umd.edu/~mariakc/burgers.pdf
- verified Burgers' equation in nonconservative form puts the shock in the wrong place
Past that point the derivative does not exist and the differential equation says nothing.
At the discontinuity only weak (integral-form) solutions make sense.
M. Cameron, 'Notes on Burgers's equation' (UMD), eqs. (6)-(8) Rankine-Hugoniot, sec. 6.1 Example 1 (nonconservative upwind gives s = 0), sec. 6.2 telescoping, sec. 6.6 Godunov, https://www.math.umd.edu/~mariakc/burgers.pdf
- verified Burgers' equation in nonconservative form puts the shock in the wrong place
What still holds is the integral form: the amount of between two points changes by what flows in at one end minus what flows out at the other, with flux .
Integral form: the amount of u in [L, R] changes only by boundary fluxes; for Burgers f(u) = u^2/2.
M. Cameron, 'Notes on Burgers's equation' (UMD), eqs. (6)-(8) Rankine-Hugoniot, sec. 6.1 Example 1 (nonconservative upwind gives s = 0), sec. 6.2 telescoping, sec. 6.6 Godunov, https://www.math.umd.edu/~mariakc/burgers.pdf
- verified Burgers' equation in nonconservative form puts the shock in the wrong place
Applied to a box around a jump from to moving at speed , it gives the Rankine-Hugoniot condition , which for Burgers is .
Rankine-Hugoniot s = (f(u_L) - f(u_R))/(u_L - u_R) = (u_L + u_R)/2 for Burgers.
M. Cameron, 'Notes on Burgers's equation' (UMD), eqs. (6)-(8) Rankine-Hugoniot, sec. 6.1 Example 1 (nonconservative upwind gives s = 0), sec. 6.2 telescoping, sec. 6.6 Godunov, https://www.math.umd.edu/~mariakc/burgers.pdf; R.J. LeVeque, IPDE 2011 slides 'Burgers' equation' [FVMHP Sec. 12.3]: Godunov flux for convex f = min over [Q_{i-1},Q_i] of f if Q_{i-1}<=Q_i, else max; RH speed (u_l+u_r)/2, https://faculty.washington.edu/rjl/ipde/slides/leveque6nup3.pdf
- not-checkable Burgers' equation in nonconservative form puts the shock in the wrong place
The Python reference,
posts/refs/burgers-in-nonconservative-form-puts-the-shock-in-the-wrong-place.py, runs both schemes separately (output beside it).Describes the post's reference script.
- verified Burgers' equation in nonconservative form puts the shock in the wrong place
A conservative scheme updates each cell by the difference of the fluxes through its two faces: .
Conservative form U_j^{n+1} = U_j^n - (k/h)[F_{j+1/2} - F_{j-1/2}]; Godunov's method is of this form.
M. Cameron, 'Notes on Burgers's equation' (UMD), eqs. (6)-(8) Rankine-Hugoniot, sec. 6.1 Example 1 (nonconservative upwind gives s = 0), sec. 6.2 telescoping, sec. 6.6 Godunov, https://www.math.umd.edu/~mariakc/burgers.pdf
- verified Burgers' equation in nonconservative form puts the shock in the wrong place
Whatever leaves one cell enters its neighbor, so the total changes only by the fluxes through the two ends of the domain.
Summing a conservative method telescopes, leaving only boundary fluxes.
M. Cameron, 'Notes on Burgers's equation' (UMD), eqs. (6)-(8) Rankine-Hugoniot, sec. 6.1 Example 1 (nonconservative upwind gives s = 0), sec. 6.2 telescoping, sec. 6.6 Godunov, https://www.math.umd.edu/~mariakc/burgers.pdf
- verified Burgers' equation in nonconservative form puts the shock in the wrong place
Godunov's flux is the flux of the exact solution of the jump between the two neighbors; for Burgers it is .
LeVeque's convex-flux Godunov flux (min of f over [u_L,u_R] if u_L <= u_R, else max) reduces for f = u^2/2 to max(f(max(u_L,0)), f(min(u_R,0))).
R.J. LeVeque, IPDE 2011 slides 'Burgers' equation' [FVMHP Sec. 12.3]: Godunov flux for convex f = min over [Q_{i-1},Q_i] of f if Q_{i-1}<=Q_i, else max; RH speed (u_l+u_r)/2, https://faculty.washington.edu/rjl/ipde/slides/leveque6nup3.pdf; M. Cameron, 'Notes on Burgers's equation' (UMD), eqs. (6)-(8) Rankine-Hugoniot, sec. 6.1 Example 1 (nonconservative upwind gives s = 0), sec. 6.2 telescoping, sec. 6.6 Godunov, https://www.math.umd.edu/~mariakc/burgers.pdf
- verified Burgers' equation in nonconservative form puts the shock in the wrong place
Every here is positive, so information comes from the left and upwinding takes the left difference: .
Cameron's Example 1 uses exactly this left-upwind update U_j - (k/h) U_j (U_j - U_{j-1}) for positive u.
M. Cameron, 'Notes on Burgers's equation' (UMD), eqs. (6)-(8) Rankine-Hugoniot, sec. 6.1 Example 1 (nonconservative upwind gives s = 0), sec. 6.2 telescoping, sec. 6.6 Godunov, https://www.math.umd.edu/~mariakc/burgers.pdf
- plausible Burgers' equation in nonconservative form puts the shock in the wrong place
On smooth data this is a consistent first-order scheme.
Cameron notes such schemes are consistent and stable yet propagate shocks at wrong speeds; first-order accuracy on smooth data is standard upwind theory (not separately accessed).
M. Cameron, 'Notes on Burgers's equation' (UMD), eqs. (6)-(8) Rankine-Hugoniot, sec. 6.1 Example 1 (nonconservative upwind gives s = 0), sec. 6.2 telescoping, sec. 6.6 Godunov, https://www.math.umd.edu/~mariakc/burgers.pdf
- plausible Burgers' equation in nonconservative form puts the shock in the wrong place
At a shock the product is a value that jumps times a derivative that is infinite, and the scheme's answer depends on how it approximates that product.
Informal explanation of why the nonconservative product is ill-defined at a shock; consistent with Cameron sec. 6.1 and Hou & LeFloch (1994), the latter not accessed.
M. Cameron, 'Notes on Burgers's equation' (UMD), eqs. (6)-(8) Rankine-Hugoniot, sec. 6.1 Example 1 (nonconservative upwind gives s = 0), sec. 6.2 telescoping, sec. 6.6 Godunov, https://www.math.umd.edu/~mariakc/burgers.pdf
- not-checkable Burgers' equation in nonconservative form puts the shock in the wrong place
The last cell repeats the nonconservative run on 400 and 1600 cells, and runs as well.
Describes this program's runs.
- not-checkable Burgers' equation in nonconservative form puts the shock in the wrong place
The speeds on 400, 800 and 1600 cells agree to (
S_SPREAD): the scheme converges, to a solution with the wrong shock speed.Program results; tested (S_SPREAD under 3e-6).
- plausible Burgers' equation in nonconservative form puts the shock in the wrong place
A first-order error would halve with each refinement; this one does not change.
A first-order error halves when h halves; the wrong-speed limit does not shrink, consistent with Cameron sec. 6.1. Not accessed as a separate source.
M. Cameron, 'Notes on Burgers's equation' (UMD), eqs. (6)-(8) Rankine-Hugoniot, sec. 6.1 Example 1 (nonconservative upwind gives s = 0), sec. 6.2 telescoping, sec. 6.6 Godunov, https://www.math.umd.edu/~mariakc/burgers.pdf
- not-checkable Excitation energies of water from the Casida equation, with and without de-excitations
Water in the 6-31G basis, from its Hartree-Fock ground state to all 40 singlet and 40 triplet excitation energies, two ways.
Describes this program's calculation; 13 basis functions, 5 occupied, 8 virtual give 40 pairs.
- verified Excitation energies of water from the Casida equation, with and without de-excitations
Time-dependent Hartree-Fock (the random-phase approximation) keeps the coupling between excitations and de-excitations; the Tamm-Dancoff approximation drops it and diagonalizes alone.
TDHF (= RPA) keeps B; TDA sets Y = 0 and diagonalizes A (Herbert sec. 2.1, 2.1.3).
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- not-checkable Excitation energies of water from the Casida equation, with and without de-excitations
The lowest singlet is at 0.344074 Ha (9.363 eV) in TDHF and 0.346161 Ha in TDA, and every one of the 160 energies matches PySCF's to Ha.
Program results linked to tests and the PySCF reference.
- plausible Excitation energies of water from the Casida equation, with and without de-excitations
A molecule absorbs light at the energies of its excited states above the ground state, its excitation energies.
Absorption energies are excitation energies (Bohr frequencies, Herbert sec. 2), though only dipole-allowed transitions absorb appreciably (triplets do not).
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- plausible Excitation energies of water from the Casida equation, with and without de-excitations
Hartree-Fock gives only the ground state, a single set of occupied orbitals.
HF is a single-determinant ground-state method; excited states need response or CI. Not accessed beyond Herbert's framing; from general knowledge.
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- verified Excitation energies of water from the Casida equation, with and without de-excitations
Linear response asks how that state responds to a weak oscillating field: the response diverges at frequencies that solve the eigenvalue problem above, the Casida equation.
Linear-response TDHF/TDDFT: poles of the response give excitation energies solving the Casida (A,B) equation.
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- verified Excitation energies of water from the Casida equation, with and without de-excitations
The unknowns are the amplitudes for moving an electron from an occupied orbital to a virtual one , and for the reverse.
x_ia are occupied-to-virtual excitation amplitudes and y_ia de-excitation amplitudes.
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- not-checkable Excitation energies of water from the Casida equation, with and without de-excitations
For a closed-shell molecule with real orbitals, orbital energies , and two-electron integrals in the molecular-orbital basis (chemists' notation),
Fragment introducing the formula that follows.
- verified Excitation energies of water from the Casida equation, with and without de-excitations
Matches PySCF's singlet get_ab: A = diag(e_a - e_i) + 2(ia|jb) - (ij|ab), B = 2(ia|jb) - (ib|ja) for real orbitals.
PySCF pyscf/tdscf/rhf.py get_ab (singlet A = diag(e_a - e_i) + 2(ai|bj) - (ij|ba); B = 2(ia|jb) - (ja|ib)), https://github.com/pyscf/pyscf/blob/master/pyscf/tdscf/rhf.py; J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- plausible Excitation energies of water from the Casida equation, with and without de-excitations
For triplets the Coulomb terms drop out, since a spin flip moves no net charge.
Herbert eqs. (30)-(31): the Coulomb term appears in the singlet but not the triplet matrices. 'Spin flip' is loose: the Ms = 0 triplet is an antisymmetric alpha/beta combination whose transition density carries no net charge.
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- verified Excitation energies of water from the Casida equation, with and without de-excitations
With the equation is time-dependent Hartree-Fock (TDHF), also called the random-phase approximation (RPA).
'TDHF is also known as the random phase approximation (RPA)' (Herbert sec. 2.1).
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- plausible Excitation energies of water from the Casida equation, with and without de-excitations
The orbitals are the eigenvectors of the converged Fock matrix, and the integrals over them come from four quarter-transformations of the atomic-orbital integrals.
Canonical HF orbitals diagonalize the Fock matrix; the AO-to-MO integral transformation done one index at a time is standard. Not accessed; from general knowledge.
PySCF pyscf/tdscf/rhf.py get_ab (singlet A = diag(e_a - e_i) + 2(ai|bj) - (ij|ba); B = 2(ia|jb) - (ja|ib)), https://github.com/pyscf/pyscf/blob/master/pyscf/tdscf/rhf.py
- not-checkable Excitation energies of water from the Casida equation, with and without de-excitations
The pair is stored at index .
Describes this program's storage layout.
- verified Excitation energies of water from the Casida equation, with and without de-excitations
TDA is one symmetric eigenvalue problem, .
TDA gives a conventional Hermitian eigenvalue problem A x = w x (Herbert sec. 2.1.3).
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- verified Excitation energies of water from the Casida equation, with and without de-excitations
For TDHF the problem is not symmetric, but it folds into a symmetric one of size .
The non-Hermitian 2n problem is equivalent to a Hermitian problem of dimension n (Herbert eqs. 25-27).
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- verified Excitation energies of water from the Casida equation, with and without de-excitations
Adding and subtracting its two block rows gives and , so .
Herbert eq. (24): (A +- B)(x +- y) = w(x -+ y); multiplying gives (A - B)(A + B)(X + Y) = w^2 (X + Y).
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- verified Excitation energies of water from the Casida equation, with and without de-excitations
When is positive definite, which holds when the Hartree-Fock state is stable against these rotations, it has a square root, and turns the product into the symmetric matrix under the title.
Replaces disputed 45362085f5b8. Eigenvector fixed from (X - Y) to (X + Y); the code computes only the eigenvalues, so no code change.
Herbert, 'Density functional theory for electronic excited states', arXiv:2204.10135, eqs. 25-27 (read from the PDF): z_+ = sqrt(omega) (A - B)^{-1/2}(x + y) satisfies (A - B)^{1/2}(A + B)(A - B)^{1/2} z_+ = omega^2 z_+; Direct derivation from the post's (A + B)(X + Y) = omega(X - Y) and (A - B)(X - Y) = omega(X + Y)
- verified Excitation energies of water from the Casida equation, with and without de-excitations
Its eigenvalues are .
Omega z = w^2 z (Herbert eq. 26).
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- not-checkable Excitation energies of water from the Casida equation, with and without de-excitations
All 160 energies agree with PySCF's to Ha, about what is left of the self-consistent field's convergence; the tests allow .
Program results against the PySCF reference; tested (160 energies, worst gap under 3.7e-9 Ha).
- plausible Excitation energies of water from the Casida equation, with and without de-excitations
couples each excitation to the de-excitations, and its effect is to pull the energies down.
Lowering holds for the lowest root (next sentence) and here for all roots, but is not a general theorem for every root. Not accessed; from general knowledge.
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- plausible Excitation energies of water from the Casida equation, with and without de-excitations
For the lowest root this always holds.
Thouless-type variational principle for the lowest RPA root, valid when the stability matrix is positive definite; setting Y = 0 recovers the TDA Rayleigh quotient. Not accessed; from general knowledge.
J.M. Herbert, 'Density Functional Theory for Electronic Excited States', arXiv:2204.10135, sec. 2.1: TDHF also called RPA; eq. (24) (A+-B)(x+-y) = w(x-+y); eqs. (25)-(27) z+ = sqrt(w)(A-B)^{-1/2}(x+y), Omega+ = (A-B)^{1/2}(A+B)(A-B)^{1/2}, Omega z = w^2 z; eqs. (30)-(31) singlet/triplet stability matrices; sec. 2.1.3 TDA with HF is CIS, https://arxiv.org/abs/2204.10135
- not-checkable Excitation energies of water from the Casida equation, with and without de-excitations
For water every root comes out lower in TDHF than in TDA, by 0.07 to 63 millihartree for the singlets and 0.01 to 19 for the triplets (
posts/refsprints the same ranges from PySCF); the largest is the 25th singlet's, 63 millihartree.Program results against the reference; the ranges and the 25th-singlet value are program output.
- verified Excitation energies of water from the Casida equation, with and without de-excitations
The 8 roots near 20 Ha, which move an electron out of the oxygen 1s orbital, shift by less than 0.25 millihartree.
The last 8 singlet and 8 triplet roots lie at 20.18-21.59 Ha (1 core orbital x 8 virtuals); TDA-TDHF shifts there are 0.07-0.24 mHa (singlet) and 0.01-0.10 mHa (triplet), all below 0.25.
posts/refs/casida-tdhf-and-tda-for-water.out (PySCF 2.5.0 TDHF/TDA roots, read)
- verified Excitation energies of water from the Casida equation, with and without de-excitations
The triplets sit below the singlets.
In the reference output every triplet root is below the singlet root of the same index, in both TDHF and TDA.
posts/refs/casida-tdhf-and-tda-for-water.out (PySCF 2.5.0 TDHF/TDA roots, read)
- verified Excitation energies of water from the Casida equation, with and without de-excitations
The singlet and carry the extra term , whose diagonal is the Coulomb self-repulsion of the charge distribution and is positive.
The 2(ia|jb) term is present only in the singlet; (ia|ia) is the Coulomb self-energy of the real density phi_i phi_a and is positive because the Coulomb kernel is positive definite.
PySCF 2.5.0 tdscf/rhf.py get_ab, add_hf_: singlet a += 2*(ia|jb) - (ij|ab), b += 2*(ia|jb) - (ib|ja) (read locally); Dreuw & Head-Gordon, Chem. Rev. 105, 4009 (2005), Sec. 2 (not accessed; from general knowledge)
- not-checkable Excitation energies of water from the Casida equation, with and without de-excitations
The first figure shows the 32 valence excitation energies of each kind.
Describes the post's figure; 4 valence occupied x 8 virtual = 32 is consistent with the reference's nocc=5, nvir=8.
- not-checkable Excitation energies of water from the Casida equation, with and without de-excitations
The second shows, root by root, how far TDA lies above TDHF.
Describes the post's figure.
- verified The double scroll of Chua's circuit
Two capacitors, an inductor, a resistor and one diode whose current is a three-piece straight line.
Two capacitors, one inductor, a resistor and Chua's diode with a piecewise-linear (three-segment) characteristic.
Wikipedia, Chua's circuit, https://en.wikipedia.org/wiki/Chua%27s_circuit (pointer to Chua, Komuro, Matsumoto, 'The double scroll family', IEEE Trans. Circuits Syst. 33 (1986))
- verified The double scroll of Chua's circuit
The voltages never settle and never repeat: they wind around two centers, hopping between them at irregular times.
The double-scroll attractor winds around two outer equilibria with irregular switching; it is aperiodic.
Wikipedia, Chua's circuit, https://en.wikipedia.org/wiki/Chua%27s_circuit (pointer to Chua, Komuro, Matsumoto, 'The double scroll family', IEEE Trans. Circuits Syst. 33 (1986)); L. O. Chua, 'The genesis of Chua's circuit', AEU 46(4):250-257 (1992), abstract via https://www.semanticscholar.org/paper/The-Genesis-of-Chua's-circuit-Chua/9e8622dcda32f95f1ecaa206a1f375ccd5b5d7da
- verified The double scroll of Chua's circuit
The reference, in
posts/refs/chuas-circuit-double-scroll.py, uses a different method and a different integrator: scipy's DOP853 at a tolerance of , carrying the linearized equations along the orbit, over 24000 time units.Describes the reference script, which does use DOP853 at 1e-11 with the variational equations over 24000 time units.
posts/refs/chuas-circuit-double-scroll.py line 42: method='DOP853', rtol=1e-11, atol=1e-11 (read); posts/refs/chuas-circuit-double-scroll.out (read)
- verified The double scroll of Chua's circuit
Chua's circuit is an electronic circuit designed by Leon Chua to be chaotic: its voltages follow a definite rule, with no randomness in it, yet never settle into a repeating pattern.
Chua designed the circuit in 1983 by a systematic procedure specifically to obtain a chaotic, Lorenz-like system in a real circuit.
L. O. Chua, 'The genesis of Chua's circuit', AEU 46(4):250-257 (1992), abstract via https://www.semanticscholar.org/paper/The-Genesis-of-Chua's-circuit-Chua/9e8622dcda32f95f1ecaa206a1f375ccd5b5d7da; Wikipedia, Chua's circuit, https://en.wikipedia.org/wiki/Chua%27s_circuit (pointer to Chua, Komuro, Matsumoto, 'The double scroll family', IEEE Trans. Circuits Syst. 33 (1986))
- verified The double scroll of Chua's circuit
It has two capacitors, an inductor, a resistor, and one nonlinear part, a Chua diode: a small circuit whose current is a function of the voltage across it made of three straight pieces.
Chua's diode is a piecewise-linear nonlinear resistor with three segments in the standard model.
Wikipedia, Chua's circuit, https://en.wikipedia.org/wiki/Chua%27s_circuit (pointer to Chua, Komuro, Matsumoto, 'The double scroll family', IEEE Trans. Circuits Syst. 33 (1986))
- verified The double scroll of Chua's circuit
In scaled units, with and the two capacitor voltages and the inductor current, the equations are the three above.
In the dimensionless equations x and y are the voltages across C1 and C2 and z is the current through the inductor.
Wikipedia, Chua's circuit, https://en.wikipedia.org/wiki/Chua%27s_circuit (pointer to Chua, Komuro, Matsumoto, 'The double scroll family', IEEE Trans. Circuits Syst. 33 (1986))
- plausible The double scroll of Chua's circuit
The negative slopes make the origin unstable: a small voltage grows instead of dying away.
The origin is indeed unstable, but what matters is the inner slope m0 being below -1 (term -alpha(1+m0) > 0), not merely negative; the outer slope m1 plays no role at the origin.
Direct computation: Jacobian at the origin with alpha=9, beta=100/7, m0=-8/7 has eigenvalues 2.217 and -0.966 +/- 2.711i (numpy); Wikipedia, Chua's circuit, https://en.wikipedia.org/wiki/Chua%27s_circuit (pointer to Chua, Komuro, Matsumoto, 'The double scroll family', IEEE Trans. Circuits Syst. 33 (1986))
- plausible The double scroll of Chua's circuit
Far out, the circuit's other parts win and push it back.
Qualitative statement of the bounded, dissipative outer region; consistent with the equations.
Direct computation: outer slope m1=-5/7 > -1 gives -alpha(1+m1) < 0, so the diode no longer overcomes the resistor far out (numpy check of Jacobian); Wikipedia, Chua's circuit, https://en.wikipedia.org/wiki/Chua%27s_circuit (pointer to Chua, Komuro, Matsumoto, 'The double scroll family', IEEE Trans. Circuits Syst. 33 (1986))
- verified The double scroll of Chua's circuit
With nowhere stable to rest, the state keeps moving.
All three equilibria are saddle-foci for these parameters, so there is no stable rest point.
Direct computation (numpy): origin eigenvalues 2.217, -0.966+/-2.711i; outer equilibria -3.942, 0.185+/-3.047i, so all three equilibria are unstable; Wikipedia, Chua's circuit, https://en.wikipedia.org/wiki/Chua%27s_circuit (pointer to Chua, Komuro, Matsumoto, 'The double scroll family', IEEE Trans. Circuits Syst. 33 (1986))
- not-checkable The double scroll of Chua's circuit
The program advances the state with the classical fourth-order Runge-Kutta method at a step of , then runs 20000 steps (100 time units) so the state reaches the set it keeps returning to, the attractor, before anything is measured.
Describes the program's integrator and settling run; 20000 x 0.005 = 100 is correct.
- plausible The double scroll of Chua's circuit
That irregular count is the visible sign of chaos.
Irregular switching between lobes is the usual visual signature of the double scroll; by itself it is not a proof of chaos, which the post then measures.
Wikipedia, Chua's circuit, https://en.wikipedia.org/wiki/Chua%27s_circuit (pointer to Chua, Komuro, Matsumoto, 'The double scroll family', IEEE Trans. Circuits Syst. 33 (1986))
- not-checkable The double scroll of Chua's circuit
Chaos has a measurable rate.
Transition to the Lyapunov-exponent section.
- verified The double scroll of Chua's circuit
On average the distance grows like ; is the largest Lyapunov exponent, and a positive is what chaos means in numbers.
Standard definition; a positive largest Lyapunov exponent is the usual quantitative criterion for chaos on a bounded attractor.
Wikipedia, Lyapunov exponent, https://en.wikipedia.org/wiki/Lyapunov_exponent (pointer to Benettin et al., Meccanica 15 (1980); Wolf et al., Physica D 16 (1985)); S. Strogatz, Nonlinear Dynamics and Chaos, Sec. 9.3 (not accessed; from general knowledge)
- verified The double scroll of Chua's circuit
The two copies cannot be left alone for long, since once their distance is as large as the attractor it stops growing.
The separation saturates at the attractor's size, which is why Benettin's method renormalizes.
Wikipedia, Lyapunov exponent, https://en.wikipedia.org/wiki/Lyapunov_exponent (pointer to Benettin et al., Meccanica 15 (1980); Wolf et al., Physica D 16 (1985)); Strogatz, Nonlinear Dynamics and Chaos, Sec. 9.3 (not accessed; from general knowledge)
- verified The double scroll of Chua's circuit
The exponent is the sum divided by the elapsed time.
Benettin-style estimate: sum of ln(d/d0) over renormalizations divided by elapsed time.
Wikipedia, Lyapunov exponent, https://en.wikipedia.org/wiki/Lyapunov_exponent (pointer to Benettin et al., Meccanica 15 (1980); Wolf et al., Physica D 16 (1985))
- not-checkable The double scroll of Chua's circuit
The estimate wanders early, while one or two passes near the center of a lobe can move it, and settles as the time grows.
Describes the running estimate in this post's plot.
- verified The double scroll of Chua's circuit
Past that time the equations are still exact, but a measurement of the starting voltage to eight digits no longer predicts which lobe the circuit is on.
This is the predictability horizon t ~ ln(a/delta0)/lambda; ln(1e8)/0.3277 = 56.
Wikipedia, Lyapunov exponent, https://en.wikipedia.org/wiki/Lyapunov_exponent (pointer to Benettin et al., Meccanica 15 (1980); Wolf et al., Physica D 16 (1985)); Strogatz, Nonlinear Dynamics and Chaos, Sec. 9.3 predictability horizon (not accessed; from general knowledge)
- verified Crank-Nicolson is second order in time, backward Euler first
Each halving cuts the Crank-Nicolson error by a factor of 4.0 to 4.7 (measured order 2.09 to 2.23, then 2.000) and the backward Euler error by 1.9 to 2.0 (order 0.94 to 0.996).
Reference orders: CN 2.142, 2.093, 2.113, 2.230, 2.000 (factors 4.0-4.7); BE 0.940-0.996 (factors 1.92-1.99).
posts/refs/crank-nicolson-is-second-order-in-time.out (read)
- verified Crank-Nicolson is second order in time, backward Euler first
The errors are measured against the exact solution of the space-discretized equation, a discrete sine series.
The semi-discrete system's exact solution is an expansion in the discrete sine eigenvectors; the reference confirms it against a matrix exponential to 7e-14.
Wikipedia, Eigenvalues and eigenvectors of the second derivative (discrete Dirichlet case), https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors_of_the_second_derivative; posts/refs/crank-nicolson-is-second-order-in-time.out (read)
- verified Crank-Nicolson is second order in time, backward Euler first
The PDE's solution is the Fourier sine series
Correct; the solution is a Fourier sine series.
Standard separation of variables for u_t=u_xx with Dirichlet ends; W. Strauss, PDE: An Introduction, Sec. 4.1 (not accessed; from general knowledge); Direct integration: 2*int_0^1 x(1-x) sin(k pi x) dx = 4(1-(-1)^k)/(k pi)^3
- verified Crank-Nicolson is second order in time, backward Euler first
Coefficients and decay rates are correct.
Direct integration: 2*int_0^1 x(1-x) sin(k pi x) dx = 4(1-(-1)^k)/(k pi)^3 = 8/(pi^3 k^3) for odd k; Strauss, PDE: An Introduction, Sec. 4.1 (not accessed; from general knowledge)
- verified Crank-Nicolson is second order in time, backward Euler first
since has sine coefficients for odd and zero for even , and each mode decays at its own rate .
Coefficients are 8/(pi^3 k^3) for odd k and 0 for even k; mode k decays as exp(-k^2 pi^2 t).
Direct integration: 2*int_0^1 x(1-x) sin(k pi x) dx = 4(1-(-1)^k)/(k pi)^3
- not-checkable Crank-Nicolson is second order in time, backward Euler first
The time steps are then the only error left to measure.
Describes the post's measurement design.
- not-checkable Crank-Nicolson is second order in time, backward Euler first
The Python reference,
posts/refs/crank-nicolson-is-second-order-in-time.py, steps the same equations with scipy's banded solver and computes the exact space-discretized solution with a matrix exponential (output beside it).Describes the reference script.
- verified Crank-Nicolson is second order in time, backward Euler first
Both schemes average the space difference between the old and the new time level, with weight on the new one:
The theta method weights the spatial operator by theta at the new level and 1-theta at the old; CN is theta=1/2, backward Euler theta=1.
Wikipedia, Crank-Nicolson method, https://en.wikipedia.org/wiki/Crank%E2%80%93Nicolson_method (pointer to Crank & Nicolson 1947)
- verified Crank-Nicolson is second order in time, backward Euler first
Standard theta scheme for u_t = delta^2 u.
Wikipedia, Crank-Nicolson method, https://en.wikipedia.org/wiki/Crank%E2%80%93Nicolson_method (pointer to Crank & Nicolson 1947)
- verified Crank-Nicolson is second order in time, backward Euler first
The left side is a tridiagonal system, with on the diagonal and beside it, .
Correct.
Wikipedia, Eigenvalues and eigenvectors of the second derivative (discrete Dirichlet case), https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors_of_the_second_derivative; Derived from the theta scheme: (I - theta dt delta^2) has diagonal 1+2 theta r and off-diagonals -theta r
- verified Crank-Nicolson is second order in time, backward Euler first
The Thomas algorithm solves it in one sweep down and one back up.
The Thomas algorithm is a forward elimination sweep followed by back substitution.
Wikipedia, Tridiagonal matrix algorithm, https://en.wikipedia.org/wiki/Tridiagonal_matrix_algorithm
- verified Crank-Nicolson is second order in time, backward Euler first
The trapezoidal rule evaluates it at both ends, the first-order error terms of the two ends cancel, and what remains is per step and in total.
The trapezoidal rule has local error O(dt^3) and global error O(dt^2).
Wikipedia, Crank-Nicolson method, https://en.wikipedia.org/wiki/Crank%E2%80%93Nicolson_method (pointer to Crank & Nicolson 1947); E. Hairer, S. Norsett, G. Wanner, Solving ODEs I, Sec. II.1 (not accessed; from general knowledge)
- verified Crank-Nicolson is second order in time, backward Euler first
The error of a time-stepping scheme is measured against the exact solution of the equations it steps, , which differs from the PDE's solution by the space error.
The reference prints the space error max|semi-discrete - PDE series| = 1.95e-6, the difference between the two exact solutions.
Wikipedia, Eigenvalues and eigenvectors of the second derivative (discrete Dirichlet case), https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors_of_the_second_derivative; posts/refs/crank-nicolson-is-second-order-in-time.out (read)
- verified Crank-Nicolson is second order in time, backward Euler first
That solution is also a sine series.
The discrete Dirichlet Laplacian has eigenvectors sin(k pi x_j) and eigenvalues -(4/h^2) sin^2(k pi h/2), which tend to -k^2 pi^2.
Wikipedia, Eigenvalues and eigenvectors of the second derivative (discrete Dirichlet case), https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors_of_the_second_derivative
- verified Crank-Nicolson is second order in time, backward Euler first
Closed form checks out; the reference matches it to 2.8e-16 at t=0, and it tends to 8/(pi^3 k^3) as h -> 0.
Derivation: -delta^2 u0 = 2 exactly for u0 = x(1-x); discrete sine coefficient of 2 is 4h sum_j sin(k pi j h) = 4h cot(k pi h/2) for odd k, 0 for even; Wikipedia, Eigenvalues and eigenvectors of the second derivative (discrete Dirichlet case), https://en.wikipedia.org/wiki/Eigenvalues_and_eigenvectors_of_the_second_derivative; posts/refs/crank-nicolson-is-second-order-in-time.out (read)
- verified Crank-Nicolson is second order in time, backward Euler first
Terms past k = 21 are below 10−190 at t = 0.1.
True with a wide margin; even the k=21 term is ~1e-194.
Direct evaluation: the k=23 term is 8/(pi^3 23^3) exp(-529 pi^2 0.1) ~ 1e-231, and later terms are smaller
- not-checkable Crank-Nicolson is second order in time, backward Euler first
The cell runs both schemes at (5 to 160 steps) and takes the largest error over the grid at .
Describes the cell; 0.1/0.02 = 5 and 0.1/0.000625 = 160 steps are consistent.
- verified Crank-Nicolson is second order in time, backward Euler first
The measured order between two runs is of the ratio of their errors.
Standard observed-order formula for step halving; the reference output uses it.
R. LeVeque, Finite Difference Methods for ODEs and PDEs (SIAM 2007), Appendix A.6 on estimating order from error ratios (not accessed; from general knowledge); posts/refs/crank-nicolson-is-second-order-in-time.out (read)
- verified Crank-Nicolson is second order in time, backward Euler first
At that is every mode from up, and it adds 47% (
fast_share) to the error of the slowest mode alone.Reference: at dt=0.02 modes with dt*lambda_k > 2 (where the CN factor is negative) are k >= 5, and total CN error 4.555e-4 vs k=1 mode 3.095e-4 is 47% more.
posts/refs/crank-nicolson-is-second-order-in-time.out (read); Wikipedia, Crank-Nicolson method, https://en.wikipedia.org/wiki/Crank%E2%80%93Nicolson_method (pointer to Crank & Nicolson 1947)
- plausible Crank-Nicolson is second order in time, backward Euler first
After that the total is the space error.
Approximate: at dt=0.000625 the CN-vs-PDE error is 1.65e-6 against a space error of 1.95e-6, so the total is the space error only to about 15%.
posts/refs/crank-nicolson-is-second-order-in-time.out (read)
- verified Crank-Nicolson is second order in time, backward Euler first
Refining further buys nothing unless is refined with it.
Once the time error is below the O(h^2) space error, only refining h lowers the total.
posts/refs/crank-nicolson-is-second-order-in-time.out (read); LeVeque, Finite Difference Methods, Ch. 9 (heat equation global error O(k^2 + h^2) for CN) (not accessed; from general knowledge)
- verified Electron mobility fitted to NIST's certified digits
A seven-parameter rational model fitted to NIST's semiconductor electron-mobility data by lmder, the Levenberg-Marquardt routine of MINPACK, translated to Viv step by step.
Thurber is a 7-parameter rational model on semiconductor electron mobility; lmder is MINPACK's Levenberg-Marquardt driver with analytic Jacobian.
NIST StRD, Thurber.dat, https://www.itl.nist.gov/div898/strd/nls/data/LINKS/DATA/Thurber.dat (read); MINPACK lmder.f documentation (Garbow, Hillstrom, More, Argonne, March 1980), https://www.netlib.org/minpack/lmder.f (read)
- verified Electron mobility fitted to NIST's certified digits
The data are 37 measurements from a NIST study of electron mobility in a semiconductor, as a function of the natural log of the carrier density (the Thurber data set of NIST's Statistical Reference Datasets).
37 observations, response electron mobility, predictor natural log of density, NIST study (Thurber).
NIST StRD, Thurber.dat, https://www.itl.nist.gov/div898/strd/nls/data/LINKS/DATA/Thurber.dat (read)
- verified Electron mobility fitted to NIST's certified digits
NIST rates the fit "higher difficulty" and publishes certified parameter values to 11 digits.
Listed as 'Higher Level of Difficulty'; certified values are given to 11 significant digits (e.g. 1.2881396800E+03).
NIST StRD, Thurber.dat, https://www.itl.nist.gov/div898/strd/nls/data/LINKS/DATA/Thurber.dat (read)
- verified Electron mobility fitted to NIST's certified digits
The model is a ratio of two cubics in x with seven parameters,
Cubic/cubic rational class, 7 parameters.
NIST StRD, Thurber.dat, https://www.itl.nist.gov/div898/strd/nls/data/LINKS/DATA/Thurber.dat (read)
- verified Electron mobility fitted to NIST's certified digits
Matches NIST's model formula.
NIST StRD, Thurber.dat, https://www.itl.nist.gov/div898/strd/nls/data/LINKS/DATA/Thurber.dat (read)
- verified Electron mobility fitted to NIST's certified digits
and the fit minimizes the sum of squares of the 37 residuals .
Least squares on 37 residuals.
NIST StRD, Thurber.dat, https://www.itl.nist.gov/div898/strd/nls/data/LINKS/DATA/Thurber.dat (read)
- verified Electron mobility fitted to NIST's certified digits
The fit is done by
lmderfromlib/minpack: a port of MINPACK's Levenberg-Marquardt code (Moré, Garbow and Hillstrom, Argonne, 1980), the same code scipy.optimize.leastsq calls.lmder is credited to Garbow, Hillstrom and More, Argonne, March 1980; scipy's leastsq calls lmder when a Jacobian (Dfun) is supplied, lmdif otherwise.
MINPACK lmder.f documentation (Garbow, Hillstrom, More, Argonne, March 1980), https://www.netlib.org/minpack/lmder.f (read); SciPy docs, scipy.optimize.leastsq: 'leastsq is a wrapper around MINPACK's lmdif and lmder algorithms' (not accessed this session; from general knowledge)
- verified Electron mobility fitted to NIST's certified digits
Each pass computes the Jacobian , factors it, and tries steps inside a trust region , a radius around the current parameters where the linear model of the residuals is trusted.
lmder uses a QR factorization of the Jacobian and a scaled step bound ||D p|| <= Delta, with diag scaling and factor setting the initial bound.
MINPACK lmder.f documentation (Garbow, Hillstrom, More, Argonne, March 1980), https://www.netlib.org/minpack/lmder.f (read); J. J. More, 'The Levenberg-Marquardt algorithm: implementation and theory', Lecture Notes in Math. 630 (1978) (not accessed; from general knowledge)
- not-checkable Electron mobility fitted to NIST's certified digits
Three references check the result:
Transition.
- not-checkable Electron mobility fitted to NIST's certified digits
the original Fortran, built with gfortran and instrumented to record every trial step (
lib/minpack/oracle); the port does the same operations in the same order, and on this problem, which uses only arithmetic, every recorded number agrees to the last bit;Describes this program's cross-check against the instrumented Fortran.
- not-checkable Electron mobility fitted to NIST's certified digits
scipy.optimize.leastsq, with the same settings;
Describes this program's cross-check.
- verified Electron mobility fitted to NIST's certified digits
info1 means lmder stopped because both the actual and the predicted relative reduction of the sum of squares fell below the tolerance , where is the machine precision.lmder docs: info=1 means 'both actual and predicted relative reductions in the sum of squares are at most ftol'; ftol = sqrt(machine eps) = 1.49e-8 is the setting used (also scipy's default).
MINPACK lmder.f documentation (Garbow, Hillstrom, More, Argonne, March 1980), https://www.netlib.org/minpack/lmder.f (read)
- not-checkable Electron mobility fitted to NIST's certified digits
It took 33 evaluations of the residuals and 27 of the Jacobian; each of the 32 trial steps after the first evaluation is one row of
hist.Run statistics of this program, checked by the linker; 32 = 33 - 1.
- not-checkable Electron mobility fitted to NIST's certified digits
The first two trial steps, starting with the Gauss-Newton step, make the fit worse and are rejected, and each rejection shrinks the trust radius.
Describes this run's iteration history.
- not-checkable Electron mobility fitted to NIST's certified digits
Three more are rejected in the next few passes, 5 of the 32 in all.
Describes this run's iteration history, checked by the linker.
- plausible Forward and backward Euler on either side of h = 2/λ
An equation is stiff when it has a component that decays much faster than the solution you want changes.
A common informal definition based on separated time scales; Hairer and Wanner define it operationally (explicit methods need tiny steps), and the two agree for this problem.
Wikipedia, Stiff equation, https://en.wikipedia.org/wiki/Stiff_equation (pointer to Dahlquist 1963; Hairer & Wanner, Solving ODEs II); LeVeque, Finite Difference Methods, Ch. 8 (not accessed; from general knowledge)
- not-checkable Forward and backward Euler on either side of h = 2/λ
The Python reference,
posts/refs/forward-euler-blows-up-past-h-equals-2-over-lambda.py, runs the same steps separately (output beside it).Describes the reference script.
- not-checkable Forward and backward Euler on either side of h = 2/λ
Let be the computed solution and its error.
Notation.
- verified Forward and backward Euler on either side of h = 2/λ
Forward Euler is , and since depends on through only,
Forward Euler step; f = -lambda(y - cos t) - sin t depends on y only through -lambda y.
Wikipedia, Stiff equation, https://en.wikipedia.org/wiki/Stiff_equation (pointer to Dahlquist 1963; Hairer & Wanner, Solving ODEs II)
- verified Forward and backward Euler on either side of h = 2/λ
The error recursion follows directly; tau_n here is the undivided one-step error.
Derivation from the forward Euler step and f = -lambda(y - cos t) - sin t, with tau_n = (one step from the exact value) - exact
- verified Forward and backward Euler on either side of h = 2/λ
where , the local truncation error, is what one step of the method gets wrong starting from the exact solution.
This is the one-step (local) error; for forward Euler it is h^2/2 y''(xi). Note h^2/2 at h=0.0021 is 2.2e-6, so 'at most 2e-6' holds only to one significant figure.
LeVeque, Finite Difference Methods, Sec. 5.5 local truncation error (not accessed; from general knowledge)
- verified Forward and backward Euler on either side of h = 2/λ
Every error made earlier is multiplied by at every later step.
Correct.
Follows from e_{n+1} = g e_n + tau_n by induction
- plausible Forward and backward Euler on either side of h = 2/λ
Accuracy would allow a far larger step: the solution is .
The solution cos t varies on a time scale of 1, so accuracy alone would allow steps far above 0.002; qualitative.
Wikipedia, Stiff equation, https://en.wikipedia.org/wiki/Stiff_equation (pointer to Dahlquist 1963; Hairer & Wanner, Solving ODEs II)
- verified Forward and backward Euler on either side of h = 2/λ
That is A-stability: the method is stable for every step size on every decaying mode.
A-stability (Dahlquist 1963): the stability region contains the whole left half-plane, i.e. stable for every step on every decaying mode.
Wikipedia, Stiff equation, https://en.wikipedia.org/wiki/Stiff_equation (pointer to Dahlquist 1963; Hairer & Wanner, Solving ODEs II)
- verified Forward and backward Euler on either side of h = 2/λ
The cost is a solve per step (here a division, since the equation is linear in ).
Implicit methods require solving an equation per step; for a linear scalar equation it is a division.
Wikipedia, Stiff equation, https://en.wikipedia.org/wiki/Stiff_equation (pointer to Dahlquist 1963; Hairer & Wanner, Solving ODEs II)
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
On seven points reach rounding.
Reference: e^x error 8.9e-16 at n=7, i.e. at rounding.
posts/refs/gauss-legendre-quadrature-and-where-tanh-sinh-wins.out (read)
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
A quadrature rule replaces an integral by a weighted sum of the integrand's values: .
Definition of an interpolatory quadrature rule.
DLMF 3.5.19-3.5.21 (Gauss-Legendre nodes, exactness, remainder), https://dlmf.nist.gov/3.5
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
With points there are numbers to choose, the nodes and the weights .
n nodes and n weights.
DLMF 3.5.19-3.5.21 (Gauss-Legendre nodes, exactness, remainder), https://dlmf.nist.gov/3.5
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
The Gauss-Legendre rule chooses them so that the sum is exact for every polynomial of degree up to , which is as high as free numbers can reach.
Gauss-Legendre is exact through degree 2n-1 (DLMF 3.5.20); no n-point rule can integrate prod(x-x_i)^2 of degree 2n exactly.
DLMF 3.5.19-3.5.21 (Gauss-Legendre nodes, exactness, remainder), https://dlmf.nist.gov/3.5
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
The nodes turn out to be the roots of the Legendre polynomial .
Nodes are the zeros of P_n (DLMF 3.5.21).
DLMF 3.5.19-3.5.21 (Gauss-Legendre nodes, exactness, remainder), https://dlmf.nist.gov/3.5
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
On the second one a different rule, tanh-sinh, does far better.
Tanh-sinh is designed for endpoint singularities; the reference shows it reaching rounding on 1/sqrt(1-x^2).
Wikipedia, Tanh-sinh quadrature, https://en.wikipedia.org/wiki/Tanh-sinh_quadrature (pointer to Takahasi & Mori, Publ. RIMS Kyoto Univ. 9 (1974) 721-741); posts/refs/gauss-legendre-quadrature-and-where-tanh-sinh-wins.out (read)
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
The reference is
posts/refs/gauss-legendre-quadrature-and-where-tanh-sinh-wins.py(output beside it): numpy'sleggauss, which gets the nodes from the eigenvalues of a tridiagonal matrix rather than by Newton's method as here, closed-form integrals, and the tanh-sinh rule written in numpy.Nodes come from the eigenvalues of the symmetric tridiagonal companion matrix; numpy then applies a single Newton correction, so 'rather than by Newton's method' is right about the main method.
NumPy source, numpy/polynomial/legendre.py leggauss: x = eigvalsh(legcompanion(c)) then 'improve roots by one application of Newton' (read locally)
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
The cell integrates for , whose exact integral is , with the 5-point rule and with the 3-point rule.
Correct formula; the reference tabulates the same test.
int_{-1}^{1} (1+x)^k dx = 2^{k+1}/(k+1) (elementary); posts/refs/gauss-legendre-quadrature-and-where-tanh-sinh-wins.out (read)
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
At degree the miss is known exactly.
For a degree-2n polynomial f^(2n) is constant, so the remainder formula gives the error exactly.
DLMF 3.5.19-3.5.21 (Gauss-Legendre nodes, exactness, remainder), https://dlmf.nist.gov/3.5
- not-checkable Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
The error of the -point rule is
Lead-in to a formula.
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
DLMF 3.5.19 with gamma_n = 2^{2n+1}(n!)^4/((2n+1)((2n)!)^2) and division by (2n)! gives this formula; the reference's n=5, degree-10 miss matches it.
DLMF 3.5.19-3.5.21 (Gauss-Legendre nodes, exactness, remainder), https://dlmf.nist.gov/3.5; posts/refs/gauss-legendre-quadrature-and-where-tanh-sinh-wins.out (read)
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
is not a polynomial, but it is smooth everywhere, including off the real line, and polynomials approximate it well.
e^x is entire; the reference shows super-geometric error decay to rounding at n=7.
L. N. Trefethen, Approximation Theory and Approximation Practice, Ch. 19 (Gauss quadrature converges geometrically for analytic integrands) (not accessed; from general knowledge); posts/refs/gauss-legendre-quadrature-and-where-tanh-sinh-wins.out (read)
- not-checkable Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
is a different case.
Transition.
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
The rule never evaluates at , which is good, since the value there is infinite; but its outermost node sits a distance of order from the end, and the integral over that last stretch, over a length of order , is of order .
The outermost node is O(1/n^2) from the end and the error is O(1/n), with n*error = 1.64-1.74.
Direct computation with numpy leggauss: n^2(1 - x_max) = 2.54, 2.71, 2.80, 2.85, 2.87 for n = 8..128 (limit j_{0,1}^2/2 = 2.89); posts/refs/gauss-legendre-quadrature-and-where-tanh-sinh-wins.out (read)
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
At that rate each further digit costs ten times as many points.
With error ~ c/n, a tenfold smaller error needs tenfold more points.
posts/refs/gauss-legendre-quadrature-and-where-tanh-sinh-wins.out (read)
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
The tanh-sinh rule, from Takahasi and Mori (1974), changes variables first:
Takahasi and Mori, 'Double exponential formulas for numerical integration', Publ. RIMS 9 (1974).
Wikipedia, Tanh-sinh quadrature, https://en.wikipedia.org/wiki/Tanh-sinh_quadrature (pointer to Takahasi & Mori, Publ. RIMS Kyoto Univ. 9 (1974) 721-741)
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
Correct substitution and Jacobian.
Wikipedia, Tanh-sinh quadrature, https://en.wikipedia.org/wiki/Tanh-sinh_quadrature (pointer to Takahasi & Mori, Publ. RIMS Kyoto Univ. 9 (1974) 721-741); Differentiation: d/dt tanh(pi/2 sinh t) = (pi/2) cosh t sech^2(pi/2 sinh t)
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
As runs over the whole line, runs over , and the endpoints move off to .
tanh(pi/2 sinh t) maps R onto (-1, 1).
Wikipedia, Tanh-sinh quadrature, https://en.wikipedia.org/wiki/Tanh-sinh_quadrature (pointer to Takahasi & Mori, Publ. RIMS Kyoto Univ. 9 (1974) 721-741)
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
The factor falls like , a double exponential, which is faster than grows.
dx/dt decays like exp(-(pi/2) e^{|t|}) up to a single-exponential factor, faster than the integrand grows.
Wikipedia, Tanh-sinh quadrature, https://en.wikipedia.org/wiki/Tanh-sinh_quadrature (pointer to Takahasi & Mori, Publ. RIMS Kyoto Univ. 9 (1974) 721-741); Asymptotics: sech^2(u) ~ 4 exp(-2u), u ~ (pi/4) e^{|t|}, while 1/sqrt(1-x^2) = cosh(u) ~ exp((pi/4) e^{|t|})/2
- not-checkable Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
There is one trap.
Transition.
- not-checkable Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
With that happens at 12 of the 37 nodes, and the sum is infinite.
Describes this program's run at h = 1/4; the count is checked by the linked test.
- plausible Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
Halving doubles the points.
Roughly true: with a fixed truncation range the rule has about 2T/h + 1 points, so halving h gives 2N - 1 (19 -> 37 -> 73), not exactly double.
Wikipedia, 'Tanh-sinh quadrature' (pointer): 'not as efficient as Gaussian quadrature for smooth integrands', https://en.wikipedia.org/wiki/Tanh-sinh_quadrature; Post's own counts: 9, 19, 37, 73 points at h = 1, 1/2, 1/4, 1/8
- verified Gauss-Legendre quadrature against tanh-sinh on a smooth and a singular integral
The substitution spends most of its points near the ends, and a smooth integrand has nothing there that needs them.
Tanh-sinh clusters its nodes double-exponentially toward the endpoints and is less efficient than Gauss-Legendre on smooth integrands, as the sources state.
Wikipedia, 'Tanh-sinh quadrature' (pointer): 'not as efficient as Gaussian quadrature for smooth integrands', https://en.wikipedia.org/wiki/Tanh-sinh_quadrature; Bailey, Jeyabalan, Li, 'A comparison of three high-precision quadrature schemes', Experimental Mathematics 14(3), 2005, https://www.osti.gov/servlets/purl/822964
- not-checkable Grad-Shafranov by finite differences, against Solov'ev's closed form
A tokamak equilibrium solved on a grid and graded against an exact one.
Describes this post.
- plausible Grad-Shafranov by finite differences, against Solov'ev's closed form
A tokamak holds its plasma in a magnetic field shaped like nested doughnuts.
Informal but correct: tokamak field lines lie on nested toroidal flux surfaces. Not accessed; from general knowledge.
Not accessed; from general knowledge (nested toroidal flux surfaces, e.g. Freidberg, Ideal MHD); Wikipedia, 'Grad-Shafranov equation' (pointer; derives from grad p = J x B, psi and p(psi), F(psi) constant along field lines), https://en.wikipedia.org/wiki/Grad%E2%80%93Shafranov_equation
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
In equilibrium the magnetic force balances the pressure gradient, .
Ideal MHD static equilibrium is grad p = J x B.
Wikipedia, 'Grad-Shafranov equation' (pointer; derives from grad p = J x B, psi and p(psi), F(psi) constant along field lines), https://en.wikipedia.org/wiki/Grad%E2%80%93Shafranov_equation
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
With the machine's rotational symmetry about its vertical axis, that balance reduces to one equation for one function, the poloidal flux , where is the distance from the axis of symmetry and the height.
Axisymmetry reduces force balance to the Grad-Shafranov equation for the poloidal flux psi(R, Z).
Wikipedia, 'Grad-Shafranov equation' (pointer; derives from grad p = J x B, psi and p(psi), F(psi) constant along field lines), https://en.wikipedia.org/wiki/Grad%E2%80%93Shafranov_equation
- not-checkable Grad-Shafranov by finite differences, against Solov'ev's closed form
The equation is the Grad-Shafranov equation above.
Transition referring to the equation shown in the post.
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
Its right side holds two free functions of , the pressure and .
The source terms are the free functions p(psi) and F(psi) = R B_phi (toroidal field).
Wikipedia, 'Grad-Shafranov equation' (pointer; derives from grad p = J x B, psi and p(psi), F(psi) constant along field lines), https://en.wikipedia.org/wiki/Grad%E2%80%93Shafranov_equation
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
When and are constants the equation is linear, and Solov'ev (1968) wrote down exact solutions.
With p' and FF' constant the right side no longer depends on psi, so the equation is linear; Solov'ev's 1968 exact solutions are the basis of Cerfon and Freidberg's analytic equilibria.
Cerfon and Freidberg, '"One size fits all" analytic solutions to the Grad-Shafranov equation', Phys. Plasmas 17, 032502 (2010), built on Solov'ev profiles (constant p' and FF'), https://pubs.aip.org/aip/pop/article/17/3/032502/106623
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
Satisfies the GS equation with FF' = 0 and -mu0 p' = 1 + 1/kappa^2; near (1,0) psi ~ (R-1)^2/2 + Z^2/(2 kappa^2), ellipses of elongation kappa.
Direct sympy check in this session: Delta* psi = psi_RR - psi_R/R + psi_ZZ = (1 + 1/kappa^2) R^2 for this psi; Wikipedia, 'Grad-Shafranov equation' (pointer; derives from grad p = J x B, psi and p(psi), F(psi) constant along field lines), https://en.wikipedia.org/wiki/Grad%E2%80%93Shafranov_equation
- not-checkable Grad-Shafranov by finite differences, against Solov'ev's closed form
posts/refs/grad-shafranov-solovev.pychecks the closed form with sympy, then solves the same finite-difference equations directly with scipy's sparse LU, which shares no code or method with the SOR iteration here.Describes the reference script.
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
On a grid with spacing in and in , the centered differences for , and give at each interior node
The stencil in the next line is the standard centered discretization of the GS operator.
Wikipedia, 'Grad-Shafranov equation' (pointer; derives from grad p = J x B, psi and p(psi), F(psi) constant along field lines), https://en.wikipedia.org/wiki/Grad%E2%80%93Shafranov_equation; Direct sympy check in this session: centered differences of psi_RR - psi_R/R + psi_ZZ give coefficients 1/h^2 -/+ 1/(2Rh) on psi_{i+/-1,j}
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
Correct discretization of Delta* psi = (1 + 1/kappa^2) R^2.
Wikipedia, 'Grad-Shafranov equation' (pointer; derives from grad p = J x B, psi and p(psi), F(psi) constant along field lines), https://en.wikipedia.org/wiki/Grad%E2%80%93Shafranov_equation; Direct sympy check in this session: coefficients follow from (psi_{i+1}-2psi_i+psi_{i-1})/h^2 - (psi_{i+1}-psi_{i-1})/(2Rh) + Z terms
- not-checkable Grad-Shafranov by finite differences, against Solov'ev's closed form
with fixed to the closed form on the edge of the box.
Describes this program's boundary condition.
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
The term makes the equation unsymmetric in ; that is the only difference from Poisson's equation.
Delta* = d2/dR2 - (1/R) d/dR + d2/dZ2 differs from the 2D Laplacian only by -psi_R/R, which makes the discrete operator nonsymmetric.
Wikipedia, 'Grad-Shafranov equation' (pointer; derives from grad p = J x B, psi and p(psi), F(psi) constant along field lines), https://en.wikipedia.org/wiki/Grad%E2%80%93Shafranov_equation
- not-checkable Grad-Shafranov by finite differences, against Solov'ev's closed form
The three grids have 8, 16 and 32 intervals across and 14, 28 and 56 across , so = 0.1, 0.05 and 0.025.
Describes this program's grids; consistent with the reference's 9x15, 17x29, 33x57 grids.
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
The error of the difference equations is second order, and here it can be written down.
Centered differences are second order; the derivation in the following sentences checks out.
LeVeque, Finite Difference Methods for ODEs and PDEs (SIAM 2007), Ch. 1-2 (centered differences are O(h^2)); not accessed, from general knowledge; Direct sympy check in this session: truncation error computed below is -h^2/4
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
The closed form's term is a quadratic in each variable, so the centered differences are exact on it.
Correct: truncation terms involve third and fourth derivatives, which vanish for R^2 and Z^2.
Direct sympy check in this session: centered first and second differences are exact on quadratics; R^2 Z^2 is quadratic in R and in Z
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
On the second difference is off by and the first difference over by , so the difference operator applied to the exact misses the source by , the same constant at every node.
The arithmetic is correct: the difference operator applied to the exact psi misses the source by -h^2/4 everywhere.
Direct sympy check in this session: psi_RRRR = 3, psi_RRR = 3R for (R^2-1)^2/8; errors h^2*3/12 = h^2/4 and h^2*3R/(6R) = h^2/2; net h^2/4 - h^2/2 = -h^2/4
- verified Grad-Shafranov by finite differences, against Solov'ev's closed form
The error therefore solves the difference equation with source and zero boundary values: it is times a fixed function, up to that function's own discretization, and each halving of divides it by 4.
Correct consequence; the run's errors 1.68e-4, 4.21e-5, 1.06e-5 fall by about 4.
Direct sympy check in this session: L_h psi_h = f, L_h psi = f - h^2/4 so L_h e = h^2/4 with e = 0 on the boundary
- plausible Grad-Shafranov by finite differences, against Solov'ev's closed form
That offset is the Shafranov shift, and it appears whenever there is pressure: the plasma pushes itself outward, where the field is weaker.
True for this pressure-only equilibrium, but in general the toroidal current's hoop force also shifts the axis outward even without pressure; 'whenever there is pressure' is correct as a sufficient condition.
CIEMAT FusionWiki, 'Shafranov shift': outward displacement of flux-surface centers 'induced by plasma pressure and the hoop force' (search snippet read; page itself failed TLS), https://wiki.fusion.ciemat.es/fusionwiki/index.php?title=Shafranov_shift
- verified Graphene's Dirac cones
An electron hopping between neighboring carbon atoms of a honeycomb has two energy bands, and they touch at the corners of the Brillouin zone.
Nearest-neighbor tight binding on the honeycomb gives two bands touching at K and K', the corners of the Brillouin zone.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
Near a corner the energy rises in a straight line in every direction, a cone, with slope .
Castro Neto Eq. (7): E = +/- v_F |q| with v_F = 3ta/2 (hbar = 1).
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- not-checkable Graphene's Dirac cones
The reference, in
posts/refs/graphenes-dirac-cones.py, builds the 2 by 2 Hamiltonian as a complex matrix and diagonalizes it withnumpy.linalg.eigvalsh, where the post uses the closed form ; it finds the slope at K by a least-squares line through 20 points in each of 12 directions.Describes the reference script.
- verified Graphene's Dirac cones
The geometry follows Castro Neto et al., Rev. Mod. Phys. 81, 109 (2009).
Citation is correct, and the post's delta vectors match Castro Neto Eq. (2): delta_{1,2} = (a/2)(1, +/-sqrt3), delta_3 = -a(1,0).
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
Graphene is a single sheet of carbon atoms in a honeycomb.
Castro Neto Sec. II: graphene is a one-atom-thick sheet of carbon in a honeycomb lattice.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
The honeycomb is not itself a lattice with one atom per cell: its atoms come in two kinds, A and B, and every A atom has three B neighbors, at the vectors , and in units of .
Castro Neto Sec. II.A: the honeycomb is two interpenetrating triangular sublattices A and B, with nearest-neighbor vectors as given (Eq. 2).
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
Tight binding keeps one orbital per atom and lets an electron hop only to a nearest neighbor, with energy .
Castro Neto Eq. (5) with t' = 0: nearest-neighbor hopping -t between A and B sites, one pi orbital per atom.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
Standard 2x2 Bloch Hamiltonian for nearest-neighbor hopping; |f| reproduces Castro Neto Eq. (6) with t' = 0.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
Its eigenvalues are : two bands, mirror images of each other.
Castro Neto: the spectrum is symmetric about zero energy when t' = 0.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
With one electron per carbon, the lower band is full and the upper one empty, so everything interesting happens where they come closest.
One pi electron per carbon fills the lower (pi) band; Castro Neto describes graphene at half filling with the Fermi level at the Dirac points.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
At the middle of an edge, M, they are at .
At M the phases are e^{i pi/3} twice and e^{-2 pi i/3}, summing to modulus 1.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163; Direct numerical check in this session: |f(M)|/t = 1.000 at M = (2pi/3a, 0)
- verified Graphene's Dirac cones
At the corner K the three phases are , and , three unit arrows at 120° to each other, which add to zero: the bands touch.
Correct: three unit phasors 120 degrees apart sum to zero.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163; Direct check: with K = (2pi/3a, 2pi/(3 sqrt3 a)) the phases k.delta_j are 2pi/3, 0, -2pi/3; |f(K)| = 4e-16
- verified Graphene's Dirac cones
The standard picture follows the straight lines K M through the zone.
Castro Neto Fig. 2-3 label Gamma, K, M; band plots along Gamma-K-M-Gamma are the standard path.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
At K the two bands meet in a V: the energy rises linearly with the distance from K, not quadratically.
Castro Neto Eq. (7): the dispersion near K is linear, E = +/- v_F |q|.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
The same happens in every direction, so in the plane of the two bands form a pair of cones touching at their tips, called Dirac cones because a massless relativistic particle obeying the Dirac equation has the same linear relation between energy and momentum.
Castro Neto: the low-energy excitations are 'Dirac-like', massless with linear E(q) like a massless Dirac particle.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- not-checkable Graphene's Dirac cones
The map below shows the upper band over the plane.
Describes the post's figure.
- verified Graphene's Dirac cones
The Brillouin zone is the hexagon of momenta closer to , the center of the map, than to any other point of the reciprocal lattice, drawn dashed, and the band reaches zero at its six corners, the dark spots around the center.
The first Brillouin zone of the triangular reciprocal lattice is a hexagon whose six corners are K and K' points where the bands touch.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163; Ashcroft and Mermin, Solid State Physics, Ch. 5 (first Brillouin zone = Wigner-Seitz cell of the reciprocal lattice); not accessed, from general knowledge
- not-checkable Graphene's Dirac cones
The four dark spots near the map's left and right edges are corners of the neighboring hexagons.
Describes the post's figure.
- not-checkable Graphene's Dirac cones
Near K, write .
Definition of notation.
- verified Graphene's Dirac cones
Expanding each phase to first order in gives , so with , the Fermi velocity: the speed of the electrons at the energy where the full band meets the empty one.
Castro Neto Eq. (7): v_F = 3ta/2 (hbar = 1); v_F is the group velocity at the Dirac point.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
The next term of the expansion is proportional to , which changes sign between and , so the centered difference cancels it and leaves an error of order .
Castro Neto Eq. (8): second-order term is (3ta^2/8) sin(3 theta_q) q^2 (angle convention differs from cos 3 phi); it flips sign under q -> -q, so the centered difference cancels it.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
Every direction gives , the worst off by (
worst): the cone is round to first order, and its slope is .Linear term is isotropic with slope 3ta/2 (Eq. 7); 1.5 and the worst deviation 1.87e-9 are computed by the program.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
It is not round to second order.
Castro Neto Eq. (8): trigonal warping, a sin(3 theta) q^2 term, makes the cone anisotropic at second order.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163
- verified Graphene's Dirac cones
Going one way from K, toward M, the band rises a little slower than the straight line, and going toward a little faster.
Matches Eq. (8)'s +/- 3/8 coefficient: slower toward M, faster toward Gamma.
Castro Neto, Guinea, Peres, Novoselov, Geim, 'The electronic properties of graphene', Rev. Mod. Phys. 81, 109 (2009), Sec. II.A, Eqs. (1)-(8), https://arxiv.org/abs/0709.1163; Direct numerical check in this session: (E - 1.5 q)/q^2 = -0.3752 toward M and +0.3748 toward Gamma at q = 1e-3
- not-checkable RHF, UHF and full CI for H₂ in STO-3G along the bond
Pull the two atoms of H₂ apart in the smallest basis there is, and compute its energy three ways.
Introduces the post.
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Full CI is exact in this basis.
Hait et al.: FCI is exact within the basis (and invariant to orbital choice).
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- not-checkable RHF, UHF and full CI for H₂ in STO-3G along the bond
The program is self-contained: the STO-3G basis, the integrals over Gaussian functions, the Hartree-Fock and full-CI energies, all in this file.
Describes this program.
- not-checkable RHF, UHF and full CI for H₂ in STO-3G along the bond
The reference is PySCF 2.5.0 (
posts/refs/h2-rhf-uhf-and-full-ci-along-the-bond.py), which shares no code with it: its own basis library, integrals, SCF solvers, stability analysis and full-CI solver.Describes the reference script and PySCF's role.
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Units are atomic: energies in hartree (1 Ha = 27.211 eV), lengths in bohr (1 bohr = 0.5292 Å), both from CODATA 2022.
27.211 eV and 0.5292 Angstrom are the 2022 CODATA values rounded.
NIST CODATA 2022: hartree energy in eV = 27.211 386 245 981(30) eV, https://physics.nist.gov/cgi-bin/cuu/Value?hrev (read in this session); NIST CODATA 2022: Bohr radius = 5.291 772 105 44(82) x 10^-11 m, https://physics.nist.gov/cgi-bin/cuu/Value?bohrrada0 (read in this session)
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
A hydrogen molecule has two electrons and two protons.
Minimal-basis H2 is a two-electron system (Hait et al.); two protons trivially.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Its electrons' wave function has to be built out of something, and the smallest choice is one function per atom.
Minimal basis STO-3G H2 has one 1s function per atom, two spatial orbitals.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- plausible RHF, UHF and full CI for H₂ in STO-3G along the bond
Gaussians are used because every integral the calculation needs has a closed form for them.
Standard reason (Gaussian product theorem gives closed forms, Boys 1950). Book not accessed; from general knowledge, but the closed forms were checked against PySCF here.
Szabo and Ostlund, Modern Quantum Chemistry, Sec. 3.5 and Appendix A; not accessed, from general knowledge; Direct check in this session: the S, T, V_C and ERI formulas for unnormalized s Gaussians, times primitive normalizations, reproduce PySCF 2.5.0 int1e_ovlp/int1e_kin/int1e_nuc/int2e to 3e-14
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
For two s Gaussians with exponents and , the product is one Gaussian of exponent centered between them, and the standard results (Szabo and Ostlund, Modern Quantum Chemistry, Appendix A) are
Gaussian product theorem: product is a Gaussian of exponent a+b centered between. Szabo-Ostlund Appendix A attribution not accessed directly.
Ho and Hernandez-Perez, 'Evaluation of Gaussian molecular integrals', The Mathematica Journal 14 (2012), Gaussian product theorem and Eq. (6), https://www.mathematica-journal.com/2012/02/16/evaluation-of-gaussian-molecular-integrals/; Direct check in this session: the S, T, V_C and ERI formulas for unnormalized s Gaussians, times primitive normalizations, reproduce PySCF 2.5.0 int1e_ovlp/int1e_kin/int1e_nuc/int2e to 3e-14
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Formulas reproduce PySCF integrals to 3e-14.
Direct check in this session: the S, T, V_C and ERI formulas for unnormalized s Gaussians, times primitive normalizations, reproduce PySCF 2.5.0 int1e_ovlp/int1e_kin/int1e_nuc/int2e to 3e-14; Ho and Hernandez-Perez, Mathematica Journal (2012), Eq. (6) for S
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
and for the repulsion between two such products, with exponents and and centers and , , each times the primitives' normalizations.
ERI formula reproduces PySCF int2e to 3e-14.
Direct check in this session: the S, T, V_C and ERI formulas for unnormalized s Gaussians, times primitive normalizations, reproduce PySCF 2.5.0 int1e_ovlp/int1e_kin/int1e_nuc/int2e to 3e-14
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Restricted Hartree-Fock (RHF) puts both electrons, spin up and spin down, in the same orbital.
RHF: the ground determinant |sigma sigma-bar> puts both spins in one spatial orbital.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
For H₂ in this basis that orbital must be , so nothing needs iterating, and the energy is in molecular-orbital integrals.
In a minimal basis the only gerade orbital is sigma_g, fixed by symmetry; 2h_gg + (gg|gg) + 1/R is the closed-shell RHF energy.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081; Standard closed-shell energy E = 2h_11 + J_11 (Szabo and Ostlund Sec. 3.8; not accessed) plus 1/R
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Unrestricted Hartree-Fock (UHF) lets the spin-up electron have one orbital and the spin-down electron another.
UHF allows different spatial orbitals for alpha and beta spins.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Here they can only be mixtures of and ; the lowest-energy pair has the form , which leans the spin-up electron toward one atom and the spin-down electron toward the other.
Hait et al.: UHF orbitals A = sigma cos(theta) + sigma* sin(theta), B = sigma cos(theta) - sigma* sin(theta), localizing toward opposite atoms.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- not-checkable RHF, UHF and full CI for H₂ in STO-3G along the bond
The program minimizes the energy over .
Describes this program.
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Full configuration interaction (FCI) is the exact answer within the basis: the lowest eigenvalue of the Hamiltonian over every two-electron state the two orbitals allow.
FCI diagonalizes over all determinants the orbitals allow; Hait et al. list six for minimal-basis H2.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
It is 1.8% of the total energy and 0.56 eV, the same size as the energy differences chemistry cares about.
Arithmetic checks; 'same size as chemistry's energy differences' is informal (reaction energies are tenths of an eV to eV).
NIST CODATA 2022 hartree = 27.211386 eV, https://physics.nist.gov/cgi-bin/cuu/Value?hrev; Arithmetic: 0.02056/1.13728 = 1.81%, 0.02056 x 27.2114 = 0.5595 eV
- not-checkable RHF, UHF and full CI for H₂ in STO-3G along the bond
The reason is in its one orbital.
Transition.
- plausible RHF, UHF and full CI for H₂ in STO-3G along the bond
written out in the atoms' functions is : half the time the two electrons are on different atoms, and half the time they are both on one, H⁻ next to a bare proton.
Hait et al. confirm the ionic terms make up 50% of the RHF wave function at dissociation; the exact coefficient is 1/(2(1+S)), which equals 1/2 only when the overlap S vanishes, as the next sentence assumes.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Once the atoms' functions stop overlapping, that ionic half costs the repulsion of two electrons on one atom and gains the attraction between H⁻ and the proton, each weighted by one half.
Consistent with the run: excess at R = 20 equals (11|11)/2 - 1/(2R).
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081; Direct derivation: ionic H-/H+ minus two H atoms = (11|11) - 1/R when overlap vanishes; weighted by 1/2
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
At bohr the excess is Ha (
excess_20), which is to nine digits, and at it is (excess_limit), on its way to Ha.The numbers are mutually consistent and the 20-bohr value is checked against PySCF by the linked test.
Szabo and Ostlund Table 3.x STO-3G H2 (11|11) = 0.7746 Ha; not accessed, from general knowledge; Arithmetic: 0.7746/2 = 0.3873; 0.3873 - 1/40 = 0.3623; 0.3873 - 1/2000 = 0.3868
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
RHF describes the separated atoms as half atoms and half ions.
Hait et al.: spurious ionic contributions make up 50% of the RHF wave function at dissociation.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
UHF avoids this by letting the spin-up electron sit on one atom and the spin-down electron on the other.
Hait et al.: the stable UHF ground state at dissociation has one electron localized on each atom.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Close to equilibrium that costs more than it gains, and UHF's lowest state is the RHF one.
Below the Coulson-Fischer point the stable HF ground state is the unpolarized |sigma sigma-bar>.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Past a bond length called the Coulson-Fischer point it pays, and the two curves split.
The CF point is where the RHF solution becomes unstable and a lower UHF solution appears.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- not-checkable RHF, UHF and full CI for H₂ in STO-3G along the bond
The price is the spin.
Transition introducing spin contamination.
- verified RHF, UHF and full CI for H₂ in STO-3G along the bond
Full CI stays a pure singlet and goes to the right limit smoothly: it mixes in , which cancels the ionic half of , a little near equilibrium and half and half at large .
FCI is spin-pure; the ground state mixes the doubly excited sigma_u^2 determinant, which removes the ionic part and gives equal weights at dissociation.
Hait, Rettig, Head-Gordon, 'Beyond the Coulson-Fischer point', PCCP 2019, arXiv:1908.07081, Sec. on minimal-basis (STO-3G) H2: RHF 50% ionic, UHF orbitals sigma cos(theta) +/- sigma* sin(theta), <S^2> = sin^2(2 theta), https://arxiv.org/abs/1908.07081
- verified The Hasegawa-Wakatani drift-wave model
The Hasegawa-Wakatani equations are the simplest model of drift-wave turbulence at the edge of a tokamak that contains the instability driving it.
Replaces disputed 45f9a53ebe36.
'Phase transition from turbulence to zonal flows in the Hasegawa-Wakatani system', arXiv:2410.01406, abstract: 'a minimal model of beta-plane-like drift-wave turbulence with an intrinsic instability'; Sec. 2: the C -> infinity Hasegawa-Mima limit has no linear instability, https://arxiv.org/abs/2410.01406
- verified The Hasegawa-Wakatani drift-wave model
The edge of a magnetically confined plasma has a steep density gradient, and the gradient drives drift waves: ripples in density and electric potential that travel across the magnetic field, along the surfaces of constant density.
The equations have kappa = -(1/n0) dn0/dx as drive and the drift wave propagates in y, perpendicular to both B and the gradient, i.e. within constant-density surfaces.
'Phase transition from turbulence to zonal flows in the Hasegawa-Wakatani system', arXiv:2410.01406, Sec. 2 (equations, C = adiabaticity, kappa = -(1/n0) dn0/dx, lengths in rho_s, C -> infinity gives Hasegawa-Mima 'without linear instability'), https://arxiv.org/html/2410.01406; Hasegawa and Wakatani, 'Plasma Edge Turbulence', Phys. Rev. Lett. 50, 682 (1983), https://doi.org/10.1103/PhysRevLett.50.682
- verified The Hasegawa-Wakatani drift-wave model
The Hasegawa-Wakatani equations (1983) describe them with two fields in the plane perpendicular to : the density fluctuation and the electric potential , whose Laplacian is the vorticity of the flow.
HW (PRL 1983) is a two-field model for n and phi; the vorticity is laplacian phi of the E x B flow.
Hasegawa and Wakatani, 'Plasma Edge Turbulence', Phys. Rev. Lett. 50, 682 (1983), https://doi.org/10.1103/PhysRevLett.50.682; 'Phase transition from turbulence to zonal flows in the Hasegawa-Wakatani system', arXiv:2410.01406, Sec. 2 (equations, C = adiabaticity, kappa = -(1/n0) dn0/dx, lengths in rho_s, C -> infinity gives Hasegawa-Mima 'without linear instability'), https://arxiv.org/html/2410.01406
- verified The Hasegawa-Wakatani drift-wave model
Matches the standard form with dissipation dropped: dt zeta + [phi,zeta] = C(phi - n), dt n + [phi,n] + kappa dy phi = C(phi - n).
'Phase transition from turbulence to zonal flows in the Hasegawa-Wakatani system', arXiv:2410.01406, Sec. 2 (equations, C = adiabaticity, kappa = -(1/n0) dn0/dx, lengths in rho_s, C -> infinity gives Hasegawa-Mima 'without linear instability'), https://arxiv.org/html/2410.01406
- verified The Hasegawa-Wakatani drift-wave model
is the density gradient, the drive.
kappa = -(1/n0) dn0/dx, the free-energy source driving the instability.
'Phase transition from turbulence to zonal flows in the Hasegawa-Wakatani system', arXiv:2410.01406, Sec. 2 (equations, C = adiabaticity, kappa = -(1/n0) dn0/dx, lengths in rho_s, C -> infinity gives Hasegawa-Mima 'without linear instability'), https://arxiv.org/html/2410.01406
- verified The Hasegawa-Wakatani drift-wave model
is the adiabaticity: how fast electrons stream along the field line to keep the density in step with the potential.
C = k_par^2 rho_s B/(e n0 eta_par) is the adiabaticity; C -> infinity gives Boltzmann electrons, n = phi.
'Phase transition from turbulence to zonal flows in the Hasegawa-Wakatani system', arXiv:2410.01406, Sec. 2 (equations, C = adiabaticity, kappa = -(1/n0) dn0/dx, lengths in rho_s, C -> infinity gives Hasegawa-Mima 'without linear instability'), https://arxiv.org/html/2410.01406
- verified The Hasegawa-Wakatani drift-wave model
The brackets are the nonlinear advection; every rung here is linear, so they drop out.
[phi, A] = (z x grad phi).grad A is the nonlinear E x B advection, quadratic in fluctuations, so it drops from the linearized equations.
'Phase transition from turbulence to zonal flows in the Hasegawa-Wakatani system', arXiv:2410.01406, Sec. 2 (equations, C = adiabaticity, kappa = -(1/n0) dn0/dx, lengths in rho_s, C -> infinity gives Hasegawa-Mima 'without linear instability'), https://arxiv.org/html/2410.01406
- verified The Hasegawa-Wakatani drift-wave model
Standard Hasegawa-Mima drift-wave dispersion relation.
'Phase transition from turbulence to zonal flows in the Hasegawa-Wakatani system', arXiv:2410.01406, Sec. 2 (equations, C = adiabaticity, kappa = -(1/n0) dn0/dx, lengths in rho_s, C -> infinity gives Hasegawa-Mima 'without linear instability'), https://arxiv.org/html/2410.01406; Direct sympy check in this session: linearizing dt(lap phi - phi) = kappa dy phi gives omega (1 + k^2) = kappa k_y
- verified The Hasegawa-Wakatani drift-wave model
Both the growth rate and the relative frequency shift follow from the linear HW system.
Direct sympy check in this session: linear dispersion omega - i eps omega^2 = omega_HM with eps = k^2/(C(1+k^2)) expands to omega_HM + i eps omega_HM^2 - 2 eps^2 omega_HM^3
- verified The Hasegawa-Wakatani drift-wave model
Solution is correct for unmodified HW; at k = 0.5 the limit is 0.25/1.25 = 0.2.
'Phase transition from turbulence to zonal flows in the Hasegawa-Wakatani system', arXiv:2410.01406, Sec. 2 (equations, C = adiabaticity, kappa = -(1/n0) dn0/dx, lengths in rho_s, C -> infinity gives Hasegawa-Mima 'without linear instability'), https://arxiv.org/html/2410.01406; Direct sympy check in this session: with k_y = 0, zeta - n is conserved and d zeta/dt = C(1 - zeta(1 + 1/k^2))
- verified Jacobi's eigenvalue method
Jacobi's method diagonalizes a symmetric matrix by plane rotations, each of which zeroes one off-diagonal pair.
Each Jacobi rotation zeroes one symmetric off-diagonal pair (a_pq, a_qp).
Wikipedia, 'Jacobi eigenvalue algorithm' (pointer to Jacobi 1846, Crelle's J. 30; rotated-entry formula, tan 2θ condition, off-norm drops by 2a_pq^2, Schönhage quadratic convergence), https://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm; J. Lambers, CME 335 Lecture 7 Notes: Jacobi Methods (off(B)^2 = off(A)^2 - 2a_pq^2; Frobenius invariance; |θ| ≤ π/4 minimizes ||B - A||_F; cyclic sweeps; quadratic convergence), https://web.stanford.edu/class/cme335/lecture7.pdf
- verified Jacobi's eigenvalue method
A symmetric matrix has an orthogonal matrix of eigenvectors with diagonal.
Spectral theorem for real symmetric matrices, which the Jacobi method constructs.
J. Lambers, CME 335 Lecture 7 Notes: Jacobi Methods (off(B)^2 = off(A)^2 - 2a_pq^2; Frobenius invariance; |θ| ≤ π/4 minimizes ||B - A||_F; cyclic sweeps; quadratic convergence), https://web.stanford.edu/class/cme335/lecture7.pdf; Wikipedia, 'Jacobi eigenvalue algorithm' (pointer to Jacobi 1846, Crelle's J. 30; rotated-entry formula, tan 2θ condition, off-norm drops by 2a_pq^2, Schönhage quadratic convergence), https://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm
- verified Jacobi's eigenvalue method
Jacobi's method (1846) builds out of plane rotations.
Jacobi proposed the method in 1846 (Crelle's Journal 30); V is the product of the plane rotations.
Wikipedia, 'Jacobi eigenvalue algorithm' (pointer to Jacobi 1846, Crelle's J. 30; rotated-entry formula, tan 2θ condition, off-norm drops by 2a_pq^2, Schönhage quadratic convergence), https://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm
- verified Jacobi's eigenvalue method
A later rotation can make an earlier zero nonzero again, so one sweep does not finish the job, but the size of the off-diagonal part, , falls with every rotation.
off(B)^2 = off(A)^2 - 2a_pq^2, so off falls with each rotation (strictly when a_pq ≠ 0) even though earlier zeros are refilled.
J. Lambers, CME 335 Lecture 7 Notes: Jacobi Methods (off(B)^2 = off(A)^2 - 2a_pq^2; Frobenius invariance; |θ| ≤ π/4 minimizes ||B - A||_F; cyclic sweeps; quadratic convergence), https://web.stanford.edu/class/cme335/lecture7.pdf; Wikipedia, 'Jacobi eigenvalue algorithm' (pointer to Jacobi 1846, Crelle's J. 30; rotated-entry formula, tan 2θ condition, off-norm drops by 2a_pq^2, Schönhage quadratic convergence), https://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm
- not-checkable Jacobi's eigenvalue method
The reference is numpy: the same sweeps in Python and
numpy.linalg.eighon the same matrix (posts/refs/jacobi-eigenvalue-sweeps.py, output beside it).Describes the post's reference script.
- verified Jacobi's eigenvalue method
Rotating the and rows and columns through changes only those two rows and columns.
J^T A J with a rotation in the (p, q) plane alters only rows and columns p and q.
Wikipedia, 'Jacobi eigenvalue algorithm' (pointer to Jacobi 1846, Crelle's J. 30; rotated-entry formula, tan 2θ condition, off-norm drops by 2a_pq^2, Schönhage quadratic convergence), https://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm
- not-checkable Jacobi's eigenvalue method
The new entry is
Lead-in to a formula.
- verified Jacobi's eigenvalue method
Matches Wikipedia's S'_ij = cos 2θ S_ij + ½ sin 2θ (S_ii - S_jj) up to the sign convention for θ (rotation direction); the post's version is consistent with its own tan 2θ condition.
Wikipedia, 'Jacobi eigenvalue algorithm' (pointer to Jacobi 1846, Crelle's J. 30; rotated-entry formula, tan 2θ condition, off-norm drops by 2a_pq^2, Schönhage quadratic convergence), https://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm
- verified Jacobi's eigenvalue method
which is zero when .
Setting the formula to zero gives tan 2θ = 2a_pq/(a_pp - a_qq) in the post's sign convention.
Wikipedia, 'Jacobi eigenvalue algorithm' (pointer to Jacobi 1846, Crelle's J. 30; rotated-entry formula, tan 2θ condition, off-norm drops by 2a_pq^2, Schönhage quadratic convergence), https://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm
- verified Jacobi's eigenvalue method
atan2picks the angle with when , the smaller rotation, which disturbs the rest of the matrix least.θ = ½ atan2(2a_pq, a_pp - a_qq) lies in (-π/4, π/4) when a_pp > a_qq; Lambers notes |θ| ≤ π/4 minimizes ||B - A||_F.
J. Lambers, CME 335 Lecture 7 Notes: Jacobi Methods (off(B)^2 = off(A)^2 - 2a_pq^2; Frobenius invariance; |θ| ≤ π/4 minimizes ||B - A||_F; cyclic sweeps; quadratic convergence), https://web.stanford.edu/class/cme335/lecture7.pdf
- verified Jacobi's eigenvalue method
A rotation leaves the sum of squares of all entries unchanged, and it moves exactly of it from off the diagonal onto it.
Orthogonal similarity preserves the Frobenius norm and off(B)^2 = off(A)^2 - 2a_pq^2.
J. Lambers, CME 335 Lecture 7 Notes: Jacobi Methods (off(B)^2 = off(A)^2 - 2a_pq^2; Frobenius invariance; |θ| ≤ π/4 minimizes ||B - A||_F; cyclic sweeps; quadratic convergence), https://web.stanford.edu/class/cme335/lecture7.pdf; Wikipedia, 'Jacobi eigenvalue algorithm' (pointer to Jacobi 1846, Crelle's J. 30; rotated-entry formula, tan 2θ condition, off-norm drops by 2a_pq^2, Schönhage quadratic convergence), https://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm
- verified Jacobi's eigenvalue method
That is why can only fall.
Follows from the preceding identity.
J. Lambers, CME 335 Lecture 7 Notes: Jacobi Methods (off(B)^2 = off(A)^2 - 2a_pq^2; Frobenius invariance; |θ| ≤ π/4 minimizes ||B - A||_F; cyclic sweeps; quadratic convergence), https://web.stanford.edu/class/cme335/lecture7.pdf
- verified Jacobi's eigenvalue method
A sweep rotates every pair in order, : 28 rotations for .
Cyclic-by-row order over p < q; 8·7/2 = 28 rotations per sweep.
J. Lambers, CME 335 Lecture 7 Notes: Jacobi Methods (off(B)^2 = off(A)^2 - 2a_pq^2; Frobenius invariance; |θ| ≤ π/4 minimizes ||B - A||_F; cyclic sweeps; quadratic convergence), https://web.stanford.edu/class/cme335/lecture7.pdf
- verified Jacobi's eigenvalue method
Once it is small next to the gaps between the eigenvalues (here the smallest gap is 0.44), each sweep roughly squares it: and the next value is ; and the next is .
Cyclic Jacobi converges quadratically once off(A) is small relative to the eigenvalue gaps (Schönhage); the reference output shows off-norms 0.0299, 3.18e-5, 8.3e-13, each below the square of the previous, and a smallest gap of 0.4385.
Wikipedia, 'Jacobi eigenvalue algorithm' (pointer to Jacobi 1846, Crelle's J. 30; rotated-entry formula, tan 2θ condition, off-norm drops by 2a_pq^2, Schönhage quadratic convergence), https://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm; J. Lambers, CME 335 Lecture 7 Notes: Jacobi Methods (off(B)^2 = off(A)^2 - 2a_pq^2; Frobenius invariance; |θ| ≤ π/4 minimizes ||B - A||_F; cyclic sweeps; quadratic convergence), https://web.stanford.edu/class/cme335/lecture7.pdf; posts/refs/jacobi-eigenvalue-sweeps.out (reference run output)
- plausible Jacobi's eigenvalue method
The number of correct digits doubles each sweep, as it does for Newton's method, and the fifth sweep hits rounding: under , about times the size of the matrix itself.
Quadratic convergence is standard; the program measures off(A) after the fifth sweep at 4.48e-17 times the Frobenius norm of A, and tests it.
Wikipedia, 'Jacobi eigenvalue algorithm' (pointer to Jacobi 1846, Crelle's J. 30; rotated-entry formula, tan 2θ condition, off-norm drops by 2a_pq^2, Schönhage quadratic convergence), https://en.wikipedia.org/wiki/Jacobi_eigenvalue_algorithm; posts/refs/jacobi-eigenvalue-sweeps.out (reference run output)
- verified Jacobi's eigenvalue method
The eigenvalues are checked against
numpy.linalg.eigh, which uses a different algorithm (LAPACK's tridiagonal reduction), and the product is checked against the matrix we started from.eigh calls LAPACK _syevd, which reduces to tridiagonal form and then uses divide and conquer, a different algorithm from Jacobi.
NumPy docs, numpy.linalg.eigh, Notes: 'computed using LAPACK routines _syevd, _heevd', https://numpy.org/doc/stable/reference/generated/numpy.linalg.eigh.html
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
The five-point stencil turns it into linear equations,
One five-point equation per interior point gives n^2 equations.
C. H. Rycroft, 'Iterative methods for linear systems' (Berkeley Math 228A notes, 2007): 2D model problem, eigenvalues 4 - 2cos - 2cos with sine eigenvectors, ρ(R_J) = cos(π/(N+1)), ρ(R_GS) = cos^2, optimal SOR ω, O(N^2) vs O(N) iterations, https://math.berkeley.edu/~wilken/228A.F07/chr_lecture.pdf
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
Standard five-point discretization of -∇²u = f multiplied by h^2.
C. H. Rycroft, 'Iterative methods for linear systems' (Berkeley Math 228A notes, 2007): 2D model problem, eigenvalues 4 - 2cos - 2cos with sine eigenvectors, ρ(R_J) = cos(π/(N+1)), ρ(R_GS) = cos^2, optimal SOR ω, O(N^2) vs O(N) iterations, https://math.berkeley.edu/~wilken/228A.F07/chr_lecture.pdf
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
one per grid point, and for short.
One equation per interior grid point, written A u = b.
C. H. Rycroft, 'Iterative methods for linear systems' (Berkeley Math 228A notes, 2007): 2D model problem, eigenvalues 4 - 2cos - 2cos with sine eigenvectors, ρ(R_J) = cos(π/(N+1)), ρ(R_GS) = cos^2, optimal SOR ω, O(N^2) vs O(N) iterations, https://math.berkeley.edu/~wilken/228A.F07/chr_lecture.pdf
- plausible Jacobi, SOR and conjugate gradients on the Poisson equation
Direct elimination is possible at this size, but the iterative methods here need only the stencil, so they are what gets used when the grid is large or three-dimensional.
Iterative methods need only the stencil and dominate for large or 3D grids, though in practice plain Jacobi/SOR are mostly used as multigrid smoothers or replaced by preconditioned CG (Rycroft notes Jacobi is too slow for many problems).
C. H. Rycroft, 'Iterative methods for linear systems' (Berkeley Math 228A notes, 2007): 2D model problem, eigenvalues 4 - 2cos - 2cos with sine eigenvectors, ρ(R_J) = cos(π/(N+1)), ρ(R_GS) = cos^2, optimal SOR ω, O(N^2) vs O(N) iterations, https://math.berkeley.edu/~wilken/228A.F07/chr_lecture.pdf
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
The forcing has the exact solution .
Checked by symbolic differentiation.
Direct differentiation (checked with sympy): -∇²[x(1-x)y(1-y)] = 2[x(1-x) + y(1-y)], and u vanishes on the edges of the unit square
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
The second difference of a quadratic is exact, so the grid solution equals at every grid point, and whatever error remains is the solver's.
Truncation error of the five-point stencil involves fourth derivatives in x and y separately, both zero here.
Direct expansion: the centered second difference of a quadratic in x (or y) is exact; u is quadratic in each variable separately, so the five-point Laplacian of u equals ∇²u at every grid point
- not-checkable Jacobi, SOR and conjugate gradients on the Poisson equation
The Python twin is
posts/refs/jacobi-sor-and-cg-on-the-poisson-equation.py(output beside it).Describes the post's reference script.
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
A Jacobi sweep solves each equation for its own unknown, using the neighbors' values from the previous sweep: .
Jacobi update for the five-point system with b = h^2 f.
C. H. Rycroft, 'Iterative methods for linear systems' (Berkeley Math 228A notes, 2007): 2D model problem, eigenvalues 4 - 2cos - 2cos with sine eigenvectors, ρ(R_J) = cos(π/(N+1)), ρ(R_GS) = cos^2, optimal SOR ω, O(N^2) vs O(N) iterations, https://math.berkeley.edu/~wilken/228A.F07/chr_lecture.pdf
- not-checkable Jacobi, SOR and conjugate gradients on the Poisson equation
All points update at once, so it is a few whole-array operations.
Describes the implementation.
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
Its error obeys .
Jacobi iteration matrix is I - D^{-1}A with D = 4I, so e ← (I - A/4)e.
C. H. Rycroft, 'Iterative methods for linear systems' (Berkeley Math 228A notes, 2007): 2D model problem, eigenvalues 4 - 2cos - 2cos with sine eigenvectors, ρ(R_J) = cos(π/(N+1)), ρ(R_GS) = cos^2, optimal SOR ω, O(N^2) vs O(N) iterations, https://math.berkeley.edu/~wilken/228A.F07/chr_lecture.pdf
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
Gauss-Seidel does the same update point by point, in order, and uses each new value as soon as it has it.
Gauss-Seidel uses updated values as soon as they are computed.
C. H. Rycroft, 'Iterative methods for linear systems' (Berkeley Math 228A notes, 2007): 2D model problem, eigenvalues 4 - 2cos - 2cos with sine eigenvectors, ρ(R_J) = cos(π/(N+1)), ρ(R_GS) = cos^2, optimal SOR ω, O(N^2) vs O(N) iterations, https://math.berkeley.edu/~wilken/228A.F07/chr_lecture.pdf
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
SOR (successive over-relaxation) takes the Gauss-Seidel update and goes further in the same direction: $u_{ij} \leftarrow u_{ij} + \omega\,(u^{GS}_{ij}
SOR extrapolates the Gauss-Seidel correction by ω; over-relaxation means 1 < ω < 2.
Wikipedia, 'Successive over-relaxation' (Young and Frankel 1950; 0 < ω < 2; ω_opt from the Jacobi spectral radius; ρ_GS = ρ_J^2), https://en.wikipedia.org/wiki/Successive_over-relaxation; C. H. Rycroft, 'Iterative methods for linear systems' (Berkeley Math 228A notes, 2007): 2D model problem, eigenvalues 4 - 2cos - 2cos with sine eigenvectors, ρ(R_J) = cos(π/(N+1)), ρ(R_GS) = cos^2, optimal SOR ω, O(N^2) vs O(N) iterations, https://math.berkeley.edu/~wilken/228A.F07/chr_lecture.pdf
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
It needs only products with .
CG touches A only through matrix-vector products.
J. R. Shewchuk, 'An Introduction to the Conjugate Gradient Method Without the Agonizing Pain' (1994), §9.2 Eq. 52 (||e_i||_A ≤ 2((√κ-1)/(√κ+1))^i ||e_0||_A) and §10 (cost dominated by matrix-vector products; iterations ~ ½√κ ln(2/ε)), https://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
Its error bound depends on the condition number , the ratio of the largest eigenvalue of to the smallest: after steps the error, measured in the norm , has shrunk by at least .
Standard CG bound in the A-norm with κ = λ_max/λ_min.
J. R. Shewchuk, 'An Introduction to the Conjugate Gradient Method Without the Agonizing Pain' (1994), §9.2 Eq. 52 (||e_i||_A ≤ 2((√κ-1)/(√κ+1))^i ||e_0||_A) and §10 (cost dominated by matrix-vector products; iterations ~ ½√κ ln(2/ε)), https://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
It is a worst case over right-hand sides, and it bounds that error rather than the residual the stopping test measures, so it is a guide to the count, not a prediction of it.
The bound is on the A-norm of the error, worst case over eigenvalue distributions/starting errors; Shewchuk notes CG usually converges faster than Eq. 52 suggests.
J. R. Shewchuk, 'An Introduction to the Conjugate Gradient Method Without the Agonizing Pain' (1994), §9.2 Eq. 52 (||e_i||_A ≤ 2((√κ-1)/(√κ+1))^i ||e_0||_A) and §10 (cost dominated by matrix-vector products; iterations ~ ½√κ ln(2/ε)), https://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
Like SOR, CG's count grows like .
CG iterations scale as √κ and κ ∝ 1/h^2 for the model problem; optimal SOR needs O(1/h) iterations.
J. R. Shewchuk, 'An Introduction to the Conjugate Gradient Method Without the Agonizing Pain' (1994), §9.2 Eq. 52 (||e_i||_A ≤ 2((√κ-1)/(√κ+1))^i ||e_0||_A) and §10 (cost dominated by matrix-vector products; iterations ~ ½√κ ln(2/ε)), https://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf; C. H. Rycroft, 'Iterative methods for linear systems' (Berkeley Math 228A notes, 2007): 2D model problem, eigenvalues 4 - 2cos - 2cos with sine eigenvectors, ρ(R_J) = cos(π/(N+1)), ρ(R_GS) = cos^2, optimal SOR ω, O(N^2) vs O(N) iterations, https://math.berkeley.edu/~wilken/228A.F07/chr_lecture.pdf
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
Unlike SOR, it needs no parameter tuned to the matrix.
CG's step lengths and directions come from the iteration itself; no relaxation parameter is chosen.
J. R. Shewchuk, 'An Introduction to the Conjugate Gradient Method Without the Agonizing Pain' (1994), §9.2 Eq. 52 (||e_i||_A ≤ 2((√κ-1)/(√κ+1))^i ||e_0||_A) and §10 (cost dominated by matrix-vector products; iterations ~ ½√κ ln(2/ε)), https://www.cs.cmu.edu/~quake-papers/painless-conjugate-gradient.pdf
- verified Jacobi, SOR and conjugate gradients on the Poisson equation
The dashed lines are the theory's rates: for Jacobi and for Gauss-Seidel.
cos πh and cos^2 πh are the Jacobi and Gauss-Seidel spectral radii for the model problem, the asymptotic per-sweep rates.
C. H. Rycroft, 'Iterative methods for linear systems' (Berkeley Math 228A notes, 2007): 2D model problem, eigenvalues 4 - 2cos - 2cos with sine eigenvectors, ρ(R_J) = cos(π/(N+1)), ρ(R_GS) = cos^2, optimal SOR ω, O(N^2) vs O(N) iterations, https://math.berkeley.edu/~wilken/228A.F07/chr_lecture.pdf
- not-checkable Jacobi, SOR and conjugate gradients on the Poisson equation
After the first few sweeps each measured line runs parallel to its dashed one.
Describes the post's figure.
- not-checkable Jacobi, SOR and conjugate gradients on the Poisson equation
The last cell solves the same problem on 23 by 23 and 31 by 31 grids ( and ) with Jacobi, SOR and CG, and plots the counts against on log axes.
Describes what the program runs.
- verified Three floating-point failures in summation, cancellation and RANDU
Evaluating from its expanded coefficients near gives rounding noise: 89 sign changes among 401 points, where the polynomial has one, and 8.5 times the true value at .
Reference output: 89 Horner sign changes in 401 points, Horner 6.66e-16 vs exact 7.81e-17 at x = 1.005 (ratio 8.5); (x-1)^7 has a single odd-order root, so one sign change.
posts/refs/kahan-summation-horner-noise-and-randus-planes.out (reference run output); N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §5.1 Horner's method: cost 2n flops, Eq. 5.3: |p(x) - q_0| ≤ γ_2n Σ|a_i||x|^i, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- verified Three floating-point failures in summation, cancellation and RANDU
The factored form is within everywhere.
Reference output gives a largest relative error of 1.385 eps for the factored form, consistent with exact x - 1 plus six rounded multiplications.
posts/refs/kahan-summation-horner-noise-and-randus-planes.out (reference run output); N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), Theorem 2.5 (Sterbenz): y/2 ≤ x ≤ 2y implies fl(x - y) = x - y, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- not-checkable Three floating-point failures in summation, cancellation and RANDU
Each section computes something in double precision and compares it with an exact answer.
Describes the post.
- verified Three floating-point failures in summation, cancellation and RANDU
A double has a 53-bit significand, so a sum, product or quotient of two doubles is the exact result times with .
IEEE double has t = 53 and u = 2^-53; basic operations satisfy fl(x op y) = (x op y)(1 + δ), |δ| ≤ u (absent overflow/underflow).
N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §2.1-2.2: double precision t = 53, u = 2^-53, fl(x op y) = (x op y)(1 + δ), |δ| ≤ u, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- verified Three floating-point failures in summation, cancellation and RANDU
Adding term by term, each addition rounds the running sum, and the rounding errors pile up.
Recursive summation rounds each partial sum and the error bound grows with n.
N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §4.2 recursive summation error, §4.3 Algorithm 4.2 (compensated summation) and Eq. 4.9: |E_n| ≤ (2u + O(nu^2)) Σ|x_i|, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- verified Three floating-point failures in summation, cancellation and RANDU
Once the sum is near 14, a term like keeps only the bits that line up with the sum's last bit, about 30 of its 53.
Arithmetic check: near 14 the ulp is 2^-49, and 1e-6 ≈ 2^-19.9, so bits 2^-20 down to 2^-49 survive, about 30 of 53.
N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §2.1-2.2: double precision t = 53, u = 2^-53, fl(x op y) = (x op y)(1 + δ), |δ| ≤ u, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- verified Three floating-point failures in summation, cancellation and RANDU
Kahan's method (1965) keeps a second variable holding what the last addition rounded away, and subtracts it from the next term before adding:
Kahan, CACM 8(1):40, 1965; the correction variable carries the rounded-away part.
Wikipedia, 'Kahan summation algorithm' (pseudocode y = x - c, t = sum + y, c = (t - sum) - y, sum = t; Kahan, 'Further remarks on reducing truncation errors', CACM 8(1):40, 1965), https://en.wikipedia.org/wiki/Kahan_summation_algorithm; N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §4.2 recursive summation error, §4.3 Algorithm 4.2 (compensated summation) and Eq. 4.9: |E_n| ≤ (2u + O(nu^2)) Σ|x_i|, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- verified Three floating-point failures in summation, cancellation and RANDU
Matches the standard pseudocode exactly.
Wikipedia, 'Kahan summation algorithm' (pseudocode y = x - c, t = sum + y, c = (t - sum) - y, sum = t; Kahan, 'Further remarks on reducing truncation errors', CACM 8(1):40, 1965), https://en.wikipedia.org/wiki/Kahan_summation_algorithm
- verified Three floating-point failures in summation, cancellation and RANDU
In floating point, is the part of that made it into , and subtracting leaves the part that did not, with its sign flipped.
(t - s) recovers the high part of y that entered t; (t - s) - y is minus the lost low part.
Wikipedia, 'Kahan summation algorithm' (pseudocode y = x - c, t = sum + y, c = (t - sum) - y, sum = t; Kahan, 'Further remarks on reducing truncation errors', CACM 8(1):40, 1965), https://en.wikipedia.org/wiki/Kahan_summation_algorithm; N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §4.2 recursive summation error, §4.3 Algorithm 4.2 (compensated summation) and Eq. 4.9: |E_n| ≤ (2u + O(nu^2)) Σ|x_i|, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- plausible Three floating-point failures in summation, cancellation and RANDU
The error of the result is at most about , independent of the number of terms, as long as is small.
True as an upper bound but twice the standard one: Higham Eq. 4.9 gives (2u + O(nu^2))Σ|x_i| with u = 2^-53, which is about ε|s| with the post's ε = 2^-52 (all terms positive), so 'about ε|s|' would be the accurate statement.
N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §4.2 recursive summation error, §4.3 Algorithm 4.2 (compensated summation) and Eq. 4.9: |E_n| ≤ (2u + O(nu^2)) Σ|x_i|, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- verified Three floating-point failures in summation, cancellation and RANDU
Horner's rule evaluates it with seven multiplications and seven additions, .
Horner for degree n costs n multiplications and n additions; the displayed nesting shows six multiplications only because the leading coefficient 1 makes the first product 1·x trivial.
N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §5.1 Horner's method: cost 2n flops, Eq. 5.3: |p(x) - q_0| ≤ γ_2n Σ|a_i||x|^i, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf; Wikipedia, 'Horner's method': degree n with n multiplications and n additions, https://en.wikipedia.org/wiki/Horner%27s_method
- verified Three floating-point failures in summation, cancellation and RANDU
Near the partial results are 1, , 15, , 15, , 1, while the answer is tiny ( at ).
Direct computation.
Arithmetic: at x = 1 the Horner partial sums are 1, -6, 15, -20, 15, -6, 1 (then 0); (0.01)^7 = 1e-14
- verified Three floating-point failures in summation, cancellation and RANDU
Each partial result is rounded, by up to half an ulp of a number near 20, about , and those errors are as large as the answer.
ulp(20) = 2^-48 ≈ 3.6e-15, half of it ≈ 1.8e-15; answers near the root are 1e-14 or smaller.
N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §2.1-2.2: double precision t = 53, u = 2^-53, fl(x op y) = (x op y)(1 + δ), |δ| ≤ u, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- verified Three floating-point failures in summation, cancellation and RANDU
The rounding bound for Horner's rule (Higham, Accuracy and Stability of Numerical Algorithms, section 5.1) is with and the unit roundoff ; here it is about , and the measured errors reach of it.
Replaces disputed 698c1fb84477. Code (horner_bound), reference and test now use u = EPS/2 = 2^-53; bound about 2e-13, errors 2.6% of it.
Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed., Lemma 3.1 and Eq. (5.3): gamma_n = n u / (1 - n u), u = 2^-53 unit roundoff (Table 2.1); posts/refs/kahan-summation-horner-noise-and-randus-planes.out (regenerated): largest ratio to gamma_14 sum|c_i||x|^i is 0.0264; the bound peaks at 2.13e-13 on [0.98, 1.02] (computed)
- verified Three floating-point failures in summation, cancellation and RANDU
The factored form has no such problem.
Factored form's relative error is at most about 6u (1.385 eps measured).
N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), Theorem 2.5 (Sterbenz): y/2 ≤ x ≤ 2y implies fl(x - y) = x - y, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf; posts/refs/kahan-summation-horner-noise-and-randus-planes.out (reference run output)
- verified Three floating-point failures in summation, cancellation and RANDU
For between and 2, is computed exactly (Sterbenz's lemma: the difference of two doubles within a factor of 2 of each other is a double), and then six multiplications each add a relative error of at most .
Sterbenz: y/2 ≤ x ≤ 2y implies x - y exact; each of the six products adds |δ| ≤ 2^-53.
N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), Theorem 2.5 (Sterbenz): y/2 ≤ x ≤ 2y implies fl(x - y) = x - y, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf; N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §2.1-2.2: double precision t = 53, u = 2^-53, fl(x op y) = (x op y)(1 + δ), |δ| ≤ u, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- verified Three floating-point failures in summation, cancellation and RANDU
Near the root it has no correct digits.
Near the root the rounding errors (up to about 5e-15) exceed the true value (7.8e-17 at x = 1.005), and the sign flips 89 times.
posts/refs/kahan-summation-horner-noise-and-randus-planes.out (reference run output); N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §5.1 Horner's method: cost 2n flops, Eq. 5.3: |p(x) - q_0| ≤ γ_2n Σ|a_i||x|^i, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- verified Three floating-point failures in summation, cancellation and RANDU
Higham's bound on the rounding error of Horner's rule at x, with his unit roundoff u = EPS / 2 = 2^-53.
Doc comment of horner_bound after the fix.
Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed., Table 2.1 and Lemma 3.1: unit roundoff u = 2^-53 for IEEE double; posts/2026-09-25-kahan-summation-horner-noise-and-randus-planes.viv: EPS = 2^-52
- verified Three floating-point failures in summation, cancellation and RANDU
RANDU was IBM's random number generator in the 1960s: , with draws .
RANDU: V_{j+1} = 65539 V_j mod 2^31, IBM, 1960s.
Wikipedia, 'RANDU' (V_{j+1} = 65539 V_j mod 2^31, 65539 = 2^16 + 3, x_{k+2} = 6x_{k+1} - 9x_k, 15 planes, IBM 1960s), https://en.wikipedia.org/wiki/RANDU
- verified Three floating-point failures in summation, cancellation and RANDU
Its multiplier is , and squaring it gives .
(2^16 + 3)^2 = 2^32 + 6·2^16 + 9.
Wikipedia, 'RANDU' (V_{j+1} = 65539 V_j mod 2^31, 65539 = 2^16 + 3, x_{k+2} = 6x_{k+1} - 9x_k, 15 planes, IBM 1960s), https://en.wikipedia.org/wiki/RANDU
- verified Three floating-point failures in summation, cancellation and RANDU
Wikipedia gives x_{k+2} = 6x_{k+1} - 9x_k (mod 2^31).
Wikipedia, 'RANDU' (V_{j+1} = 65539 V_j mod 2^31, 65539 = 2^16 + 3, x_{k+2} = 6x_{k+1} - 9x_k, 15 planes, IBM 1960s), https://en.wikipedia.org/wiki/RANDU
- verified Three floating-point failures in summation, cancellation and RANDU
So is always a whole number.
Dividing the congruence by 2^31 makes 9u_k - 6u_{k+1} + u_{k+2} an integer; it takes values -5..9, 15 planes, as the reference run confirms.
Wikipedia, 'RANDU' (V_{j+1} = 65539 V_j mod 2^31, 65539 = 2^16 + 3, x_{k+2} = 6x_{k+1} - 9x_k, 15 planes, IBM 1960s), https://en.wikipedia.org/wiki/RANDU; posts/refs/kahan-summation-horner-noise-and-randus-planes.out (reference run output)
- verified Three floating-point failures in summation, cancellation and RANDU
The products here are below , so double-precision arithmetic computes them, and the remainders, exactly.
65539·x < 2^17·2^31 = 2^48 < 2^53, so products and remainders are exact integers in double precision.
N. J. Higham, Accuracy and Stability of Numerical Algorithms, 2nd ed. (SIAM 2002), §2.1-2.2: double precision t = 53, u = 2^-53, fl(x op y) = (x op y)(1 + δ), |δ| ≤ u, http://ftp.demec.ufpr.br/CFD/bibliografia/Higham_2002_Accuracy%20and%20Stability%20of%20Numerical%20Algorithms.pdf
- verified Three floating-point failures in summation, cancellation and RANDU
the largest Horner error is 5.49 × 10−15 (against exact rationals in the reference), 2.6% of Higham's bound
Test name after the fix; asserts worst = 5.4899e-15 and worst_ratio = 0.0264.
posts/refs/kahan-summation-horner-noise-and-randus-planes.out: 'largest |Horner - exact| 5.4899e-15; largest ratio to gamma_14 sum|c_i||x|^i: 0.0264' (exact rationals, u = 2^-53)
- not-checkable Kinetic Monte Carlo against the master equation
A molecule hops between three states, A to B to C and back, at fixed rates.
Describes the post's model.
- not-checkable Kinetic Monte Carlo against the master equation
The exact solution in the reference,
posts/refs/kinetic-monte-carlo-against-the-master-equation.py, is the matrix exponential fromscipy.linalg.expm.Describes the post's reference script.
- verified Kinetic Monte Carlo against the master equation
Many processes are jumps between a few states at known rates: a molecule changing shape, an atom hopping between sites on a surface, a gene switching on and off.
Surface diffusion is a canonical KMC application and gene expression a canonical Gillespie one; conformational switching fits the same Markov-jump model.
Wikipedia, 'Kinetic Monte Carlo' (surface diffusion, vacancy diffusion; rejection-free algorithm Δt = ln(1/u)/Q), https://en.wikipedia.org/wiki/Kinetic_Monte_Carlo; Wikipedia, 'Gillespie algorithm' (Gillespie 1976/1977, J. Phys. Chem. 81, 2340; τ = ln(1/r1)/a0; reaction chosen by relative propensity; statistically exact, no time step), https://en.wikipedia.org/wiki/Gillespie_algorithm
- verified Kinetic Monte Carlo against the master equation
A rate means that in a short time a system in state jumps to with probability , independently of how long it has already been in .
A rate is probability per unit time in a memoryless (Markov) jump process.
Wikipedia, 'Master equation' (dP/dt = AP, rates as probability per unit time, gain-loss form, detailed balance), https://en.wikipedia.org/wiki/Master_equation; Wikipedia, 'Gillespie algorithm' (Gillespie 1976/1977, J. Phys. Chem. 81, 2340; τ = ln(1/r1)/a0; reaction chosen by relative propensity; statistically exact, no time step), https://en.wikipedia.org/wiki/Gillespie_algorithm
- not-checkable Kinetic Monte Carlo against the master equation
Here the states are A, B and C in a chain,
Describes the post's model.
- not-checkable Kinetic Monte Carlo against the master equation
Defines the post's model rates.
- verified Kinetic Monte Carlo against the master equation
and every molecule starts in A. The probability of being in state gains from jumps into and loses from jumps out of it.
Gain-loss form of the master equation.
Wikipedia, 'Master equation' (dP/dt = AP, rates as probability per unit time, gain-loss form, detailed balance), https://en.wikipedia.org/wiki/Master_equation
- verified Kinetic Monte Carlo against the master equation
That balance is the master equation written above, a linear system with a 3 by 3 matrix .
The master equation for a finite state space is the linear system dP/dt = AP.
Wikipedia, 'Master equation' (dP/dt = AP, rates as probability per unit time, gain-loss form, detailed balance), https://en.wikipedia.org/wiki/Master_equation
- verified Kinetic Monte Carlo against the master equation
The fastest decay rate of is 2.82, so a step of makes the method's error at between and .
RK4 at h = 1e-3 against scipy expm: 8.5e-14 at t = 1, inside the stated 3e-14 to 3e-13.
RK4 at h = 1e-3 against scipy.linalg.expm, run in this session: eigenvalues of W are 0, -0.931, -2.819; max error 1.9e-13 near t = 0.4, 8.5e-14 at t = 1; posts/2026-09-25-kinetic-monte-carlo-against-the-master-equation.viv test 'the Runge-Kutta error at t = 1 is between 3e-14 and 3e-13'
- verified Kinetic Monte Carlo against the master equation
The master equation tracks probabilities.
The master equation evolves the probability vector.
Wikipedia, 'Master equation' (dP/dt = AP, rates as probability per unit time, gain-loss form, detailed balance), https://en.wikipedia.org/wiki/Master_equation
- verified Kinetic Monte Carlo against the master equation
Kinetic Monte Carlo (KMC) follows one molecule instead, and gets the probabilities by counting many molecules.
KMC/SSA generates individual trajectories; probabilities come from counting over many.
Wikipedia, 'Kinetic Monte Carlo' (surface diffusion, vacancy diffusion; rejection-free algorithm Δt = ln(1/u)/Q), https://en.wikipedia.org/wiki/Kinetic_Monte_Carlo; Wikipedia, 'Gillespie algorithm' (Gillespie 1976/1977, J. Phys. Chem. 81, 2340; τ = ln(1/r1)/a0; reaction chosen by relative propensity; statistically exact, no time step), https://en.wikipedia.org/wiki/Gillespie_algorithm
- verified Kinetic Monte Carlo against the master equation
The version here is Gillespie's algorithm (1977).
Gillespie, J. Phys. Chem. 81, 2340 (1977) (with a 1976 J. Comput. Phys. precursor).
Wikipedia, 'Gillespie algorithm' (Gillespie 1976/1977, J. Phys. Chem. 81, 2340; τ = ln(1/r1)/a0; reaction chosen by relative propensity; statistically exact, no time step), https://en.wikipedia.org/wiki/Gillespie_algorithm
- verified Kinetic Monte Carlo against the master equation
In state the total rate of leaving is .
Total escape rate is the sum of the outgoing rates (a0 or Q_k).
Wikipedia, 'Gillespie algorithm' (Gillespie 1976/1977, J. Phys. Chem. 81, 2340; τ = ln(1/r1)/a0; reaction chosen by relative propensity; statistically exact, no time step), https://en.wikipedia.org/wiki/Gillespie_algorithm; Wikipedia, 'Kinetic Monte Carlo' (surface diffusion, vacancy diffusion; rejection-free algorithm Δt = ln(1/u)/Q), https://en.wikipedia.org/wiki/Kinetic_Monte_Carlo
- verified Kinetic Monte Carlo against the master equation
Since each jump happens at a constant rate, the waiting time until the next one is exponential with mean , drawn as from a uniform random number .
τ = ln(1/r1)/a0, i.e. -ln(u1)/a, exponential with mean 1/a.
Wikipedia, 'Gillespie algorithm' (Gillespie 1976/1977, J. Phys. Chem. 81, 2340; τ = ln(1/r1)/a0; reaction chosen by relative propensity; statistically exact, no time step), https://en.wikipedia.org/wiki/Gillespie_algorithm
- verified Kinetic Monte Carlo against the master equation
Which jump it is follows from a second draw: jump to with probability .
Next event chosen with probability proportional to its rate.
Wikipedia, 'Gillespie algorithm' (Gillespie 1976/1977, J. Phys. Chem. 81, 2340; τ = ln(1/r1)/a0; reaction chosen by relative propensity; statistically exact, no time step), https://en.wikipedia.org/wiki/Gillespie_algorithm
- verified Kinetic Monte Carlo against the master equation
No time step is chosen, and none of the jumps is approximated.
The SSA is statistically exact with no predetermined time step.
Wikipedia, 'Gillespie algorithm' (Gillespie 1976/1977, J. Phys. Chem. 81, 2340; τ = ln(1/r1)/a0; reaction chosen by relative propensity; statistically exact, no time step), https://en.wikipedia.org/wiki/Gillespie_algorithm
- verified Kinetic Monte Carlo against the master equation
The measured first-passage mean, 1.721, is 2.05 standard errors below 1.75; a normal variable lands that far out about one time in 25.
Numbers check out, including the tail probability.
Program cell output (www/public/programs/posts/...kinetic-monte-carlo...cells.json): first_mean 1.72129, first_err 0.0140162; (1.75 - 1.72129)/0.0140162 = 2.05; two-sided normal tail P(|Z| > 2.05) = erfc(2.05/√2) = 0.041 ≈ 1/25; posts/refs/kinetic-monte-carlo-against-the-master-equation.out (eigenvalues of W, p(5.0), stationary p, first-passage 1.75)
- verified Kinetic Monte Carlo against the master equation
By the slowest part of the approach, which decays as (the smaller nonzero eigenvalue of ), has not died out, so is still 0.011 short of .
Reference: eigenvalues -2.819, -0.931, 0; p_C(5) = 0.7511 vs 16/21 = 0.7619, a gap of 0.0108.
posts/refs/kinetic-monte-carlo-against-the-master-equation.out (eigenvalues of W, p(5.0), stationary p, first-passage 1.75)
- verified Kinetic Monte Carlo against the master equation
the Runge-Kutta error at t = 1 is between 3 × 10−14 and 3 × 10−13
New test added with the fix of a8d0be44d32f.
RK4 at h = 1e-3 against scipy.linalg.expm (this session): error 8.5e-14 at t = 1; posts/refs/kinetic-monte-carlo-against-the-master-equation.out (the expm values the test compares with)
- verified Lanczos finds the largest eigenvalue three times
Orthogonalizing each new vector against all the old ones stops it.
Full reorthogonalization restores orthogonality and removes the spurious copies.
Wikipedia, 'Lanczos algorithm' (T = V*AV tridiagonal, three-term recurrence, extreme eigenvalues of large sparse Hermitian matrices via matrix-vector products, loss of orthogonality in floating point, full reorthogonalization remedy, Kaniel-Paige convergence), https://en.wikipedia.org/wiki/Lanczos_algorithm
- verified Lanczos finds the largest eigenvalue three times
Lanczos is for the extreme eigenvalues of a symmetric matrix too big to diagonalize, when all you can do with it is multiply a vector by it.
Lanczos targets extreme eigenvalues of large symmetric/Hermitian matrices using only matrix-vector products.
Wikipedia, 'Lanczos algorithm' (T = V*AV tridiagonal, three-term recurrence, extreme eigenvalues of large sparse Hermitian matrices via matrix-vector products, loss of orthogonality in floating point, full reorthogonalization remedy, Kaniel-Paige convergence), https://en.wikipedia.org/wiki/Lanczos_algorithm
- verified Lanczos finds the largest eigenvalue three times
From one starting vector it builds an orthonormal basis of the Krylov space, the span of .
The Lanczos vectors are an orthonormal basis of the Krylov space (in exact arithmetic).
Wikipedia, 'Lanczos algorithm' (T = V*AV tridiagonal, three-term recurrence, extreme eigenvalues of large sparse Hermitian matrices via matrix-vector products, loss of orthogonality in floating point, full reorthogonalization remedy, Kaniel-Paige convergence), https://en.wikipedia.org/wiki/Lanczos_algorithm
- verified Lanczos finds the largest eigenvalue three times
In that basis is tridiagonal, and each new vector needs only the two before it:
T = V*AV is tridiagonal and the recurrence is three-term.
Wikipedia, 'Lanczos algorithm' (T = V*AV tridiagonal, three-term recurrence, extreme eigenvalues of large sparse Hermitian matrices via matrix-vector products, loss of orthogonality in floating point, full reorthogonalization remedy, Kaniel-Paige convergence), https://en.wikipedia.org/wiki/Lanczos_algorithm
- verified Lanczos finds the largest eigenvalue three times
Standard Lanczos three-term recurrence.
Wikipedia, 'Lanczos algorithm' (T = V*AV tridiagonal, three-term recurrence, extreme eigenvalues of large sparse Hermitian matrices via matrix-vector products, loss of orthogonality in floating point, full reorthogonalization remedy, Kaniel-Paige convergence), https://en.wikipedia.org/wiki/Lanczos_algorithm
- verified Lanczos finds the largest eigenvalue three times
The eigenvalues of the small tridiagonal matrix (the on its diagonal, the beside it) are the Ritz values, and the largest and smallest of them converge to the largest and smallest eigenvalues of after far fewer steps than has rows.
Ritz values are eigenvalues of T; Kaniel-Paige theory gives fast convergence of the extremes.
Wikipedia, 'Lanczos algorithm' (T = V*AV tridiagonal, three-term recurrence, extreme eigenvalues of large sparse Hermitian matrices via matrix-vector products, loss of orthogonality in floating point, full reorthogonalization remedy, Kaniel-Paige convergence), https://en.wikipedia.org/wiki/Lanczos_algorithm
- verified Lanczos finds the largest eigenvalue three times
The three-term formula is where the trouble is.
Loss of orthogonality stems from the short recurrence in floating point.
Wikipedia, 'Lanczos algorithm' (T = V*AV tridiagonal, three-term recurrence, extreme eigenvalues of large sparse Hermitian matrices via matrix-vector products, loss of orthogonality in floating point, full reorthogonalization remedy, Kaniel-Paige convergence), https://en.wikipedia.org/wiki/Lanczos_algorithm
- verified Lanczos finds the largest eigenvalue three times
It makes orthogonal to and by construction, and to every earlier vector only because, in exact arithmetic, those overlaps are zero anyway.
Global orthogonality in the three-term recurrence holds only in exact arithmetic.
Wikipedia, 'Lanczos algorithm' (T = V*AV tridiagonal, three-term recurrence, extreme eigenvalues of large sparse Hermitian matrices via matrix-vector products, loss of orthogonality in floating point, full reorthogonalization remedy, Kaniel-Paige convergence), https://en.wikipedia.org/wiki/Lanczos_algorithm
- verified Lanczos finds the largest eigenvalue three times
In floating point they are not zero, and nothing removes them.
In floating point orthogonality is lost and the plain recurrence does nothing to restore it.
Wikipedia, 'Lanczos algorithm' (T = V*AV tridiagonal, three-term recurrence, extreme eigenvalues of large sparse Hermitian matrices via matrix-vector products, loss of orthogonality in floating point, full reorthogonalization remedy, Kaniel-Paige convergence), https://en.wikipedia.org/wiki/Lanczos_algorithm
- not-checkable Lanczos finds the largest eigenvalue three times
The numpy twin of this program, with the same matrix and starting vector, is
posts/refs/lanczos-loses-orthogonality.py; its output is beside it.Describes the post's reference script.
- not-checkable Lanczos finds the largest eigenvalue three times
The plain run is the three-term formula above.
Describes the program.
- plausible Lanczos finds the largest eigenvalue three times
That costs extra dot products at step , so over steps where plain Lanczos costs beyond the products with , and it needs every vector kept in memory.
Full reorthogonalization adds about j dot products and vector updates at step j, O(Nk^2) total, and needs all k vectors stored (cost figures not accessed; from general knowledge; Wikipedia only says it comes at computational cost).
Wikipedia, 'Lanczos algorithm' (T = V*AV tridiagonal, three-term recurrence, extreme eigenvalues of large sparse Hermitian matrices via matrix-vector products, loss of orthogonality in floating point, full reorthogonalization remedy, Kaniel-Paige convergence), https://en.wikipedia.org/wiki/Lanczos_algorithm
- plausible Lanczos finds the largest eigenvalue three times
In both runs it first falls, geometrically: stretches the direction the most, so the Krylov space captures it early, and once it is in the space the new vectors, orthogonal to the space, have nothing left along it.
Lanczos Ritz values converge fastest at the extreme, well-separated end of the spectrum (SLEPc STR-5 sec. 2.2), so the top eigenvector enters the Krylov space early; the falling component itself is this run's output.
Hernandez, Roman, Tomas, Vidal, 'Lanczos Methods in SLEPc', SLEPc Technical Report STR-5, sec. 2.2-2.3, https://slepc.upv.es/documentation/reports/str5.pdf; posts/refs/lanczos-loses-orthogonality.out
- not-checkable Lanczos finds the largest eigenvalue three times
From there the two runs split.
Transition describing this program's two runs.
- not-checkable Lanczos finds the largest eigenvalue three times
With reorthogonalization the component keeps falling to rounding, below , and stays.
Program result; tested (every step after the return below 1e-16).
- not-checkable Lanczos finds the largest eigenvalue three times
The component grows back to order one by step 24.
Describes this run; the reference output has the plain run's component back up at step 24 (0.764).
- verified Lanczos finds the largest eigenvalue three times
The copies are called ghosts.
Redundant copies of converged Ritz values in finite-precision Lanczos are called ghosts in the literature; SLEPc STR-5 sec. 2.2 describes the multiple copies.
Barlow, 'Reorthogonalization for the Golub-Kahan-Lanczos bidiagonal reduction' (redundant copies of Ritz values called 'ghosts'), https://www.cse.psu.edu/~b58/lanczos_svd_orthI.pdf; Hernandez, Roman, Tomas, Vidal, 'Lanczos Methods in SLEPc', SLEPc Technical Report STR-5, sec. 2.2-2.3, https://slepc.upv.es/documentation/reports/str5.pdf
- not-checkable Lanczos finds the largest eigenvalue three times
Full reorthogonalization is the fix used here.
Describes this program's choice.
- verified Lanczos finds the largest eigenvalue three times
It is also the most expensive one; selective reorthogonalization (against converged Ritz vectors only) costs less, and restarted Lanczos, as in ARPACK, keeps full reorthogonalization affordable by keeping the basis short.
Replaces disputed 342ac965a934. Restarting keeps the basis short so full reorthogonalization stays cheap; it does not replace it.
ARPACK-NG SRC/dsaitr.f (read): each step computes r_j = OP v_j - V_j w_j by classical Gram-Schmidt against all of V_j, with a DGKS re-orthogonalization step, https://github.com/opencollab/arpack-ng/blob/master/SRC/dsaitr.f; Parlett and Scott, 'The Lanczos algorithm with selective orthogonalization', Math. Comp. 33 (1979) 217-238, doi:10.1090/S0025-5718-1979-0514820-3 (abstract: stifles duplicate eigenvectors without significantly increasing the cost of a step)
- verified Landau damping from the root of the dispersion relation
A Langmuir wave in a collisionless plasma still decays: electrons moving near its phase velocity take energy from it.
Chen ties the damping to resonant particles with velocity near the phase velocity, with net energy going from the wave to the electrons.
F. F. Chen, Introduction to Plasma Physics and Controlled Fusion, 3rd ed. (Springer, 2016), secs. 7.4-7.5, https://fenix.tecnico.ulisboa.pt/downloadFile/1970943312531201/2016_Book_IntroductionToPlasmaPhysicsAnd.pdf; Wikipedia, Landau damping (pointer; cites Landau 1946), https://en.wikipedia.org/wiki/Landau_damping
- verified Landau damping from the root of the dispersion relation
The usual small- damping formula is 1.3% off there and 59% off at .
Formula gives 0.1514 vs exact 0.15336 at 0.5 (-1.3%) and 0.02002 vs 0.012620 at 0.3 (+59%), confirmed by an independent scipy root solve.
arXiv:1911.08294, 'On the theory of the nonlinear Landau damping' (linear rate gamma = -sqrt(pi/8) k^-3 exp(-1/(2k^2) - 3/2) in units omega_pe = lambda_D = 1), https://arxiv.org/abs/1911.08294; Independent recomputation in this check: scipy.special.wofz + Newton on 1 + (1 + zeta Z)/k^2, roots at k = 0.2, 0.3, 0.5 = 1.06398-5.511e-5i, 1.15985-0.012620i, 1.415662-0.153359i
- verified Landau damping from the root of the dispersion relation
A Langmuir wave is an oscillation of the electrons in a plasma against the ions, at about the plasma frequency .
Chen sec. 4.3: electrons oscillate about a fixed ion background at the plasma frequency, the ions too massive to respond; sec. 4.4 adds the thermal correction.
F. F. Chen, Introduction to Plasma Physics and Controlled Fusion, 3rd ed. (Springer, 2016), secs. 4.3-4.4, https://fenix.tecnico.ulisboa.pt/downloadFile/1970943312531201/2016_Book_IntroductionToPlasmaPhysicsAnd.pdf
- verified Landau damping from the root of the dispersion relation
In a plasma with no collisions at all it still decays.
Chen: 'there is a collisionless damping of plasma waves; this is called Landau damping.'
F. F. Chen, Introduction to Plasma Physics and Controlled Fusion, 3rd ed. (Springer, 2016), secs. 7.4-7.5, https://fenix.tecnico.ulisboa.pt/downloadFile/1970943312531201/2016_Book_IntroductionToPlasmaPhysicsAnd.pdf; R. Fitzpatrick, Plasma Physics lecture notes, 'Landau Damping', eqs. (7.29) and (7.32), https://farside.ph.utexas.edu/teaching/plasma/lectures1/node90.html
- verified Landau damping from the root of the dispersion relation
Electrons moving a little slower than the wave are pushed forward by it and take energy; electrons moving a little faster are held back and give energy.
Wikipedia: particles slightly slower than v_ph are accelerated by the wave, slightly faster ones are decelerated and lose energy to it; Chen's sec. 7.5 gives the same picture.
F. F. Chen, Introduction to Plasma Physics and Controlled Fusion, 3rd ed. (Springer, 2016), sec. 7.5, https://fenix.tecnico.ulisboa.pt/downloadFile/1970943312531201/2016_Book_IntroductionToPlasmaPhysicsAnd.pdf; Wikipedia, Landau damping (pointer; cites Landau 1946), https://en.wikipedia.org/wiki/Landau_damping; R. Fitzpatrick, Plasma Physics, 'Physics of Landau Damping', https://farside.ph.utexas.edu/teaching/plasma/Plasma/node110.html
- verified Landau damping from the root of the dispersion relation
In a Maxwellian distribution the slower ones outnumber the faster ones at any speed above the mean, so the wave loses.
Chen: 'A Maxwellian distribution, however, has more slow electrons than fast ones ... the wave is damped'; the slope df/dv < 0 above the mean makes this hold at any phase velocity above it.
F. F. Chen, Introduction to Plasma Physics and Controlled Fusion, 3rd ed. (Springer, 2016), sec. 7.5, https://fenix.tecnico.ulisboa.pt/downloadFile/1970943312531201/2016_Book_IntroductionToPlasmaPhysicsAnd.pdf; R. Fitzpatrick, Plasma Physics, 'Physics of Landau Damping', https://farside.ph.utexas.edu/teaching/plasma/Plasma/node110.html
- verified Landau damping from the root of the dispersion relation
This is Landau damping (Landau, 1946).
Landau's paper is 1946 (J. Phys. USSR 10, 25; Russian version JETP 16, 574).
R. Stucchi and P. Lauber, Landau Damping for Non-Maxwellian Distribution Functions, arXiv:2411.06769 (J. Plasma Phys. 2025), sec. 1 and sec. 3.3, https://arxiv.org/abs/2411.06769 (ref. L. Landau, On the vibrations of the electronic plasma, J. Phys. USSR 10, 25 (1946)); Wikipedia, Landau damping (pointer; cites Landau 1946), https://en.wikipedia.org/wiki/Landau_damping
- verified Landau damping from the root of the dispersion relation
The rate comes out of the kinetic dispersion relation.
Landau's 1946 rate follows from the linearized Vlasov (kinetic) treatment; the damped root of the kinetic dispersion relation gives it.
Wikipedia, 'Landau damping' (Landau 1946; damping rate from the Vlasov treatment), https://en.wikipedia.org/wiki/Landau_damping; Wikipedia, 'Faddeeva function' / plasma dispersion function Z(z) = i sqrt(pi) w(z) (Fried and Conte 1961), https://en.wikipedia.org/wiki/Plasma_dispersion_function
- plausible Landau damping from the root of the dispersion relation
For a Maxwellian with thermal speed and Debye length , a wave exists when
Standard Maxwellian Langmuir dielectric with v_th = sqrt(T/m) and lambda_D = v_th/omega_pe; textbook statement (e.g. Stix, Waves in Plasmas ch. 8) not accessed, but an independent solve of this form reproduces the post's root.
Wikipedia, 'Faddeeva function' / plasma dispersion function Z(z) = i sqrt(pi) w(z) (Fried and Conte 1961), https://en.wikipedia.org/wiki/Plasma_dispersion_function; Independent recomputation in this check: scipy.special.wofz + Newton on 1 + (1 + zeta Z)/k^2, roots at k = 0.2, 0.3, 0.5 = 1.06398-5.511e-5i, 1.15985-0.012620i, 1.415662-0.153359i
- plausible Landau damping from the root of the dispersion relation
Correct form of the electron-wave dielectric function with zeta = omega/(sqrt2 k v_th); textbook page not accessed, but an independent scipy solve reproduces 1.415662 - 0.153359i at k lambda_D = 0.5.
Wikipedia, 'Faddeeva function' / plasma dispersion function Z(z) = i sqrt(pi) w(z) (Fried and Conte 1961), https://en.wikipedia.org/wiki/Plasma_dispersion_function; Independent recomputation in this check: scipy.special.wofz + Newton on 1 + (1 + zeta Z)/k^2, roots at k = 0.2, 0.3, 0.5 = 1.06398-5.511e-5i, 1.15985-0.012620i, 1.415662-0.153359i
- verified Landau damping from the root of the dispersion relation
where is the plasma dispersion function.
Chen defines the plasma dispersion function Z and notes Fried and Conte tabulated it for the Maxwellian case.
F. F. Chen, Introduction to Plasma Physics and Controlled Fusion, 3rd ed. (Springer, 2016), sec. 7.9.1, eq. (7.118); sec. 7.4 (Fried and Conte tables), https://fenix.tecnico.ulisboa.pt/downloadFile/1970943312531201/2016_Book_IntroductionToPlasmaPhysicsAnd.pdf
- verified Landau damping from the root of the dispersion relation
Its roots are complex, , and is the damping rate.
The Stanford notes write omega = omega_p - i gamma so that e^{-i omega t} = e^{-i omega_p t - gamma t}; gamma is the decay rate.
Stanford Physics 312 (2007), Lecture 12, Plasma waves. Landau damping, pp. 13-14, http://sun.stanford.edu/~sasha/PHYS312/2007/L12/phys312_2007_l12.pdf; F. F. Chen, Introduction to Plasma Physics and Controlled Fusion, 3rd ed. (Springer, 2016), sec. 7.4, https://fenix.tecnico.ulisboa.pt/downloadFile/1970943312531201/2016_Book_IntroductionToPlasmaPhysicsAnd.pdf
- not-checkable Landau damping from the root of the dispersion relation
comes from
lib/zfunc, which computes it by Weideman's rational expansion and is tested there againstscipy.special.wofz.About this repository's lib/zfunc and its tests; checkable only in the repository.
- not-checkable Landau damping from the root of the dispersion relation
Units: , so means .
Defines this program's units (consistent, since lambda_D = v_th/omega_pe).
- verified Landau damping from the root of the dispersion relation
A good starting guess is the Bohm-Gross frequency , the fluid-theory answer, on the real axis.
Chen's kinetic eq. (7.64), omega^2 = omega_p^2 + 3k^2 KT/m, equals the fluid result (4.30); in units omega_pe = lambda_D = 1 it is sqrt(1 + 3k^2), as in Fitzpatrick's eq. (7.29).
F. F. Chen, Introduction to Plasma Physics and Controlled Fusion, 3rd ed. (Springer, 2016), sec. 4.4 eq. (4.30) and sec. 7.4 eq. (7.64), https://fenix.tecnico.ulisboa.pt/downloadFile/1970943312531201/2016_Book_IntroductionToPlasmaPhysicsAnd.pdf; R. Fitzpatrick, Plasma Physics lecture notes, 'Landau Damping', eqs. (7.29) and (7.32), https://farside.ph.utexas.edu/teaching/plasma/lectures1/node90.html
- not-checkable Landau damping from the root of the dispersion relation
From there Newton's method moves the guess down into the lower half plane.
Describes this program's Newton iteration; the damped root does lie in the lower half plane (Im omega < 0).
- verified Landau damping from the root of the dispersion relation
The dispersion relation has more than one root.
Stucchi and Lauber: the dispersion relation 'generally admits more than one root', and for a Maxwellian it 'admits infinite roots' (sec. 3.3).
R. Stucchi and P. Lauber, Landau Damping for Non-Maxwellian Distribution Functions, arXiv:2411.06769 (J. Plasma Phys. 2025), sec. 1 and sec. 3.3, https://arxiv.org/abs/2411.06769
- verified Landau damping from the root of the dispersion relation
The one found above is the highest, the least damped, and it is the one a wave settles into.
Stucchi and Lauber, sec. 1: the root with the largest imaginary part 'dominates the long-time behavior'; that the root found is the highest is shown by the run's own root map.
R. Stucchi and P. Lauber, Landau Damping for Non-Maxwellian Distribution Functions, arXiv:2411.06769 (J. Plasma Phys. 2025), sec. 1 and sec. 3.3, https://arxiv.org/abs/2411.06769
- not-checkable Landau damping from the root of the dispersion relation
Re is across and Im up.
Describes the figure's axes.
- verified Landau damping from the root of the dispersion relation
The usual result is
The small-k Langmuir damping rate sqrt(pi/8) omega_pe (k lambda_D)^-3 exp(-1/(2k^2 lambda_D^2) - 3/2) is the standard result.
arXiv:1911.08294, 'On the theory of the nonlinear Landau damping' (linear rate gamma = -sqrt(pi/8) k^-3 exp(-1/(2k^2) - 3/2) in units omega_pe = lambda_D = 1), https://arxiv.org/abs/1911.08294
- verified Landau damping from the root of the dispersion relation
Chen's eq. (7.70), with v_th^2 = 2KT/m and 0.22 = e^{-3/2}, is this formula; the e^{-3/2} comes from keeping the Bohm-Gross shift in the exponent. Fitzpatrick's eq. (7.32) gives the same rate without the e^{-3/2} factor.
F. F. Chen, Introduction to Plasma Physics and Controlled Fusion, 3rd ed. (Springer, 2016), sec. 7.4, eqs. (7.69)-(7.70), https://fenix.tecnico.ulisboa.pt/downloadFile/1970943312531201/2016_Book_IntroductionToPlasmaPhysicsAnd.pdf; R. Fitzpatrick, Plasma Physics lecture notes, 'Landau Damping', eqs. (7.29) and (7.32), https://farside.ph.utexas.edu/teaching/plasma/lectures1/node90.html
- verified Landau damping from the root of the dispersion relation
At the formula gives against the exact , 1.3% low.
Formula value 0.15139 vs exact 0.153359: 1.29% low, confirmed independently.
arXiv:1911.08294, 'On the theory of the nonlinear Landau damping' (linear rate gamma = -sqrt(pi/8) k^-3 exp(-1/(2k^2) - 3/2) in units omega_pe = lambda_D = 1), https://arxiv.org/abs/1911.08294; Independent recomputation in this check: scipy.special.wofz + Newton on 1 + (1 + zeta Z)/k^2, roots at k = 0.2, 0.3, 0.5 = 1.06398-5.511e-5i, 1.15985-0.012620i, 1.415662-0.153359i
- verified Landau damping from the root of the dispersion relation
That agreement is an accident of where the error changes sign: at the formula gives against , 59% too high, and at it is still 18% high.
Independent check: 0.02002 vs 0.012620 at 0.3 (+58.6%) and 6.51e-5 vs 5.51e-5 at 0.2 (+18.2%); the error is positive at 0.2 and 0.3 and negative at 0.5, so it changes sign in between.
arXiv:1911.08294, 'On the theory of the nonlinear Landau damping' (linear rate gamma = -sqrt(pi/8) k^-3 exp(-1/(2k^2) - 3/2) in units omega_pe = lambda_D = 1), https://arxiv.org/abs/1911.08294; Independent recomputation in this check: scipy.special.wofz + Newton on 1 + (1 + zeta Z)/k^2, roots at k = 0.2, 0.3, 0.5 = 1.06398-5.511e-5i, 1.15985-0.012620i, 1.415662-0.153359i
- verified Landau damping from the root of the dispersion relation
The real part is above Bohm-Gross by 0.5% at and by 7% at .
Replaces disputed c34b6e02075f.
posts/2026-09-25-landau-damping-from-the-dispersion-relation.viv test: 1.0639843406877026 / 1.0583005244258363 - 1 = 0.537% at k lambda_D = 0.2, 1.4156618886045364 / 1.3228756555322954 - 1 = 7.01% at 0.5
- verified Landau damping from the root of the dispersion relation
the small-k formula gives 0.1514 at k = 0.5 and 0.0200 at k = 0.3
The small-k Landau formula as the program writes it; the program's values match Python's to 1e-12.
Recomputed in Python 3 in this session: sqrt(pi/8)/k^3 exp(-1/(2k^2) - 3/2) = 0.151387230212514 at k = 0.5 and 0.020020611312067026 at k = 0.3
- verified Make Euler stable on a stiff equation
A problem is stiff when it contains a rate much faster than the one you want to follow.
Matches the standard characterization: a fast decaying mode forces explicit methods to tiny steps while the solution varies slowly.
Wikipedia, 'Stiff equation' (fast vs slow time scales; backward Euler u_{n+1} = u_n + h f(u_{n+1}); A-stability, |1 - h lambda|^-1 <= 1), https://en.wikipedia.org/wiki/Stiff_equation
- verified Make Euler stable on a stiff equation
Backward Euler solves for .
Backward Euler is u_{n+1} = u_n + h f(u_{n+1}), solved for u_{n+1}.
Wikipedia, 'Stiff equation' (fast vs slow time scales; backward Euler u_{n+1} = u_n + h f(u_{n+1}); A-stability, |1 - h lambda|^-1 <= 1), https://en.wikipedia.org/wiki/Stiff_equation
- not-checkable Make Euler stable on a stiff equation
The second function steps a system whose matrix has eigenvalues and .
Describes this program's matrix; the code's comment gives eigenvalues -1 along (1,1) and -1000 along (1,-1).
- not-checkable Make Euler stable on a stiff equation
The expected numbers come from
posts/refs/make-euler-stable-on-a-stiff-equation.py, which runs backward Euler in numpy.Describes this post's reference script.
- verified Make Gram-Schmidt orthogonal to rounding
Classical Gram-Schmidt turns them into ten "orthonormal" vectors of which two are at 60 degrees: their dot product is 0.5.
An independent numpy CGS on these vectors gives a dot product of 0.5 between two output vectors, and arccos(0.5) = 60 degrees.
Independent recomputation in this check: numpy classical Gram-Schmidt on the 10 Lauchli rows with eps = 1e-8 gives max |Q Q^T - I| = 0.5; kappa = sqrt(10 + eps^2)/eps = 3.16e8; A. Bjorck, 'Gram-Schmidt Orthogonalization: 100 Years and More' (IWMS 2010 slides): MGS loss of orthogonality ~ u kappa(A); Krylov subspace methods; 'twice is enough' proved by Giraud et al. 2005, https://www.cis.upenn.edu/~cis6100/Gram-Schmidt-Bjorck.pdf
- verified Make Gram-Schmidt orthogonal to rounding
Gram-Schmidt builds an orthonormal set one vector at a time: take the next vector, subtract its components along the vectors already made, normalize.
Standard description of the Gram-Schmidt process.
Wikipedia, 'Gram-Schmidt process', sec. Numerical stability (CGS vs MGS; Householder more stable; Gram-Schmidt used in Arnoldi iteration), https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process
- verified Make Gram-Schmidt orthogonal to rounding
It is how Krylov methods (Arnoldi, Lanczos) and deflation build their bases, and it fails when the input is close to dependent.
Gram-Schmidt builds the Arnoldi/Lanczos bases (Wikipedia; Bjorck, Krylov section) and loses orthogonality when the input is ill conditioned.
Wikipedia, 'Gram-Schmidt process', sec. Numerical stability (CGS vs MGS; Householder more stable; Gram-Schmidt used in Arnoldi iteration), https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process; A. Bjorck, 'Gram-Schmidt Orthogonalization: 100 Years and More' (IWMS 2010 slides): MGS loss of orthogonality ~ u kappa(A); Krylov subspace methods; 'twice is enough' proved by Giraud et al. 2005, https://www.cis.upenn.edu/~cis6100/Gram-Schmidt-Bjorck.pdf
- verified Make Gram-Schmidt orthogonal to rounding
These inputs, the Läuchli vectors, have condition number : after the subtraction what is left of each vector is of size , and the rounding in the subtracted parts, half a unit in the last place of numbers near 1, is then a relative error of or more.
For rows e_0 + eps e_{k+1}, n = 10, eps = 1e-8 the singular values are sqrt(10 + eps^2) and eps, so kappa = 3.16e8; rounding of size u on an O(1) subtraction leaving O(1e-8) gives relative error ~1e-8.
Independent recomputation in this check: numpy classical Gram-Schmidt on the 10 Lauchli rows with eps = 1e-8 gives max |Q Q^T - I| = 0.5; kappa = sqrt(10 + eps^2)/eps = 3.16e8; A. Bjorck, 'Gram-Schmidt Orthogonalization: 100 Years and More' (IWMS 2010 slides): MGS loss of orthogonality ~ u kappa(A); Krylov subspace methods; 'twice is enough' proved by Giraud et al. 2005, https://www.cis.upenn.edu/~cis6100/Gram-Schmidt-Bjorck.pdf
- verified Make Gram-Schmidt orthogonal to rounding
The classical version computes every dot product with the original vector, so the errors of the early projections are never corrected.
CGS projects the original vector against all previous q; MGS applies projections to the updated intermediate vector, which reduces error.
Wikipedia, 'Gram-Schmidt process', sec. Numerical stability (CGS vs MGS; Householder more stable; Gram-Schmidt used in Arnoldi iteration), https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process
- verified Make Gram-Schmidt orthogonal to rounding
Running the orthogonalization a second time on the result (the rule known as "twice is enough") gets there, and so does a QR factorization by Householder reflections.
Two passes of CGS give orthogonality near unit roundoff for numerically full-rank input (Giraud et al. 2005, 'twice is enough'); Householder QR is more stable than Gram-Schmidt.
Giraud, Langou, Rozloznik, Van den Eshof, 'Rounding error analysis of the classical Gram-Schmidt orthogonalization process', Numer. Math. 101, 87-100 (2005), https://link.springer.com/article/10.1007/s00211-005-0615-4; A. Bjorck, 'Gram-Schmidt Orthogonalization: 100 Years and More' (IWMS 2010 slides): MGS loss of orthogonality ~ u kappa(A); Krylov subspace methods; 'twice is enough' proved by Giraud et al. 2005, https://www.cis.upenn.edu/~cis6100/Gram-Schmidt-Bjorck.pdf; Wikipedia, 'Gram-Schmidt process', sec. Numerical stability (CGS vs MGS; Householder more stable; Gram-Schmidt used in Arnoldi iteration), https://en.wikipedia.org/wiki/Gram%E2%80%93Schmidt_process
- not-checkable Make Gram-Schmidt orthogonal to rounding
The expected vectors come from
posts/refs/make-gram-schmidt-orthogonal-to-rounding.py, which runs Gram-Schmidt at 60 digits in mpmath, where rounding does not matter; it also measures the three double-precision versions.Describes this post's reference script.
- not-checkable Make Numerov find the decaying solution
Rewrite
decayingso that it follows to Numerov's own accuracy, within , on both intervals.States the exercise's target: the last test's tolerance, 2.7e-5.
- verified Make Numerov find the decaying solution
Numerov's method is the standard way to integrate , which is the form of the radial Schrödinger equation.
Numerov's method integrates y'' = -g(x) y and is the standard tool for the radial Schrodinger equation for u(r).
Wikipedia, 'Numerov's method' (recurrence for y'' = -g y; local error O(h^6), order 4; radial Schrodinger equation), https://en.wikipedia.org/wiki/Numerov%27s_method
- verified Make Numerov find the decaying solution
For on a grid of spacing it is the three-term recurrence
Lead-in; Numerov is a three-point (three-term) recurrence.
Wikipedia, 'Numerov's method' (recurrence for y'' = -g y; local error O(h^6), order 4; radial Schrodinger equation), https://en.wikipedia.org/wiki/Numerov%27s_method
- verified Make Numerov find the decaying solution
Setting g = -k^2 in Wikipedia's (1 + h^2 g/12) y_{n+1} = 2(1 - 5h^2 g/12) y_n - (1 + h^2 g/12) y_{n-1} gives exactly this recurrence.
Wikipedia, 'Numerov's method' (recurrence for y'' = -g y; local error O(h^6), order 4; radial Schrodinger equation), https://en.wikipedia.org/wiki/Numerov%27s_method
- verified Make Numerov find the decaying solution
accurate to fourth order in .
Local error O(h^6), global order 4.
Wikipedia, 'Numerov's method' (recurrence for y'' = -g y; local error O(h^6), order 4; radial Schrodinger equation), https://en.wikipedia.org/wiki/Numerov%27s_method
- verified Make Numerov find the decaying solution
The equation has two solutions, and , and the recurrence carries both.
y'' = y has the independent solutions e^{-x} and e^{x}; a second-order linear recurrence has two independent solutions, which approximate both.
Wikipedia, 'Numerov's method' (recurrence for y'' = -g y; local error O(h^6), order 4; radial Schrodinger equation), https://en.wikipedia.org/wiki/Numerov%27s_method
- plausible Make Numerov find the decaying solution
The two starting values are never exactly on the decaying one (they differ from the recurrence's own decaying solution by its truncation error), so a little of is always mixed in.
Not accessed; from general knowledge: the starting values carry truncation error, so the growing solution is excited at that level.
Wikipedia, 'Numerov's method' (recurrence for y'' = -g y; local error O(h^6), order 4; radial Schrodinger equation), https://en.wikipedia.org/wiki/Numerov%27s_method
- verified Make Numerov find the decaying solution
Going outward, that part grows by relative to the part you want.
The ratio of the two solutions e^{x}/e^{-x} = e^{2x}.
Wikipedia, 'Numerov's method' (recurrence for y'' = -g y; local error O(h^6), order 4; radial Schrodinger equation), https://en.wikipedia.org/wiki/Numerov%27s_method
- plausible Make Numerov find the decaying solution
In the region where a bound state's wavefunction decays, every outward integration has this problem.
Not accessed; from general knowledge (standard advice to integrate inward in the classically forbidden region, e.g. Koonin, Computational Physics ch. 3).
Wikipedia, 'Numerov's method' (recurrence for y'' = -g y; local error O(h^6), order 4; radial Schrodinger equation), https://en.wikipedia.org/wiki/Numerov%27s_method
- not-checkable Make Numerov find the decaying solution
The tests allow about 1.5 times those.
Describes this program's tests; the ratios 1.3e-5/8.87e-6, 8e-7/5.58e-7, 2.7e-5/1.84e-5 are 1.43 to 1.47.
- verified Make power iteration converge on a tied pair
Power iteration multiplies a vector by again and again and finds the eigenvalue of largest magnitude.
Power iteration finds the eigenvalue greatest in absolute value, when it is strictly dominant.
Wikipedia, 'Power iteration' (finds the eigenvalue greatest in absolute value; needs a strictly dominant eigenvalue; Rayleigh quotient gives the eigenvalue), https://en.wikipedia.org/wiki/Power_iteration
- verified Make power iteration converge on a tied pair
With those are 3 and , so the part wins by a factor of 3 per step; with they are 1 and , and wins.
2 + 1 = 3, -2 + 1 = -1, 2 - 1 = 1, -2 - 1 = -3; the dominant component grows by the eigenvalue ratio (3) per step.
Wikipedia, 'Power iteration' (finds the eigenvalue greatest in absolute value; needs a strictly dominant eigenvalue; Rayleigh quotient gives the eigenvalue), https://en.wikipedia.org/wiki/Power_iteration
- verified Make power iteration converge on a tied pair
The Rayleigh quotient of the original then gives the eigenvalue itself.
The Rayleigh quotient of A at an eigenvector gives its eigenvalue.
Wikipedia, 'Power iteration' (finds the eigenvalue greatest in absolute value; needs a strictly dominant eigenvalue; Rayleigh quotient gives the eigenvalue), https://en.wikipedia.org/wiki/Power_iteration
- verified Make power iteration converge on a tied pair
The second matrix, , has eigenvalues , again a tie.
Trace 0 and determinant -5 give eigenvalues +-sqrt5, equal in magnitude.
Wikipedia, 'Power iteration' (finds the eigenvalue greatest in absolute value; needs a strictly dominant eigenvalue; Rayleigh quotient gives the eigenvalue), https://en.wikipedia.org/wiki/Power_iteration; numpy.linalg.eigvalsh([[1,2],[2,-1]]) = [-2.2360680, 2.2360680] (this check)
- verified Make the heat-equation step stable past r = 1/2
The explicit (FTCS) step for multiplies the grid's most jagged mode by about each step, and for that is : a checkerboard that should fade grows to 215 in 16 steps.
FTCS multiplies mode m by 1 - 4r sin^2(m pi/(2N)), about 1 - 4r for the most jagged mode; 1 - 2.4 = -1.4, beyond the r <= 1/2 limit. The 215 is from the run.
Wikipedia, 'FTCS scheme' (forward time, centered space; stable for r = alpha dt/dx^2 <= 1/2), https://en.wikipedia.org/wiki/FTCS_scheme
- verified Make the heat-equation step stable past r = 1/2
Rewrite
heat_stepas backward Euler, which needs a tridiagonal solve per step and damps every mode for every .Backward Euler on the semi-discrete heat equation is A-stable, so every mode is damped for any r; each step is a tridiagonal solve.
Wikipedia, 'Stiff equation' (fast vs slow time scales; backward Euler u_{n+1} = u_n + h f(u_{n+1}); A-stability, |1 - h lambda|^-1 <= 1), https://en.wikipedia.org/wiki/Stiff_equation; Wikipedia, 'FTCS scheme' (forward time, centered space; stable for r = alpha dt/dx^2 <= 1/2), https://en.wikipedia.org/wiki/FTCS_scheme
- verified Make the heat-equation step stable past r = 1/2
FTCS stands for forward in time, centered in space: the new value at each point is the old one plus times the second difference of its neighbors.
Standard definition of FTCS.
Wikipedia, 'FTCS scheme' (forward time, centered space; stable for r = alpha dt/dx^2 <= 1/2), https://en.wikipedia.org/wiki/FTCS_scheme
- verified Make the heat-equation step stable past r = 1/2
It is stable only for , so halving forces a time step four times smaller.
Stability needs dt <= dx^2/2 (alpha = 1), so halving dx cuts dt by 4.
Wikipedia, 'FTCS scheme' (forward time, centered space; stable for r = alpha dt/dx^2 <= 1/2), https://en.wikipedia.org/wiki/FTCS_scheme
- verified Make the heat-equation step stable past r = 1/2
Backward Euler takes the second difference at the new time instead,
Backward Euler evaluates the right-hand side (the second difference) at the new time.
Wikipedia, 'Stiff equation' (fast vs slow time scales; backward Euler u_{n+1} = u_n + h f(u_{n+1}); A-stability, |1 - h lambda|^-1 <= 1), https://en.wikipedia.org/wiki/Stiff_equation
- verified Make the heat-equation step stable past r = 1/2
Backward Euler u^{n+1} = u^n + r (second difference of u^{n+1}), rearranged.
Wikipedia, 'Stiff equation' (fast vs slow time scales; backward Euler u_{n+1} = u_n + h f(u_{n+1}); A-stability, |1 - h lambda|^-1 <= 1), https://en.wikipedia.org/wiki/Stiff_equation; Wikipedia, 'FTCS scheme' (forward time, centered space; stable for r = alpha dt/dx^2 <= 1/2), https://en.wikipedia.org/wiki/FTCS_scheme
- verified Make the heat-equation step stable past r = 1/2
a tridiagonal linear system for the new values, with , , on its three diagonals.
Collecting terms in the equation gives -r, 1 + 2r, -r on the three diagonals.
Wikipedia, 'Stiff equation' (fast vs slow time scales; backward Euler u_{n+1} = u_n + h f(u_{n+1}); A-stability, |1 - h lambda|^-1 <= 1), https://en.wikipedia.org/wiki/Stiff_equation
- not-checkable Make the heat-equation step stable past r = 1/2
Viv's
tridiag_solve(lower, diagonal, upper, rhs)solves one.Describes Viv's library function.
- not-checkable Make the heat-equation step stable past r = 1/2
The other expected numbers come from
posts/refs/make-the-heat-equation-step-stable.py, which runs backward Euler withnumpy.linalg.solveon the full matrix.Describes this post's reference script.
- not-checkable Metropolis sampling finds Onsager's magnetization
The test's tolerance is three standard errors, measured from the run itself by batch means: 20 batches of 60 sweeps each.
Describes this program's test (20 batches of 60 sweeps, PER_BATCH = 60 in the code); nothing to check against the literature.
- not-checkable Metropolis sampling finds Onsager's magnetization
A separate Metropolis code (
posts/refs/metropolis-ising-against-onsager.py, 64 chains of 20000 sweeps) supports that choice three ways.Describes this post's reference script.
- verified Metropolis sampling finds Onsager's magnetization
The Ising model is a grid of little magnets, each pointing up () or down ().
Spins s = +-1 on a lattice, standing for magnetic dipoles, is the Ising model.
Wikipedia, Ising model (pointer), https://en.wikipedia.org/wiki/Ising_model; J. Kotze, Introduction to Monte Carlo methods for an Ising Model of a Ferromagnet, arXiv:0803.0217 (2008), eq. (2) and Fig. 2
- verified Metropolis sampling finds Onsager's magnetization
Each spin interacts with its four neighbors, and the energy of an arrangement is
Nearest-neighbor coupling on the square lattice: each spin has four neighbors (above, below, left, right).
J. Kotze, Introduction to Monte Carlo methods for an Ising Model of a Ferromagnet, arXiv:0803.0217 (2008), eq. (2), Figs. 3-4; Wikipedia, Ising model (pointer), https://en.wikipedia.org/wiki/Ising_model
- verified Metropolis sampling finds Onsager's magnetization
Standard zero-field nearest-neighbor Ising energy.
Wikipedia, 'Ising model' (H = -J sum_<ij> s_i s_j; Boltzmann weight e^{-beta H}; single-spin-flip Metropolis), https://en.wikipedia.org/wiki/Ising_model
- verified Metropolis sampling finds Onsager's magnetization
summed over neighboring pairs, so two aligned neighbors lower the energy by and two opposed ones raise it by .
With H = -J sum s_i s_j over nearest neighbors and J > 0, an aligned pair contributes -J and an opposed pair +J.
Wikipedia, Ising model (pointer), https://en.wikipedia.org/wiki/Ising_model; J. Kotze, Introduction to Monte Carlo methods for an Ising Model of a Ferromagnet, arXiv:0803.0217 (2008), eq. (2) (J > 0 favors parallel alignment)
- verified Metropolis sampling finds Onsager's magnetization
At temperature , an arrangement with energy occurs with probability proportional to .
Configuration probability P(sigma) = e^{-beta H(sigma)}/Z with beta = 1/(k_B T); the post sets k_B = 1.
Wikipedia, Ising model (pointer), https://en.wikipedia.org/wiki/Ising_model
- verified Metropolis sampling finds Onsager's magnetization
The quantity of interest is the magnetization , the average spin.
Magnetization per spin M/N, the average spin, is the standard order parameter.
J. Kotze, Introduction to Monte Carlo methods for an Ising Model of a Ferromagnet, arXiv:0803.0217 (2008), sec. 2.2, Figs. 9-10 (magnetization per spin M/N)
- verified Metropolis sampling finds Onsager's magnetization
Summing over all arrangements of a 16 by 16 grid is impossible, so the program samples arrangements instead.
16 x 16 = 256 spins with two states each gives 2^256 (about 1.2e77) configurations, far too many to sum.
Wikipedia, 'Ising model' (H = -J sum_<ij> s_i s_j; Boltzmann weight e^{-beta H}; single-spin-flip Metropolis), https://en.wikipedia.org/wiki/Ising_model
- verified Metropolis sampling finds Onsager's magnetization
Repeating this visits arrangements with exactly the Boltzmann probabilities in the long run.
Single-spin Metropolis leaves the Boltzmann distribution invariant and is ergodic; the post sweeps spins in order, which satisfies balance rather than detailed balance, and Manousiouthakis and Deem show balance suffices for sequential updating.
Wikipedia, Ising model (pointer), https://en.wikipedia.org/wiki/Ising_model; V. I. Manousiouthakis and M. W. Deem, Strict detailed balance is unnecessary in Monte Carlo simulation, J. Chem. Phys. 110, 2753 (1999), abstract, https://arxiv.org/abs/cond-mat/9809240
- plausible Metropolis sampling finds Onsager's magnetization
One pass over all 256 spins is a sweep.
Not accessed; from general knowledge: a sweep is one attempted flip per spin (Newman and Barkema, Monte Carlo Methods in Statistical Physics).
Wikipedia, 'Ising model' (H = -J sum_<ij> s_i s_j; Boltzmann weight e^{-beta H}; single-spin-flip Metropolis), https://en.wikipedia.org/wiki/Ising_model
- not-checkable Metropolis sampling finds Onsager's magnetization
The edges wrap around (periodic boundaries), so every spin has four neighbors.
Describes this program's boundary conditions (the mod() in metropolis_sweep); periodic wrapping giving four neighbors is standard (Kotze, arXiv:0803.0217, Figs. 3-4).
- verified Metropolis sampling finds Onsager's magnetization
Lars Onsager solved the two-dimensional Ising model exactly in 1944, and C. N. Yang derived its magnetization in 1952.
Onsager solved the model in 1944 (Phys. Rev. 65, 117), announced the magnetization without proof in 1949, and Yang published its derivation in Phys. Rev. 85, 808 (1952).
F. Y. Wu, Professor C. N. Yang and Statistical Mechanics, arXiv:1010.1838, eq. (1) and refs. [10], [11], [14], https://arxiv.org/abs/1010.1838; C. N. Yang, The Spontaneous Magnetization of a Two-Dimensional Ising Model, Phys. Rev. 85, 808 (1952), title page read at http://home.ustc.edu.cn/~weixianhao/ref/cnyang.pdf; Wikipedia, Square lattice Ising model (pointer to Onsager 1944 and Yang 1952), https://en.wikipedia.org/wiki/Square_lattice_Ising_model
- not-checkable Metropolis sampling finds Onsager's magnetization
Below the critical temperature ,
Sentence fragment leading into the formula.
- verified Metropolis sampling finds Onsager's magnetization
Yang's spontaneous magnetization with J = k = 1.
Wikipedia, 'Square lattice Ising model' (Onsager 1944; Yang 1952: M = [1 - sinh^-4(2 beta J)]^(1/8) below Tc, 0 above; kTc/J = 2/ln(1+sqrt2)), https://en.wikipedia.org/wiki/Square_lattice_Ising_model
- verified Metropolis sampling finds Onsager's magnetization
Close to , behaves like , so it drops to zero almost vertically.
Wu's eq. (1), Yang's result M = [1 - sinh^{-4}(2K)]^{1/8}, vanishes at T_c with exponent beta = 1/8, so its slope diverges there.
F. Y. Wu, Professor C. N. Yang and Statistical Mechanics, arXiv:1010.1838, eq. (1) and refs. [10], [11], [14], https://arxiv.org/abs/1010.1838; Wikipedia, Square lattice Ising model (pointer to Onsager 1944 and Yang 1952), https://en.wikipedia.org/wiki/Square_lattice_Ising_model
- verified Metropolis sampling finds Onsager's magnetization
The standard error comes from batch means: average each block of 60 sweeps, and treat the 20 block averages as independent samples.
Nonoverlapping batch means: batch averages are treated as approximately independent to estimate the Monte Carlo standard error.
Flegal and Jones, 'Batch means and spectral variance estimators in Markov chain Monte Carlo', Ann. Statist. 38(2), 1034-1070 (2010), arXiv:0811.1729
- verified Metropolis sampling finds Onsager's magnetization
The run gives with a standard error of (
m_mc,sigma), and Onsager's value is (m_exact): they differ by , about an eighth of one standard error.Yang's formula at T = 1.8 gives 0.956857 (computed in this check); 0.956857 - 0.956686 = 0.000171, which is 0.13 standard errors, about an eighth.
Wikipedia, 'Square lattice Ising model' (Onsager 1944; Yang 1952: M = [1 - sinh^-4(2 beta J)]^(1/8) below Tc, 0 above; kTc/J = 2/ln(1+sqrt2)), https://en.wikipedia.org/wiki/Square_lattice_Ising_model
- not-checkable Metropolis sampling finds Onsager's magnetization
Below the points sit on the curve.
Describes this run's figure.
- not-checkable Metropolis sampling finds Onsager's magnetization
Above it they do not reach zero: at the grid still has (
m_T), and the reference code, running the same short protocol 256 times, averages there.Describes this run and the reference output (3.2 0.1465).
- verified Metropolis sampling finds Onsager's magnetization
The reason is the grid's size.
Kotze attributes the nonzero |M| and the missing sharp transition to the lattice's finite size; the post's 1/sqrt(patches) argument is the central-limit estimate.
J. Kotze, Introduction to Monte Carlo methods for an Ising Model of a Ferromagnet, arXiv:0803.0217 (2008), sec. 2.2 (Figs. 9-10, absolute magnetization) and sec. 2.4 (finite size scaling)
- plausible Metropolis sampling finds Onsager's magnetization
Above the spins form patches of aligned spins that are uncorrelated with each other, and the net spin of 256 spins in a few dozen independent patches is a random sum, whose absolute value is of order one over the square root of the number of patches, not zero.
Not accessed; from general knowledge: a finite lattice above Tc has |m| of order 1/sqrt(number of correlated regions) by the central limit theorem, going to zero as L grows.
Wikipedia, 'Square lattice Ising model' (Onsager 1944; Yang 1952: M = [1 - sinh^-4(2 beta J)]^(1/8) below Tc, 0 above; kTc/J = 2/ln(1+sqrt2)), https://en.wikipedia.org/wiki/Square_lattice_Ising_model
- verified Metropolis sampling finds Onsager's magnetization
The same effect rounds off the sharp drop at .
On a finite lattice the divergence at T_c is not seen; the transition is rounded, and only finite-size scaling recovers the infinite-lattice behavior.
J. Kotze, Introduction to Monte Carlo methods for an Ising Model of a Ferromagnet, arXiv:0803.0217 (2008), sec. 2.4 (finite size scaling)
- verified Nuclear level density, by counting the states
They grow like Bethe's ; at the count is 4.4% below the leading Hardy-Ramanujan term, and the next term of the series, , accounts for all but 0.06% of that.
p(100)/HR(100) = 0.95628, 4.37% below; with c = 0.4433 the corrected estimate misses by 0.00061 (0.06%).
Wikipedia, 'Partition function (number theory)' (p(100) = 190569292; Hardy-Ramanujan 1918 p(n) ~ exp(pi sqrt(2n/3))/(4 n sqrt3); Euler pentagonal recurrence; Rademacher 1937; parts at most k via Ferrers diagrams), https://en.wikipedia.org/wiki/Partition_function_(number_theory); Independent recomputation in this check (mpmath, 30 digits): p(25) = 1958, p/HR = 0.912704; p(100)/HR = 0.956285; c = sqrt6/(2 pi) + pi/(24 sqrt6) = 0.443288; residual 0.00136 and 0.000614
- plausible Nuclear level density, by counting the states
A heavy nucleus hit by a neutron is left with a few MeV of excitation energy, and at that energy it has an enormous number of states.
Not accessed; from general knowledge: neutron capture leaves the compound nucleus at the neutron separation energy, typically 5-8 MeV, where s-wave resonance spacings are eV-scale, i.e. very many states.
Egidy/Bucurescu-type back-shifted Fermi gas fits: a fixed from cumulative low-lying level counts and s-wave resonance spacing D0 at the neutron binding energy, e.g. 'Level-density parameters in the back-shifted Fermi gas model', Phys. At. Nucl., https://link.springer.com/article/10.1134/1.855702
- verified Nuclear level density, by counting the states
How many states lie near a given energy, the level density , decides how likely it is to capture the neutron, and what it emits as it cools down.
In Hauser-Feshbach theory, level densities set the capture cross section and the decay (gamma) cascade.
Capote et al., 'RIPL - Reference Input Parameter Library', Nucl. Data Sheets 110, 3107 (2009), https://www-nds.iaea.org/RIPL-3/ (level densities as Hauser-Feshbach input; capture cross sections most sensitive to level densities and photon strengths)
- verified Nuclear level density, by counting the states
It enters reaction rates in reactors and in the formation of the heavy elements in stars.
Level densities are core inputs to reaction-rate evaluations for reactor data and for astrophysical (s- and r-process) rates.
Capote et al., 'RIPL - Reference Input Parameter Library', Nucl. Data Sheets 110, 3107 (2009), https://www-nds.iaea.org/RIPL-3/ (level densities as Hauser-Feshbach input; capture cross sections most sensitive to level densities and photon strengths)
- verified Nuclear level density, by counting the states
The simplest model that gives the right trend is a Fermi gas: nucleons that do not interact with each other, sitting in single-particle levels.
Bethe's model treats the nucleons as independent particles in single-particle levels.
H. A. Bethe, 'An Attempt to Calculate the Number of Energy Levels of a Heavy Nucleus', Phys. Rev. 50, 332 (1936), https://link.aps.org/doi/10.1103/PhysRev.50.332 (abstract: independent particles in a potential, energy a sum of single-particle energies); Guttormsen et al., 'Experimental level densities of atomic nuclei', arXiv:1503.03300 (Bethe's non-interacting Fermi gas; data favor constant temperature at low energy)
- not-checkable Nuclear level density, by counting the states
An excited state is any other choice of occupied levels, and its excitation energy is its total energy minus the lowest one.
Defines the model's terms.
- not-checkable Nuclear level density, by counting the states
Listing every choice of 100 levels out of 200 is out of the question, so the program counts with a table: after deciding about levels to , entry is the number of ways to have placed particles in them with energy above the least possible for particles, .
Describes this program's counting table; the minimum energy for n particles in levels 0, 1, ... is n(n-1)/2.
- not-checkable Nuclear level density, by counting the states
Level is either empty, which changes nothing, or holds the -th particle, which adds to the energy and to .
Describes this program's update; the arithmetic is right (the minimum rises by n - 1 when the n-th particle is added).
- not-checkable Nuclear level density, by counting the states
Going through from the top down uses each level at most once.
Describes this program's loop order (the 0/1-knapsack trick).
- not-checkable Nuclear level density, by counting the states
Energies above are never needed, and no level above can be occupied at those energies, so the table is small.
Describes this program's table bounds; the top particle can rise at most E_max above level N - 1.
- not-checkable Nuclear level density, by counting the states
The first counts can be checked by hand.
Transition.
- verified Nuclear level density, by counting the states
The reason: number the particles from the top, and let be how far the -th one moved up.
Standard bijection between Fermi-sea excitations of equally spaced levels and partitions (Ferrers diagrams).
Wikipedia, 'Partition function (number theory)' (p(100) = 190569292; Hardy-Ramanujan 1918 p(n) ~ exp(pi sqrt(2n/3))/(4 n sqrt3); Euler pentagonal recurrence; Rademacher 1937; parts at most k via Ferrers diagrams), https://en.wikipedia.org/wiki/Partition_function_(number_theory)
- verified Nuclear level density, by counting the states
So an excited state is a partition of into at most parts, and for the limit on the number of parts never binds.
The displacements form a partition of E with at most N parts; a partition of E has at most E parts, so the limit never binds when E <= N.
Wikipedia, 'Partition function (number theory)' (p(100) = 190569292; Hardy-Ramanujan 1918 p(n) ~ exp(pi sqrt(2n/3))/(4 n sqrt3); Euler pentagonal recurrence; Rademacher 1937; parts at most k via Ferrers diagrams), https://en.wikipedia.org/wiki/Partition_function_(number_theory)
- verified Nuclear level density, by counting the states
Hans Bethe worked out in 1936 how a Fermi gas's level density grows: , where the level density parameter is times the number of single-particle levels per unit energy, which is 1 here.
Bethe 1936 Fermi-gas density grows as exp(2 sqrt(aE)) with a = pi^2 g/6 (g = single-particle level density); here g = 1.
H. A. Bethe, 'An Attempt to Calculate the Number of Energy Levels of a Heavy Nucleus', Phys. Rev. 50, 332 (1936), https://link.aps.org/doi/10.1103/PhysRev.50.332 (abstract: independent particles in a potential, energy a sum of single-particle energies)
- verified Nuclear level density, by counting the states
Hardy and Ramanujan had found the growth of the partition numbers in 1918, with the prefactor:
Hardy and Ramanujan, 1918, with the 1/(4 n sqrt3) prefactor.
Wikipedia, 'Partition function (number theory)' (p(100) = 190569292; Hardy-Ramanujan 1918 p(n) ~ exp(pi sqrt(2n/3))/(4 n sqrt3); Euler pentagonal recurrence; Rademacher 1937; parts at most k via Ferrers diagrams), https://en.wikipedia.org/wiki/Partition_function_(number_theory)
- verified Nuclear level density, by counting the states
Hardy-Ramanujan asymptotic formula as stated.
Wikipedia, 'Partition function (number theory)' (p(100) = 190569292; Hardy-Ramanujan 1918 p(n) ~ exp(pi sqrt(2n/3))/(4 n sqrt3); Euler pentagonal recurrence; Rademacher 1937; parts at most k via Ferrers diagrams), https://en.wikipedia.org/wiki/Partition_function_(number_theory)
- verified Nuclear level density, by counting the states
and is Bethe's exponent with .
2 sqrt(pi^2 E/6) = pi sqrt(4E/6) = pi sqrt(2E/3).
Wikipedia, 'Partition function (number theory)' (p(100) = 190569292; Hardy-Ramanujan 1918 p(n) ~ exp(pi sqrt(2n/3))/(4 n sqrt3); Euler pentagonal recurrence; Rademacher 1937; parts at most k via Ferrers diagrams), https://en.wikipedia.org/wiki/Partition_function_(number_theory)
- verified Nuclear level density, by counting the states
The two results are the same count.
For equally spaced single-species levels, the state count at energy E is p(E), so Bethe's exponent and Hardy-Ramanujan's are the same asymptotics.
Wikipedia, 'Partition function (number theory)' (p(100) = 190569292; Hardy-Ramanujan 1918 p(n) ~ exp(pi sqrt(2n/3))/(4 n sqrt3); Euler pentagonal recurrence; Rademacher 1937; parts at most k via Ferrers diagrams), https://en.wikipedia.org/wiki/Partition_function_(number_theory); H. A. Bethe, 'An Attempt to Calculate the Number of Energy Levels of a Heavy Nucleus', Phys. Rev. 50, 332 (1936), https://link.aps.org/doi/10.1103/PhysRev.50.332 (abstract: independent particles in a potential, energy a sum of single-particle energies)
- verified Nuclear level density, by counting the states
At the count is 8.7% below the leading term and at it is 4.4% below (
ratio_25,ratio_100): four times the energy, half the gap.1 - p/HR = 8.73% at 25 and 4.37% at 100, ratio 2.0, as expected from a leading 1/sqrt(E) correction.
Independent recomputation in this check (mpmath, 30 digits): p(25) = 1958, p/HR = 0.912704; p(100)/HR = 0.956285; c = sqrt6/(2 pi) + pi/(24 sqrt6) = 0.443288; residual 0.00136 and 0.000614
- plausible Nuclear level density, by counting the states
An experiment measures , not , and extracts from how fast grows with .
Simplified: in practice a is fitted to measured densities at two energies (low-lying level counts and the resonance spacing D0 at the neutron binding energy), which amounts to the growth of ln rho with energy.
Egidy/Bucurescu-type back-shifted Fermi gas fits: a fixed from cumulative low-lying level counts and s-wave resonance spacing D0 at the neutron binding energy, e.g. 'Level-density parameters in the back-shifted Fermi gas model', Phys. At. Nucl., https://link.springer.com/article/10.1134/1.855702; Guttormsen et al., 'Experimental level densities of atomic nuclei', arXiv:1503.03300 (Bethe's non-interacting Fermi gas; data favor constant temperature at low energy)
- verified Nuclear level density, by counting the states
The prefactor subtracts from it.
With rho ~ exp(2 sqrt(aE))/E, ln rho has the term -ln E = -2 ln sqrt(E), whose derivative in sqrt(E) is -2/sqrt(E); a = pi^2/6 gives the Hardy-Ramanujan exponent.
Wikipedia, 'Partition function (number theory)', sec. Approximation formulas: Hardy-Ramanujan p(n) ~ exp(pi*sqrt(2n/3))/(4n*sqrt(3)) (Hardy & Ramanujan, Proc. London Math. Soc. 17, 75 (1918)), https://en.wikipedia.org/wiki/Partition_function_(number_theory)
- verified Nuclear level density, by counting the states
The counts give a slope of (
slope), not : taking from them without the prefactor would put at instead of , 15% low.Arithmetic checks: (2.359/2)^2 = 1.391, which is 15.4% below pi^2/6 = 1.645; 2.565 - 2 ln(10/9) = 2.354 matches the stated prediction.
Wikipedia, 'Partition function (number theory)', sec. Approximation formulas: Hardy-Ramanujan p(n) ~ exp(pi*sqrt(2n/3))/(4n*sqrt(3)) (Hardy & Ramanujan, Proc. London Math. Soc. 17, 75 (1918)), https://en.wikipedia.org/wiki/Partition_function_(number_theory); posts/refs/nuclear-level-density-by-counting.out
- verified Nuclear level density, by counting the states
The prefactor matters at energies this low.
At sqrt(E) = 9 to 10 the prefactor term -2/sqrt(E) is about -0.21, 8% of the bare slope 2.565, as the sentence says.
Wikipedia, 'Partition function (number theory)', sec. Approximation formulas: Hardy-Ramanujan p(n) ~ exp(pi*sqrt(2n/3))/(4n*sqrt(3)) (Hardy & Ramanujan, Proc. London Math. Soc. 17, 75 (1918)), https://en.wikipedia.org/wiki/Partition_function_(number_theory)
- not-checkable Neutron pairing in a neutron-star crust
One cell of the neutron-star inner crust in one dimension: a slab of nuclear matter in a gas of free neutrons, with a contact pairing force.
Describes what the program models.
- verified Neutron pairing in a neutron-star crust
Below the outer crust of a neutron star, nuclei are so neutron-rich that neutrons drip out of them and fill the space between as a gas.
The review describes neutron drip at the outer/inner crust boundary with a neutron gas between the nuclei.
N. Chamel and P. Haensel, 'Physics of Neutron Star Crusts', Living Rev. Relativity 11, 10 (2008), arXiv:0812.3955, sec. 2.1 ('A neutron gas is also present at densities greater than neutron drip density ~4e11 g/cm^3') and sec. 3.1 (neutrons 'drip out of nuclei')
- verified Neutron pairing in a neutron-star crust
That gas is expected to be a superfluid: neutrons of opposite spin pair up, as electrons do in a superconductor, and the energy needed to break a pair is twice the pairing gap .
Crust neutrons are expected to be superfluid; breaking a pair costs at least 2 Delta (two quasiparticles of energy >= Delta each).
N. Chamel and P. Haensel, 'Physics of Neutron Star Crusts', Living Rev. Relativity 11, 10 (2008), arXiv:0812.3955, sec. 8.2 (free neutrons in the crust very likely superfluid); Wikipedia, 'BCS theory' (energy gap for single-particle excitation; breaking a pair), https://en.wikipedia.org/wiki/BCS_theory
- verified Neutron pairing in a neutron-star crust
Deeper down, the nuclei are thought to flatten into sheets (the "lasagna" phase).
Pasta phases, including slab-shaped 'lasagna', are predicted in the deepest layer of the inner crust; spaghetti rods come before the slabs.
N. Chamel and P. Haensel, 'Physics of Neutron Star Crusts', Living Rev. Relativity 11, 10 (2008), arXiv:0812.3955, sec. 3.3 (sphere -> cylinder -> slab shapes; slabs called 'lasagna') and sec. 7.2 (pasta in the bottom crust layer); Wikipedia, 'Nuclear pasta': inner-crust phases gnocchi, spaghetti, lasagna (sheets), ..., https://en.wikipedia.org/wiki/Nuclear_pasta
- not-checkable Neutron pairing in a neutron-star crust
The method is the Hartree-Fock-Bogoliubov one, cut down to its pairing part.
Describes this program's method.
- not-checkable Neutron pairing in a neutron-star crust
A neutron's energy in the cell is , with a Woods-Saxon well 40 MeV deep and 10 fm wide standing for the slab.
States this program's model parameters.
- verified Neutron pairing in a neutron-star crust
Pairing mixes a neutron state () with a hole state (), which gives the Bogoliubov-de Gennes (BdG) equations above.
In HFB/BdG the quasiparticle has an upper (particle) and lower (hole) component coupled by the pairing field.
K. Bennaceur and J. Dobaczewski, 'Coordinate-space solution of the Skyrme-Hartree-Fock-Bogolyubov equations within spherical symmetry. The program HFBRAD (v1.00)', Comput. Phys. Commun. 168, 96 (2005), arXiv:nucl-th/0501002, eqs. (31)-(33)
- verified Neutron pairing in a neutron-star crust
The pairing field depends on the solutions through the anomalous density , so the equations are solved over and over until stops changing.
Same sign convention as HFBRAD's abnormal density; the pairing field depends on it, so the equations are iterated to self-consistency. Signs and which half of the spectrum is summed vary by convention.
K. Bennaceur and J. Dobaczewski, 'Coordinate-space solution of the Skyrme-Hartree-Fock-Bogolyubov equations within spherical symmetry. The program HFBRAD (v1.00)', Comput. Phys. Commun. 168, 96 (2005), arXiv:nucl-th/0501002, eq. (5): abnormal density rho~ = -sum_i phi1 phi2
- verified Neutron pairing in a neutron-star crust
In one dimension a contact force gives a finite without a cutoff, so no regularization is needed.
Bulgac and Yu show the anomalous density diverges for a zero-range force in 3D; in 1D the corresponding integral goes as int dk/k^2 at large k and converges, so no cutoff is needed.
A. Bulgac and Y. Yu, 'Renormalization of the Hartree-Fock-Bogoliubov equations in the case of a zero range pairing interaction', PRL 88, 042504 (2002), arXiv:nucl-th/0106062
- not-checkable Neutron pairing in a neutron-star crust
posts/refs/pairing-in-the-neutron-star-crust.pysolves the same cell with numpy (the matrix in block form, not interleaved, and 100 times tighter convergence), and solves the uniform gas from the BCS gap equation without diagonalizing anything.Describes the reference script.
- verified Neutron pairing in a neutron-star crust
The kinetic energy is the three-point second difference, so each site couples to its neighbors with .
The three-point stencil applied to -hbar^2/(2m) d^2/dx^2 gives off-diagonal -hbar^2/(2m dx^2) and diagonal twice that, so tau = hbar^2/(2m dx^2).
Wikipedia, 'Finite difference', sec. Higher-order differences: f''(x) ~ [f(x+h) - 2f(x) + f(x-h)]/h^2, https://en.wikipedia.org/wiki/Finite_difference
- not-checkable Neutron pairing in a neutron-star crust
The cell has hard walls at both ends.
Describes this program's boundary conditions.
- verified Neutron pairing in a neutron-star crust
Every site is then the same, is uniform, and the BdG equations separate into plane waves of momentum , each with quasiparticle energy and .
Applying the three-point stencil to e^{ikx} gives 2 tau (1 - cos k dx); with uniform Delta the BdG problem is the BCS one with E_k = sqrt(xi_k^2 + Delta^2).
D. Ivanov, ETH Zurich lecture notes 'Self-consistency equations for the superconducting gap', sec. 5.4, eqs. (5.4.3)-(5.4.4), https://people.phys.ethz.ch/~ivanov/cmt/1213/ssth-lectureC.pdf; Wikipedia, 'Finite difference', sec. Higher-order differences: f''(x) ~ [f(x+h) - 2f(x) + f(x-h)]/h^2, https://en.wikipedia.org/wiki/Finite_difference
- verified Neutron pairing in a neutron-star crust
The self-consistency condition becomes the BCS gap equation on this lattice,
With uniform Delta the self-consistency condition Delta = (g/V) sum_k u_k v_k and u_k v_k = Delta/(2E_k) give the BCS gap equation.
D. Ivanov, ETH Zurich lecture notes 'Self-consistency equations for the superconducting gap', sec. 5.4, eqs. (5.4.3)-(5.4.4), https://people.phys.ethz.ch/~ivanov/cmt/1213/ssth-lectureC.pdf
- verified Neutron pairing in a neutron-star crust
Ivanov eqs. (5.4.3)-(5.4.4) at T = 0 give 1 = (g/V) sum_k 1/(2E_k); here the volume is V = N dx, which matches the post's g/dx * (1/N) sum.
D. Ivanov, ETH Zurich lecture notes 'Self-consistency equations for the superconducting gap', sec. 5.4, eqs. (5.4.3)-(5.4.4), https://people.phys.ethz.ch/~ivanov/cmt/1213/ssth-lectureC.pdf
- not-checkable Neutron pairing in a neutron-star crust
The gas there is 10 fm wide on each side, bounded by a hard wall and by the slab, not an infinite gas.
Describes this program's cell geometry (30 fm cell minus a 10 fm slab).
- not-checkable Neutron pairing in a neutron-star crust
The gap there peaks at 1.012 MeV about 4 fm from the wall, falls to zero at the wall, and falls toward the slab.
Describes this program's output; the 1.012 MeV peak and its position are checked by the program's test.
- not-checkable Silicon's band structure, from the crystal up
The code is a small version of the plane-wave DFT program in
dft/(the dense engine,dft/pwdft.viv), cut into the order the physics goes in.Describes this program.
- verified Silicon's band structure, from the crystal up
The whole calculation solves one equation, the Kohn-Sham equation above: each electron moves in the potential of the ions, plus the classical repulsion of the electron density (Hartree), plus an exchange-correlation term for what the classical repulsion misses.
The Kohn-Sham effective potential is external (ions) + Hartree + exchange-correlation, as described.
Wikipedia, 'Kohn-Sham equations' (v_eff = v_ext + Hartree + dE_xc/drho; self-consistent solution; total energy E = sum eps_i - E_H + E_xc - int rho v_xc), https://en.wikipedia.org/wiki/Kohn%E2%80%93Sham_equations
- verified Silicon's band structure, from the crystal up
The potential depends on , and is built from the solutions, so it is solved by iteration until the density stops changing.
The effective potential depends on the density built from the orbitals, so the equations are solved iteratively to self-consistency.
Wikipedia, 'Kohn-Sham equations' (v_eff = v_ext + Hartree + dE_xc/drho; self-consistent solution; total energy E = sum eps_i - E_H + E_xc - int rho v_xc), https://en.wikipedia.org/wiki/Kohn%E2%80%93Sham_equations
- verified Silicon's band structure, from the crystal up
Silicon has the diamond structure: an fcc lattice with lattice constant bohr (5.43 Å), and two atoms in each primitive cell, at .
a = 5.4310 A = 10.263 bohr; the diamond structure is fcc with two atoms per primitive cell a/4(1,1,1) apart, equivalent to +-a/8(1,1,1).
NIST CODATA 2022, lattice parameter of silicon a = 5.431020511e-10 m, https://physics.nist.gov/cgi-bin/cuu/Value?asil; Wikipedia, 'Diamond cubic': fcc lattice with two atoms per primitive cell separated by 1/4 of the cube edge in each direction, https://en.wikipedia.org/wiki/Diamond_cubic
- verified Silicon's band structure, from the crystal up
The rows of
Bare the reciprocal vectors, defined by .This is the standard definition of reciprocal lattice vectors.
Wikipedia, 'Reciprocal lattice': a_i . b_j = 2 pi delta_ij; lattice-periodic functions are Fourier series over G = m1 b1 + m2 b2 + m3 b3, https://en.wikipedia.org/wiki/Reciprocal_lattice
- verified Silicon's band structure, from the crystal up
Every function with the period of the crystal is a sum of plane waves with for integers .
Lattice-periodic functions expand in plane waves with G = m1 b1 + m2 b2 + m3 b3.
Wikipedia, 'Reciprocal lattice': a_i . b_j = 2 pi delta_ij; lattice-periodic functions are Fourier series over G = m1 b1 + m2 b2 + m3 b3, https://en.wikipedia.org/wiki/Reciprocal_lattice
- verified Silicon's band structure, from the crystal up
That is the reason to work with plane waves: the potential, the density and the periodic part of every orbital are Fourier series on this lattice.
The potential and density are lattice-periodic, and Bloch's theorem makes the orbital's u(r) periodic, so all are Fourier series over G.
Wikipedia, 'Reciprocal lattice': a_i . b_j = 2 pi delta_ij; lattice-periodic functions are Fourier series over G = m1 b1 + m2 b2 + m3 b3, https://en.wikipedia.org/wiki/Reciprocal_lattice; Wikipedia, 'Bloch's theorem': psi = e^{ik.r} u(r) with u lattice-periodic; each k gives bands eps_n(k), https://en.wikipedia.org/wiki/Bloch%27s_theorem
- not-checkable Silicon's band structure, from the crystal up
The next cell describes one silicon ion to the valence electrons.
Transition to the next cell.
- verified Silicon's band structure, from the crystal up
A silicon atom has 14 electrons; the 10 core electrons stay put when atoms bond, so they are replaced, together with the nucleus, by a pseudopotential acting on the 4 valence electrons.
Si has Z = 14 with configuration [Ne]3s2 3p2, so 10 core and 4 valence electrons; the GTH Si potential is the q4 (Z_ion = 4) one.
S. Goedecker, M. Teter, J. Hutter, 'Separable dual-space Gaussian pseudopotentials', PRB 54, 1703 (1996), arXiv:mtrl-th/9512004: eqs. (1)-(3) local + separable nonlocal form, eq. (5) V_loc(K), eqs. (6)-(12) projectors in Fourier space, Appendix (Pade LDA), introduction (eliminating core electrons); CP2K data, GTH_POTENTIALS, entry 'Si GTH-PADE-q4' (r_loc 0.44, C1 -7.33610297; s: r 0.42273813, h 5.90692831 -1.26189397 3.25819622; p: r 0.48427842, h 2.72701346), https://github.com/cp2k/cp2k-data/blob/master/potentials/Goedecker/cp2k/GTH_POTENTIALS
- verified Silicon's band structure, from the crystal up
The parameters are the Goedecker-Teter-Hutter ones for silicon, copied from CP2K's table by
dft/pseudo/make_pseudo.py.The r_loc, C1, HS, RP and HP values in the post's code match CP2K's 'Si GTH-PADE-q4' entry digit for digit.
CP2K data, GTH_POTENTIALS, entry 'Si GTH-PADE-q4' (r_loc 0.44, C1 -7.33610297; s: r 0.42273813, h 5.90692831 -1.26189397 3.25819622; p: r 0.48427842, h 2.72701346), https://github.com/cp2k/cp2k-data/blob/master/potentials/Goedecker/cp2k/GTH_POTENTIALS
- verified Silicon's band structure, from the crystal up
Its local part is a function of only.
GTH's V_loc(K) depends only on K = |K|, since the local part is spherically symmetric.
S. Goedecker, M. Teter, J. Hutter, 'Separable dual-space Gaussian pseudopotentials', PRB 54, 1703 (1996), arXiv:mtrl-th/9512004: eqs. (1)-(3) local + separable nonlocal form, eq. (5) V_loc(K), eqs. (6)-(12) projectors in Fourier space, Appendix (Pade LDA), eq. (5)
- verified Silicon's band structure, from the crystal up
Expect it to be negative (attractive) and to vanish at large , since the ion looks smooth to the valence electrons.
For Si, C1 = -7.336 < 0, so both terms of V_loc(g) are negative, and both carry the Gaussian e^{-(g r_loc)^2/2}, which vanishes at large g.
S. Goedecker, M. Teter, J. Hutter, 'Separable dual-space Gaussian pseudopotentials', PRB 54, 1703 (1996), arXiv:mtrl-th/9512004: eqs. (1)-(3) local + separable nonlocal form, eq. (5) V_loc(K), eqs. (6)-(12) projectors in Fourier space, Appendix (Pade LDA), eq. (5); CP2K data, GTH_POTENTIALS, entry 'Si GTH-PADE-q4' (r_loc 0.44, C1 -7.33610297; s: r 0.42273813, h 5.90692831 -1.26189397 3.25819622; p: r 0.48427842, h 2.72701346), https://github.com/cp2k/cp2k-data/blob/master/potentials/Goedecker/cp2k/GTH_POTENTIALS
- verified Silicon's band structure, from the crystal up
The local part is the same for every electron.
The local part is a single radial function applied to every electron, while the nonlocal part acts through l-dependent separable projectors.
S. Goedecker, M. Teter, J. Hutter, 'Separable dual-space Gaussian pseudopotentials', PRB 54, 1703 (1996), arXiv:mtrl-th/9512004: eqs. (1)-(3) local + separable nonlocal form, eq. (5) V_loc(K), eqs. (6)-(12) projectors in Fourier space, Appendix (Pade LDA), eqs. (1)-(3)
- not-checkable Silicon's band structure, from the crystal up
The next cell defines them and evaluates each at three values of .
Describes the next cell.
- verified Silicon's band structure, from the crystal up
The projector starts at zero and grows with : a plane wave with small is nearly constant across the ion, and a constant has no () component.
Replaces disputed a9d8aace9ad7: the zero is from angular momentum (j_1(0) = 0), not from the projector vanishing at the center.
Goedecker, Teter and Hutter, PRB 54, 1703 (1996), eqs. 10-12: the l = 1 projector's transform carries j_1(K r), p_p1(K) ~ K exp(-(K r_p)^2/2); Direct check in this session: the l = 1 transform of r exp(-r^2/2) is 0 at K = 0 and grows like K, while the second s projector (r^2 exp(-r^2/2), zero at the center) transforms to 3.76 at K = 0
- verified Silicon's band structure, from the crystal up
An electron in a crystal is a Bloch wave, times a periodic function, and each wave vector in the Brillouin zone gives its own set of energy bands.
This is Bloch's theorem and the resulting band structure eps_n(k).
Wikipedia, 'Bloch's theorem': psi = e^{ik.r} u(r) with u lattice-periodic; each k gives bands eps_n(k), https://en.wikipedia.org/wiki/Bloch%27s_theorem
- verified Silicon's band structure, from the crystal up
The density averages over , and that average is replaced by a sum over a few points.
The density is an average over the Brillouin zone, which plane-wave codes replace by a weighted sum over special (Monkhorst-Pack) k-points.
ABINIT documentation, input variable shiftk, item 2: for an FCC lattice the usual Monkhorst-Pack sampling uses nshiftk 4 with shifts (0.5 0.5 0.5), (0.5 0 0), (0 0.5 0), (0 0 0.5), https://docs.abinit.org/variables/basic/#shiftk
- verified Silicon's band structure, from the crystal up
It is a four-shift mesh: its points are closed under the crystal's rotations, so the density comes out with the crystal's symmetry without any explicit symmetrization.
ABINIT's usual FCC Monkhorst-Pack sampling uses exactly these four shifts; they are the four inequivalent L points, which the cubic point group permutes (up to reciprocal lattice vectors), so the sampled density keeps the crystal symmetry.
ABINIT documentation, input variable shiftk, item 2: for an FCC lattice the usual Monkhorst-Pack sampling uses nshiftk 4 with shifts (0.5 0.5 0.5), (0.5 0 0), (0 0.5 0), (0 0 0.5), https://docs.abinit.org/variables/basic/#shiftk; Wikipedia, 'Brillouin zone', FCC critical points: L = center of a hexagonal face, X = center of a square face, https://en.wikipedia.org/wiki/Brillouin_zone
- verified Silicon's band structure, from the crystal up
The basis at one is every plane wave whose kinetic energy is at most the cutoff.
The plane-wave basis is all k+G with kinetic energy below the cutoff; this is the standard definition.
N. D. Woods, M. C. Payne, P. J. Hasnip, 'Computing the self-consistent field in Kohn-Sham density functional theory', J. Phys.: Condens. Matter 31, 453001 (2019), arXiv:1905.02332, sec. IV (linear mixing converges q-linearly; Pulay/Anderson accelerates it), sec. III (plane-wave basis set); S. Goedecker, M. Teter, J. Hutter, 'Separable dual-space Gaussian pseudopotentials', PRB 54, 1703 (1996), arXiv:mtrl-th/9512004: eqs. (1)-(3) local + separable nonlocal form, eq. (5) V_loc(K), eqs. (6)-(12) projectors in Fourier space, Appendix (Pade LDA)
- verified Silicon's band structure, from the crystal up
The cutoff is the basis's one tunable parameter (the k-point mesh is the other convergence setting): raising it adds shorter waves and lowers the energy.
Replaces disputed 74a01a5add4f.
posts/2026-09-25-silicon-bands-from-the-crystal-up.viv: NKMESH is a tunable mesh setting, and the post later says the 10 Ha / 16 k-point comparison 'mixes the cutoff and the k-points'
- not-checkable Silicon's band structure, from the crystal up
plane_wavesloops over a box of integer triples large enough to hold every that can pass, and keeps the ones that do.Describes this program's function.
- not-checkable Silicon's band structure, from the crystal up
The cell above only defines things.
Describes this program.
- not-checkable Silicon's band structure, from the crystal up
The next one counts, sizes the arrays (one slot per k-point, and one spare slot for the band path), and fills each k-point's slot.
Describes this program.
- not-checkable Silicon's band structure, from the crystal up
On that grid the cell tabulates (for the Hartree term later) and the ions' potential.
Describes what this cell tabulates.
- verified Silicon's band structure, from the crystal up
Each atom contributes its local pseudopotential times a phase , the structure factor, which says where in the cell the atom sits.
An atom at tau contributes its form factor times exp(-i G . tau), the structure-factor phase.
Wikipedia, 'Structure factor' (F = sum_j f_j exp(-i q . R_j), phase set by atomic position in the cell), https://en.wikipedia.org/wiki/Structure_factor
- verified Silicon's band structure, from the crystal up
Two electrons repel, so each keeps the others at a distance, and electrons of the same spin are kept apart further by the Pauli principle.
Coulomb repulsion keeps all electrons apart (correlation), and same-spin electrons are further kept apart by the exchange hole required by the Pauli principle.
Wikipedia, 'Exchange interaction': exchange hole around an electron that same-spin electrons avoid by the Pauli principle, https://en.wikipedia.org/wiki/Exchange_interaction
- verified Silicon's band structure, from the crystal up
The Hartree term treats the density as a smooth charge cloud and misses both.
The Hartree term is the classical Coulomb energy of the density; exchange and correlation are the separate E_xc term.
Wikipedia, 'Kohn-Sham equations' (v_eff = v_ext + Hartree + dE_xc/drho; self-consistent solution; total energy E = sum eps_i - E_H + E_xc - int rho v_xc), https://en.wikipedia.org/wiki/Kohn%E2%80%93Sham_equations
- verified Silicon's band structure, from the crystal up
The local density approximation (LDA) adds, at each point, the exchange-correlation energy per electron of a uniform electron gas with the density found there.
The LDA uses at each point the xc energy per particle of the homogeneous electron gas with the local density.
Wikipedia, 'Local-density approximation': E_xc = int rho eps_xc(rho), eps_xc of the homogeneous electron gas; r_s = radius of a sphere holding one electron, https://en.wikipedia.org/wiki/Local-density_approximation
- verified Silicon's band structure, from the crystal up
The cell uses the Teter-93 Padé fit, a ratio of two polynomials in the Wigner-Seitz radius , the radius of a sphere that holds one electron.
The Pade form is a ratio of polynomials in r_s, and r_s is the radius of a sphere holding one electron.
S. Goedecker, M. Teter, J. Hutter, 'Separable dual-space Gaussian pseudopotentials', PRB 54, 1703 (1996), arXiv:mtrl-th/9512004: eqs. (1)-(3) local + separable nonlocal form, eq. (5) V_loc(K), eqs. (6)-(12) projectors in Fourier space, Appendix (Pade LDA), Appendix: eps_xc = -(a0 + a1 rs + a2 rs^2 + a3 rs^3)/(b1 rs + b2 rs^2 + b3 rs^3 + b4 rs^4); Wikipedia, 'Local-density approximation': E_xc = int rho eps_xc(rho), eps_xc of the homogeneous electron gas; r_s = radius of a sphere holding one electron, https://en.wikipedia.org/wiki/Local-density_approximation
- verified Silicon's band structure, from the crystal up
It is the functional the pseudopotential was fitted with.
The GTH LDA potentials were fitted with this Pade parameterization; CP2K labels the Si one GTH-PADE.
S. Goedecker, M. Teter, J. Hutter, 'Separable dual-space Gaussian pseudopotentials', PRB 54, 1703 (1996), arXiv:mtrl-th/9512004: eqs. (1)-(3) local + separable nonlocal form, eq. (5) V_loc(K), eqs. (6)-(12) projectors in Fourier space, Appendix (Pade LDA), section 'The parameters' (LDA parameters built with the Appendix's Pade parameterization); CP2K data, GTH_POTENTIALS, entry 'Si GTH-PADE-q4' (r_loc 0.44, C1 -7.33610297; s: r 0.42273813, h 5.90692831 -1.26189397 3.25819622; p: r 0.48427842, h 2.72701346), https://github.com/cp2k/cp2k-data/blob/master/potentials/Goedecker/cp2k/GTH_POTENTIALS
- verified Silicon's band structure, from the crystal up
The potential is the derivative, .
v_xc = d(rho eps_xc)/drho; with rho ~ r_s^-3, dr_s/drho = -r_s/(3 rho), which gives eps_xc - (r_s/3) d eps_xc/dr_s.
Wikipedia, 'Kohn-Sham equations' (v_eff = v_ext + Hartree + dE_xc/drho; self-consistent solution; total energy E = sum eps_i - E_H + E_xc - int rho v_xc), https://en.wikipedia.org/wiki/Kohn%E2%80%93Sham_equations; Wikipedia, 'Local-density approximation': E_xc = int rho eps_xc(rho), eps_xc of the homogeneous electron gas; r_s = radius of a sphere holding one electron, https://en.wikipedia.org/wiki/Local-density_approximation
- not-checkable Silicon's band structure, from the crystal up
In the plane-wave basis at , the Hamiltonian is a matrix with one row per plane wave:
Introduces a formula.
- verified Silicon's band structure, from the crystal up
Kinetic energy diagonal in k+G, local potential through V(G-G'), nonlocal separable term: the standard plane-wave Hamiltonian.
S. Goedecker, M. Teter, J. Hutter, 'Separable dual-space Gaussian pseudopotentials', PRB 54, 1703 (1996), arXiv:mtrl-th/9512004: eqs. (1)-(3) local + separable nonlocal form, eq. (5) V_loc(K), eqs. (6)-(12) projectors in Fourier space, Appendix (Pade LDA), eqs. (5)-(8) (plane-wave matrix elements of the local and nonlocal parts)
- verified Silicon's band structure, from the crystal up
The kinetic energy is diagonal.
A plane wave e^{i(k+G).r} is an eigenfunction of the kinetic operator with eigenvalue |k+G|^2/2, so that term is diagonal.
S. Goedecker, M. Teter, J. Hutter, 'Separable dual-space Gaussian pseudopotentials', PRB 54, 1703 (1996), arXiv:mtrl-th/9512004: eqs. (1)-(3) local + separable nonlocal form, eq. (5) V_loc(K), eqs. (6)-(12) projectors in Fourier space, Appendix (Pade LDA)
- verified Silicon's band structure, from the crystal up
The nonlocal part is a sum over projectors, , where each is one projector of one atom times an angular factor (a real spherical harmonic of the direction of ) times the atom's structure factor.
GTH's nonlocal part is sum Y_lm(K^) p_i(K) h_ij p_j(K') Y*_lm(K^'), a sum of projector outer products; each atom's copy carries its structure-factor phase. Real spherical harmonics are an equivalent choice.
S. Goedecker, M. Teter, J. Hutter, 'Separable dual-space Gaussian pseudopotentials', PRB 54, 1703 (1996), arXiv:mtrl-th/9512004: eqs. (1)-(3) local + separable nonlocal form, eq. (5) V_loc(K), eqs. (6)-(12) projectors in Fourier space, Appendix (Pade LDA), eqs. (6)-(8); Wikipedia, 'Structure factor' (F = sum_j f_j exp(-i q . R_j), phase set by atomic position in the cell), https://en.wikipedia.org/wiki/Structure_factor
- verified Silicon's band structure, from the crystal up
Five per atom: two projectors and one projector with three orientations.
Two s projectors plus one p projector with m = -1, 0, 1 gives five per atom.
S. Goedecker, M. Teter, J. Hutter, 'Separable dual-space Gaussian pseudopotentials', PRB 54, 1703 (1996), arXiv:mtrl-th/9512004: eqs. (1)-(3) local + separable nonlocal form, eq. (5) V_loc(K), eqs. (6)-(12) projectors in Fourier space, Appendix (Pade LDA), 'Discussion of the pseudo-potential parameters': second-row atoms have two s projectors and one p projector; CP2K data, GTH_POTENTIALS, entry 'Si GTH-PADE-q4' (r_loc 0.44, C1 -7.33610297; s: r 0.42273813, h 5.90692831 -1.26189397 3.25819622; p: r 0.48427842, h 2.72701346), https://github.com/cp2k/cp2k-data/blob/master/potentials/Goedecker/cp2k/GTH_POTENTIALS
- not-checkable Silicon's band structure, from the crystal up
Dholds the coupling matrices.Describes this program's variable.
- not-checkable Silicon's band structure, from the crystal up
Every k-point has its own number of plane waves, so the matrices are padded to
NPWMAXrows.Describes this program's padding.
- not-checkable Silicon's band structure, from the crystal up
To see the Hamiltonian before any self-consistency, the cell diagonalizes it at in the starting potential: the ions plus the exchange-correlation potential of a uniform density (whose Hartree potential is zero).
Describes what this cell computes.
- verified Silicon's band structure, from the crystal up
Expect one low -like state and then a triple degeneracy: at the three directions are equivalent.
Silicon's Gamma25' valence level is triply degenerate at k = 0 without spin-orbit, below it the s-like Gamma1 state; the starting potential has the same cubic symmetry.
M. S. Dresselhaus, Solid State Physics Part II, Optical Properties of Solids (MIT 6.732 notes): 'The Gamma25' band is triply degenerate at k = 0' (no spin-orbit), https://web.mit.edu/6.732/www/6.732-pt2.pdf
- not-checkable Silicon's band structure, from the crystal up
pair_indexgives, for every pair of plane waves, where their difference sits in the FFT grid, using whole-matrix arithmetic: an outer difference of the integer triples, wrapped onto the grid (a negative component is stored at ).Describes this program's function.
- not-checkable Silicon's band structure, from the crystal up
wrapdoes the same for one number.Describes this program's function.
- not-checkable Silicon's band structure, from the crystal up
takethen reads the potential at all those places at once.Describes this program's function.
- not-checkable Silicon's band structure, from the crystal up
Now the starting potential and one diagonalization at , in the spare slot.
Transition to the next cell.
- not-checkable Silicon's band structure, from the crystal up
potentialassembles the total local potential on the grid from a density: the ions, the Hartree potential and exchange-correlation.Describes this program's function.
- verified Silicon's band structure, from the crystal up
The Hartree potential comes from Poisson's equation, , which in reciprocal space is algebra: .
The Hartree potential int rho/|r-r'| satisfies del^2 V_H = -4 pi rho (atomic units), and del^2 -> -|G|^2 gives V_H(G) = 4 pi rho(G)/|G|^2.
Wikipedia, 'Kohn-Sham equations' (v_eff = v_ext + Hartree + dE_xc/drho; self-consistent solution; total energy E = sum eps_i - E_H + E_xc - int rho v_xc), https://en.wikipedia.org/wiki/Kohn%E2%80%93Sham_equations; N. D. Woods, M. C. Payne, P. J. Hasnip, 'Computing the self-consistent field in Kohn-Sham density functional theory', J. Phys.: Condens. Matter 31, 453001 (2019), arXiv:1905.02332, sec. IV (linear mixing converges q-linearly; Pulay/Anderson accelerates it), sec. III (Hartree kernel 4 pi/|G|^2)
- not-checkable Silicon's band structure, from the crystal up
build the potential from the density
RHO;Step of this program's loop.
- not-checkable Silicon's band structure, from the crystal up
compute the total energy and how far the new density is from the old one;
Step of this program's loop.
- verified Silicon's band structure, from the crystal up
The energy is the sum of the occupied band energies, corrected for double counting: each band energy contains the electron's interaction with the whole density, which counts every pair of electrons twice, so the Hartree energy is subtracted once and is replaced by .
Matches the Kohn-Sham total energy E = sum eps_i - E_H + E_xc - int rho v_xc. The full total energy also has an ion-ion (Ewald) term, which this program leaves out, as its test says.
Wikipedia, 'Kohn-Sham equations' (v_eff = v_ext + Hartree + dE_xc/drho; self-consistent solution; total energy E = sum eps_i - E_H + E_xc - int rho v_xc), https://en.wikipedia.org/wiki/Kohn%E2%80%93Sham_equations
- verified Silicon's band structure, from the crystal up
The full program mixes with the last three iterations (Anderson mixing,
dft/pw_common.viv), which takes fewer iterations; plain mixing is one line and reaches the same density.Anderson/Pulay mixing converges faster than linear mixing, and both converge to the same self-consistent fixed point.
N. D. Woods, M. C. Payne, P. J. Hasnip, 'Computing the self-consistent field in Kohn-Sham density functional theory', J. Phys.: Condens. Matter 31, 453001 (2019), arXiv:1905.02332, sec. IV (linear mixing converges q-linearly; Pulay/Anderson accelerates it)
- verified Silicon's band structure, from the crystal up
Plain mixing converges geometrically: once the first few iterations are past, expect the density change to shrink by about the same factor at every iteration.
Woods et al. state that linear mixing converges q-linearly, which means a roughly constant reduction factor per iteration near the fixed point.
N. D. Woods, M. C. Payne, P. J. Hasnip, 'Computing the self-consistent field in Kohn-Sham density functional theory', J. Phys.: Condens. Matter 31, 453001 (2019), arXiv:1905.02332, sec. IV (linear mixing converges q-linearly; Pulay/Anderson accelerates it)
- verified Silicon's band structure, from the crystal up
With the potential converged, the bands at any come from one diagonalization each, with no further iteration.
With the self-consistent potential fixed, H at each k is independent of the density, so bands along a path need one diagonalization per k (non-self-consistent band structure).
Wikipedia, 'Kohn-Sham equations' (v_eff = v_ext + Hartree + dE_xc/drho; self-consistent solution; total energy E = sum eps_i - E_H + E_xc - int rho v_xc), https://en.wikipedia.org/wiki/Kohn%E2%80%93Sham_equations; Wikipedia, 'Bloch's theorem': psi = e^{ik.r} u(r) with u lattice-periodic; each k gives bands eps_n(k), https://en.wikipedia.org/wiki/Bloch%27s_theorem
- verified Silicon's band structure, from the crystal up
The path runs from , the center of a hexagonal face of the Brillouin zone, to its center , and on to , the center of a square face.
In the fcc Brillouin zone, L is the center of a hexagonal face and X the center of a square face.
Wikipedia, 'Brillouin zone', FCC critical points: L = center of a hexagonal face, X = center of a square face, https://en.wikipedia.org/wiki/Brillouin_zone
- not-checkable Silicon's band structure, from the crystal up
Energies are shifted so that the top of the valence bands is zero, and converted to eV.
Describes this program's plotting convention.
- verified Silicon's band structure, from the crystal up
What to look for: the valence-band top is at and threefold degenerate.
The VBM is at Gamma and is triply degenerate (Gamma25') when spin-orbit coupling is neglected, as in this program.
E. Oliphant, V. Mantena, M. Brod, G. J. Snyder, W. Sun, 'Why does silicon have an indirect band gap?', Mater. Horiz. 12, 3073 (2025), arXiv:2404.05634, introduction: VBM at Gamma, CBM ~85% of the way from Gamma to X; M. S. Dresselhaus, Solid State Physics Part II, Optical Properties of Solids (MIT 6.732 notes): 'The Gamma25' band is triply degenerate at k = 0' (no spin-orbit), https://web.mit.edu/6.732/www/6.732-pt2.pdf
- verified Silicon's band structure, from the crystal up
The lowest conduction state is not at but most of the way to , so silicon's gap is indirect: an electron at the bottom of the conduction band has a different crystal momentum from a hole at the top of the valence band.
The silicon CBM lies about 85% of the way from Gamma to X, so the gap is indirect.
E. Oliphant, V. Mantena, M. Brod, G. J. Snyder, W. Sun, 'Why does silicon have an indirect band gap?', Mater. Horiz. 12, 3073 (2025), arXiv:2404.05634, introduction: VBM at Gamma, CBM ~85% of the way from Gamma to X
- verified Silicon's band structure, from the crystal up
That is a known failure of the LDA, not of the code.
LDA/GGA Kohn-Sham gaps severely underestimate semiconductor gaps (Si experiment 1.17 eV at 0 K); this is a failure of the functional and of the KS gap, not of the numerics.
Z.-h. Yang, H. Peng, J. Sun, J. P. Perdew, 'More-realistic band gaps from meta-generalized gradient approximations: only in a generalized Kohn-Sham scheme', PRB 93, 205205 (2016), arXiv:1603.00512, introduction and Table I (Si experimental gap 1.17 eV; LDA/GGA KS gaps severely underestimate, derivative discontinuity); Ioffe NSM archive, Silicon band structure: Eg = 1.17 - 4.73e-4 T^2/(T+636) eV, https://www.ioffe.ru/SVA/NSM/Semicond/Si/bandstr.html
- not-checkable Silicon's band structure, from the crystal up
The full program runs silicon at 10 Ha with 16 k-points (
dft/si.viv), and its check file pins the band energies at , and .Describes the full program and its check file.
- not-checkable Silicon's band structure, from the crystal up
Two settings differ, the cutoff and the k-points, so each difference mixes the two effects.
Describes this post's comparison.
- not-checkable Silicon's band structure, from the crystal up
The energies on both sides are measured from the valence-band top, so the comparison is of spacings between bands, and the differences need not have one sign.
Describes this post's comparison.
- not-checkable Silicon's band structure, from the crystal up
The six lowest bands along the path.
Figure caption.
- not-checkable Skyrme Hartree-Fock of oxygen-16
The ground state of O from the SLy5 Skyrme functional, solved on a radial mesh at two spacings and extrapolated.
Describes what this program computes.
- verified Skyrme Hartree-Fock of oxygen-16
The binding energy comes out 8.0250 MeV per nucleon and the charge radius 2.7993 fm; skyrme_rpa, the published code of Colò et al. (2013), gives 8.0261 MeV and 2.7991 fm in its own test run with the same force, and the six single-particle energies agree with it to 3 keV.
The numbers are linked to the run and to skyrme_rpa's sample output; the largest single-particle difference in the reference file is 2.1 keV (1p3/2 neutron), within the stated 3 keV.
G. Colo, L. Cao, N. Van Giai, L. Capelli, 'Self-consistent RPA calculations with Skyrme-type interactions: the skyrme_rpa program', Comput. Phys. Commun. 184, 142 (2013); posts/refs/skyrme-hartree-fock-of-oxygen-16.out
- verified Skyrme Hartree-Fock of oxygen-16
A nucleus is up to a few hundred protons and neutrons (sixteen here) held together by the strong force, which has no simple closed form.
Replaces disputed d8dbb5d20d30.
Wikipedia, 'Oganesson': 'Its only known isotope, oganesson-294'; highest atomic mass of all known elements, https://en.wikipedia.org/wiki/Oganesson; Vautherin and Brink, PRC 5, 626 (1972), treats 16O through 208Pb
- verified Skyrme Hartree-Fock of oxygen-16
Nuclear density functional theory replaces it with an energy that depends only on a few local densities: the number density of neutrons () and protons (), their kinetic-energy densities , and their spin-orbit densities .
For even-even nuclei the Skyrme functional depends on rho_q, tau_q, J_q (and gradients of rho_q), as described.
K. Bennaceur and J. Dobaczewski, 'Coordinate-space solution of the Skyrme-Hartree-Fock-Bogolyubov equations within spherical symmetry. The program HFBRAD (v1.00)', Comput. Phys. Commun. 168, 96 (2005), arXiv:nucl-th/0501002, eqs. (5)-(8), (13)-(15) and the Skyrme energy functional (ESkyrme)
- verified Skyrme Hartree-Fock of oxygen-16
Skyrme's functional is the oldest of these, with about ten parameters fitted to nuclear data.
Skyrme's 1959 interaction predates the Gogny force and relativistic mean-field models; standard parameterizations such as SLy5 have about ten parameters.
Memoir of D. M. Brink, arXiv:2301.02907: Skyrme proposed his short-range effective interaction in 1959; Vautherin and Brink (PRC 5, 626 (1972)) made it the basis of HF calculations; K. Bennaceur and J. Dobaczewski, 'Coordinate-space solution of the Skyrme-Hartree-Fock-Bogolyubov equations within spherical symmetry. The program HFBRAD (v1.00)', Comput. Phys. Commun. 168, 96 (2005), arXiv:nucl-th/0501002, Skyrme energy functional (t0-t3, x0-x3, W0, gamma)
- verified Skyrme Hartree-Fock of oxygen-16
Minimizing the energy gives each nucleon a Schrödinger equation (the second equation above) with a position-dependent effective mass , a central potential and a spin-orbit field , all computed from the densities.
Varying the Skyrme energy gives a Schrodinger-like equation with hbar^2/2m*(r), central field U and spin-orbit form factor built from the densities.
K. Bennaceur and J. Dobaczewski, 'Coordinate-space solution of the Skyrme-Hartree-Fock-Bogolyubov equations within spherical symmetry. The program HFBRAD (v1.00)', Comput. Phys. Commun. 168, 96 (2005), arXiv:nucl-th/0501002, eq. (33); Vautherin and Brink, PRC 5, 626 (1972)
- not-checkable Skyrme Hartree-Fock of oxygen-16
That output file is the published reference here.
Describes this post's reference.
- verified Skyrme Hartree-Fock of oxygen-16
Each orbital is , and on a mesh , , the radial equation for is a symmetric tridiagonal matrix:
A three-point discretization of -d/dr B du/dr with B at half points plus a diagonal potential gives a symmetric tridiagonal matrix.
K. Bennaceur and J. Dobaczewski, 'Coordinate-space solution of the Skyrme-Hartree-Fock-Bogolyubov equations within spherical symmetry. The program HFBRAD (v1.00)', Comput. Phys. Commun. 168, 96 (2005), arXiv:nucl-th/0501002, eqs. (13)-(15) (orbitals as u(nlj,r)/r times spin-angular factor); Wikipedia, 'Finite difference', sec. Higher-order differences: f''(x) ~ [f(x+h) - 2f(x) + f(x-h)]/h^2, https://en.wikipedia.org/wiki/Finite_difference
- verified Skyrme Hartree-Fock of oxygen-16
HFBRAD's radial equation has -d/dr M d/dr + M l(l+1)/r^2 + M'/r + U + B[j(j+1)-l(l+1)-3/4]/(2r); with <sigma.l> = j(j+1)-l(l+1)-3/4 and W = B/2 (Vautherin-Brink convention) this is the post's equation, plus Coulomb for protons.
K. Bennaceur and J. Dobaczewski, 'Coordinate-space solution of the Skyrme-Hartree-Fock-Bogolyubov equations within spherical symmetry. The program HFBRAD (v1.00)', Comput. Phys. Commun. 168, 96 (2005), arXiv:nucl-th/0501002, eqs. (32)-(33); Vautherin and Brink, PRC 5, 626 (1972)
- plausible Skyrme Hartree-Fock of oxygen-16
The first term uses at the half points, which keeps the matrix symmetric; the term comes from writing the equation for rather than .
Not accessed; from general knowledge. Rewriting -(1/r^2)(r^2 B phi')' with phi=u/r gives -(Bu')' + (B'/r)u, and half-point B gives a symmetric three-point matrix, so the sentence checks by direct algebra.
Vautherin and Brink, Phys. Rev. C 5, 626 (1972) (not accessed)
- plausible Skyrme Hartree-Fock of oxygen-16
On the first pass the eigenvalue itself is found first, by bisection on the Sturm count (the number of negative pivots of is the number of eigenvalues below ), so the iteration starts on the right state.
Not accessed; from general knowledge. The count of negative pivots of the LDL^T factorization of H - x equals the number of eigenvalues below x by Sylvester's law of inertia.
Golub and Van Loan, Matrix Computations, Sturm-sequence bisection for symmetric tridiagonal matrices (not accessed)
- not-checkable Skyrme Hartree-Fock of oxygen-16
Derivatives of the densities are centered differences with second-order one-sided ones at the ends, and integrals are trapezoidal.
Describes this program's discretization.
- not-checkable Skyrme Hartree-Fock of oxygen-16
The protons also feel the Coulomb field of their own density, with exchange in the Slater approximation.
Describes this program's Coulomb treatment; the reference script uses the same Slater exchange.
posts/refs/skyrme-hartree-fock-of-oxygen-16.py header: 'Coulomb exchange in the Slater approximation'
- not-checkable Skyrme Hartree-Fock of oxygen-16
On both meshes the energy per nucleon, the three radii and the six orbital energies match the numpy twin to ; the tests allow .
Program agreement with its numpy twin; tested (twin_diff under 7e-9).
- verified Skyrme Hartree-Fock of oxygen-16
Going from to fm moves the energy per nucleon by 0.016 MeV and the charge radius by 0.002 fm.
From the reference output, E/A moves from -8.04654 to -8.03037 MeV (0.0162) and r_ch from 2.79668 to 2.79861 fm (0.0019).
posts/refs/skyrme-hartree-fock-of-oxygen-16.out and .py header (skyrme_rpa rerun at 0.05 fm: E/A = -8.0259916)
- verified Skyrme Hartree-Fock of oxygen-16
The extrapolated binding energy is MeV per nucleon, against skyrme_rpa's : the two differ by MeV per nucleon, 18 keV out of 128 MeV. skyrme_rpa's own answer moves by MeV per nucleon between its 0.1 fm and 0.05 fm meshes (the reference script records the rerun), so most of the remaining difference is between the two programs' formulas, not their meshes.
Difference 1.13e-3 MeV x 16 = 18 keV; skyrme_rpa's rerun at 0.05 fm gives -8.0259916 vs -8.0261107 at 0.1 fm, a change of 1.2e-4, as stated.
posts/refs/skyrme-hartree-fock-of-oxygen-16.out and .py header (skyrme_rpa rerun at 0.05 fm: E/A = -8.0259916)
- verified Skyrme Hartree-Fock of oxygen-16
On the 0.1 fm mesh alone, this program's second-order scheme is off by 0.02 MeV per nucleon, which is why it extrapolates.
On the 0.1 fm mesh E/A = -8.04654 vs skyrme_rpa's -8.02611, a difference of 0.020 MeV.
posts/refs/skyrme-hartree-fock-of-oxygen-16.out and .py header (skyrme_rpa rerun at 0.05 fm: E/A = -8.0259916)
- verified A gyro-orbit and the E×B drift by the Boris push
The Boris push moves a charged particle through electric and magnetic fields in almost every particle-in-cell code.
Qin et al.: the Boris algorithm 'is the de facto standard for advancing a charged particle' and has been used in plasma simulation for over forty years.
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- verified A gyro-orbit and the E×B drift by the Boris push
With an electric field added, a particle started at moves at exactly that velocity forever, and any other start averages to it.
From Eqs. (5)-(7), v -> R(v + a) + a, and R(v_E + a) = v_E - a, so v_E is a fixed point and v - v_E is only rotated, which averages out. Checked algebraically; 'exactly' holds up to rounding.
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- verified A gyro-orbit and the E×B drift by the Boris push
A charged particle in a uniform magnetic field circles the field lines at the cyclotron frequency .
Qin et al. give the gyro-frequency as qB0/mc in Gaussian units, which is qB/m in SI.
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- verified A gyro-orbit and the E×B drift by the Boris push
This circling is gyration, and its circle is the gyro-orbit.
Qin et al. call the circular motion gyromotion at the gyro-frequency and show it as a circle of constant radius; 'gyro-orbit' is standard terminology.
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- verified A gyro-orbit and the E×B drift by the Boris push
The Boris push (J. P. Boris, 1970) is the standard choice.
Qin et al.: 'the Boris algorithm is the de facto standard for advancing a charged particle'; ref. [1] is J. Boris, Proc. 4th Conf. Num. Sim. Plasmas (NRL, 1970), p. 3.
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- not-checkable A gyro-orbit and the E×B drift by the Boris push
posts/refs/boris_push.pycomputes the same numbers with a separate numpy implementation.Describes the post's reference script.
- verified A gyro-orbit and the E×B drift by the Boris push
The positions are updated with the new velocity, .
Qin et al. Eq. (3): (x_{k+1} - x_k)/dt = v_{k+1}.
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- verified A gyro-orbit and the E×B drift by the Boris push
Eq. (6) of Qin et al. is a Cayley rotation with tan(theta/2) = omega_c dt/2, so the period ratio is omega_c dt/(2 arctan(omega_c dt/2)); expanding arctan gives 1 + (omega_c dt)^2/12 + O(dt^4) (checked with mpmath).
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- verified A gyro-orbit and the E×B drift by the Boris push
At that is against .
mpmath: 2 pi (0.05)/(2 arctan 0.025) = 6.284494, and 2 pi = 6.283185.
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- verified A gyro-orbit and the E×B drift by the Boris push
At the term shows: the error is , below .
mpmath: 0.4/(2 arctan 0.2) - 1 = 1.31940e-2, below 0.4^2/12 = 1.33333e-2.
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- verified A gyro-orbit and the E×B drift by the Boris push
The drift velocity is .
With E = 0.1 x-hat and B = z-hat, E x B / B^2 = 0.1 (x-hat x z-hat) = (0, -0.1).
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- verified A gyro-orbit and the E×B drift by the Boris push
The vector is turned by into , because its half-angle from is .
a = E dt/2 = (0.0025, 0); the Cayley rotation turns by theta = 2 arctan(dt/2) clockwise for q > 0, taking the vector at half-angle arctan(0.025) on one side of -y-hat to the mirror point (-0.0025, -0.1). Checked by hand.
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- verified A gyro-orbit and the E×B drift by the Boris push
For any other start, is only rotated, so the particle gyrates about a guiding center moving at .
From v -> R(v + a) + a and R(v_E + a) = v_E - a, it follows that v - v_E -> R(v - v_E); checked algebraically.
H. Qin et al., 'Why is Boris algorithm so good?', Phys. Plasmas 20, 084503 (2013), Eqs. (3)-(7), https://bp-pub.pppl.gov/pub_report//2013/PPPL-4872.pdf
- not-checkable The error of a linear solve follows the condition number
Gaussian elimination with partial pivoting solves Hilbert systems whose exact solution is all ones.
Describes what this program does.
- not-checkable The error of a linear solve follows the condition number
Every computed answer here is compared with an exact one.
Describes this post's testing.
- not-checkable The error of a linear solve follows the condition number
The Hilbert systems are scaled to have integer entries, so the system stored in the computer is the exact system and its solution is exactly all ones; the Python reference confirms it by solving in rational arithmetic with
fractions.Describes this program and its reference script.
- not-checkable The error of a linear solve follows the condition number
The exact condition numbers come from mpmath at 80 digits, and numpy's
linalg.condagrees with them to through .Describes the reference script; its output prints numpy cond against mpmath at most 2.8e-6 off through n = 10.
- verified The error of a linear solve follows the condition number
The condition number , the ratio of the largest to the smallest singular value, bounds how much a relative change in or can change the solution of : by up to times as much.
Higham: forward error <~ condition number x backward error; kappa_2 = sigma_max/sigma_min for Ax = b. The bound is a first-order worst case, as 'up to' says.
N. J. Higham, 'What Is Backward Error?', https://nhigham.com/2020/03/25/what-is-backward-error/; Numerical Linear Algebra: Least Squares, QR and SVD, arXiv:2412.19960, Secs. 1.3, 3.1, 3.5
- verified The error of a linear solve follows the condition number
A method is backward stable if its answer is the exact solution of a nearby system, one whose data differ from and by a few relative.
Matches Higham's definition of backward error as the smallest relative data perturbation making the computed answer exact; backward stable means that is O(eps).
N. J. Higham, 'What Is Backward Error?', https://nhigham.com/2020/03/25/what-is-backward-error/
- verified The error of a linear solve follows the condition number
Its residual is then a few relative to , and its error is about .
Small backward error gives small relative residual, and forward error <~ kappa x backward error; 'about kappa eps' is an upper-bound estimate, which the post's measured 0.005 to 0.18 kappa eps shows.
N. J. Higham, 'What Is Backward Error?', https://nhigham.com/2020/03/25/what-is-backward-error/
- verified The error of a linear solve follows the condition number
Gaussian elimination with partial pivoting (GEPP) behaves this way in practice.
Higham: GEPP's backward error is proportional to the growth factor, which 'is usually of modest size in practice'.
N. J. Higham, 'What Is the Growth Factor for Gaussian Elimination?', https://nhigham.com/2020/07/14/what-is-the-growth-factor-for-gaussian-elimination/
- verified The error of a linear solve follows the condition number
So a small residual says the method did its job, and it says nothing about the error when is large.
Since forward error <~ kappa x backward error, a small residual (small backward error) bounds the error only up to a factor kappa.
N. J. Higham, 'What Is Backward Error?', https://nhigham.com/2020/03/25/what-is-backward-error/
- verified The error of a linear solve follows the condition number
The Hilbert matrix is the standard ill-conditioned example; grows about 32 times with each row added.
kappa grows asymptotically like e^{3.5255n}, about 34x per row; from 524 (n = 3) to 1.71e16 (n = 12) the geometric mean is 31.7x per row, tested.
Hilbert matrix, https://en.wikipedia.org/wiki/Hilbert_matrix (pointer; kappa ~ e^{3.5255 n}/sqrt(n), (1+sqrt2)^4 = 33.97); posts/refs/the-error-follows-the-condition-number.out
- verified The error of a linear solve follows the condition number
Multiplying by makes every entry an integer below , stored exactly, with the same .
Entries are 1/(i+j+1) with i+j+1 in 1..2n-1, so L makes them integers; lcm(1..23) = 5354228880 < 2^53 = 9.0e15, and scaling by a constant leaves kappa unchanged.
posts/refs/the-error-follows-the-condition-number.out; Hilbert matrix, https://en.wikipedia.org/wiki/Hilbert_matrix (pointer; kappa ~ e^{3.5255 n}/sqrt(n), (1+sqrt2)^4 = 33.97)
- verified The error of a linear solve follows the condition number
The right side is a sum of integers, also exact.
Row sums of at most 12 integers each below 5.4e9 stay far below 2^53, so they are exact in double precision.
posts/refs/the-error-follows-the-condition-number.out
- not-checkable The error of a linear solve follows the condition number
The condition number has to be computed too, and it runs into the same limit.
Transition.
- plausible The error of a linear solve follows the condition number
eig_symfinds the smallest eigenvalue to within about times the largest, so comes out with a relative error below : at and 4.4% at , where numpy'scondis off by 1.6%.Not accessed; from general knowledge: a backward-stable symmetric eigensolver gives eigenvalues with absolute error ~ eps*||H|| (Weyl), so kappa's relative error is ~ kappa eps. The reference output confirms numpy cond is 1.57% off at n = 12.
posts/refs/the-error-follows-the-condition-number.out
- verified The error of a linear solve follows the condition number
A least-squares fit asks for the that minimizes for a tall matrix .
Standard definition of the linear least-squares problem for a tall matrix.
Numerical Linear Algebra: Least Squares, QR and SVD, arXiv:2412.19960, Secs. 1.3, 3.1, 3.5
- verified The error of a linear solve follows the condition number
The normal equations are the textbook route: a square system, solved here with the same elimination.
Sec. 1.3 introduces the normal equations A^T A x = A^T b as the classical route.
Numerical Linear Algebra: Least Squares, QR and SVD, arXiv:2412.19960, Secs. 1.3, 3.1, 3.5
- verified The error of a linear solve follows the condition number
But , so the error is about .
Sec. 1.3: cond2(A^T A) = cond2(A)^2; the reference output shows NE errors of 0.002 to 0.27 kappa^2 eps.
Numerical Linear Algebra: Least Squares, QR and SVD, arXiv:2412.19960, Secs. 1.3, 3.1, 3.5
- verified The error of a linear solve follows the condition number
Householder QR multiplies by reflections , each of which zeroes one column below the diagonal, until is upper triangular, .
Sec. 3.1: H = I - 2uu^T/u^Tu maps a vector to a multiple of e_1, zeroing entries below the first; applied column by column it produces R.
Numerical Linear Algebra: Least Squares, QR and SVD, arXiv:2412.19960, Secs. 1.3, 3.1, 3.5
- verified The error of a linear solve follows the condition number
Reflections are orthogonal and change no lengths, so the problem becomes with , and the error is about .
Householder QR is backward stable (Sec. 3.5, Wilkinson), and for this consistent (zero-residual) problem the error is about kappa eps; strictly the system is R c = (first n rows of Q^T y).
Numerical Linear Algebra: Least Squares, QR and SVD, arXiv:2412.19960, Secs. 1.3, 3.1, 3.5; posts/refs/the-error-follows-the-condition-number.out
- not-checkable The error of a linear solve follows the condition number
The data are rounded when they are formed, which moves the exact least-squares answer of the stored problem slightly away from all ones.
Describes this program's data; the reference output lists the exact-LS offset.
posts/refs/the-error-follows-the-condition-number.out
- not-checkable The error of a linear solve follows the condition number
The singular values for come from one-sided Jacobi (
lib/svd).Describes which library routine the program uses.
- not-checkable A star of free neutrons can weigh at most 0.71 suns
Hold a ball of neutrons up by their Fermi pressure alone, with gravity from general relativity, and solve for the star at each central density.
Describes what the post computes.
- verified A star of free neutrons can weigh at most 0.71 suns
A scipy twin written in different variables gets , and Narain, Schaffner-Bielich and Mishustin (2006) quote .
Narain et al.: 'a neutron star with mf = mn = 939.6 MeV in eq. (31) and eq. (32), has the maximum mass Mmax = 0.710 M_sun'.
G. Narain, J. Schaffner-Bielich, I. N. Mishustin, Phys. Rev. D 74, 063003 (2006), arXiv:astro-ph/0605724, Eqs. (30)-(32) and following text
- not-checkable A star of free neutrons can weigh at most 0.71 suns
The reference, in
posts/refs/the-free-neutron-star-limit.py, integrates the same physics a different way: in cgs units, with the radius as the independent variable and the Fermi momentum as the unknown, by scipy's DOP853 at a relative tolerance of , and finds the maximum withminimize_scalar.Describes the reference script.
- verified A star of free neutrons can weigh at most 0.71 suns
The literature value is from G. Narain, J. Schaffner-Bielich and I. N. Mishustin, "Compact stars made of fermionic dark matter", Phys. Rev. D 74, 063003 (2006), arXiv:astro-ph/0605724: from their Eqs. (31) and (32), a star of free neutrons has "the maximum mass at a radius of km, which match very well the original results of Oppenheimer and Volkoff" (Phys. Rev. 55, 374, 1939).
Quote matches the paper text verbatim, including Eqs. (31) and (32), 9.192 km, and the reference to Oppenheimer and Volkoff.
G. Narain, J. Schaffner-Bielich, I. N. Mishustin, Phys. Rev. D 74, 063003 (2006), arXiv:astro-ph/0605724, Eqs. (30)-(32) and following text
- not-checkable A star of free neutrons can weigh at most 0.71 suns
The program takes 400 steps per star, and its maximum agrees with scipy's to of a solar mass; the tests allow , relative.
Describes this program's step count and test tolerance.
- verified A star of free neutrons can weigh at most 0.71 suns
A neutron star is held up by the pressure of its neutrons.
Silbar and Reddy: degeneracy pressure (with nuclear interactions for realistic stars) supports the star against gravity.
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- verified A star of free neutrons can weigh at most 0.71 suns
Neutrons are fermions: no two can share a state, so packing them tighter forces them into states of higher momentum, and that momentum pushes outward even at zero temperature.
Silbar and Reddy lines on the Pauli principle: degeneracy pressure stabilizes cold (T = 0) stars against gravity.
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- verified A star of free neutrons can weigh at most 0.71 suns
In 1939 Oppenheimer and Volkoff asked how heavy a star held up this way alone can be, ignoring the nuclear force between the neutrons.
Silbar and Reddy: the non-interacting Fermi gas EoS reproduces 'the results of Oppenheimer and Volkov' (Phys. Rev. 55, 374 (1939)) for pure neutron stars.
G. Narain, J. Schaffner-Bielich, I. N. Mishustin, Phys. Rev. D 74, 063003 (2006), arXiv:astro-ph/0605724, Eqs. (30)-(32) and following text; R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- verified A star of free neutrons can weigh at most 0.71 suns
In general relativity pressure is itself a source of gravity, so a star that squeezes its center harder to push back also pulls harder, and past some central density the extra pull wins.
The TOV equation in Silbar and Reddy has the factors (1 + p/eps) and (1 + 4 pi r^3 p/Mc^2): pressure adds to the gravitational pull.
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- verified A star of free neutrons can weigh at most 0.71 suns
A cold gas of free neutrons is described by one number, the Fermi momentum , written as .
Silbar and Reddy Eqs. (10) and (14) give eps and p as functions of x = k_F/mc alone.
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- not-checkable A star of free neutrons can weigh at most 0.71 suns
The energy density (including the neutrons' rest mass) and the pressure are
Lead-in to the formula that follows.
- verified A star of free neutrons can weigh at most 0.71 suns
Silbar and Reddy Eqs. (10) and (14) have eps0'/8 [...] and eps0'/24 [...] with eps0' = m^4c^5/(pi^2 hbar^3); with eps0 = eps0'/8 these are the post's formulas.
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- verified A star of free neutrons can weigh at most 0.71 suns
The first two terms of the pressure's series at small x, (8/15)·x⁵·(1 − (5/14)·x²), in units of ε₀.
sympy series of Silbar-Reddy's P (Eq. 14, rescaled): 8x^5/15 - 4x^7/21 = (8/15)x^5(1 - (5/14)x^2).
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- verified A star of free neutrons can weigh at most 0.71 suns
For free neutrons , so and the equation of state needs no inverting.
The T = 0 chemical potential d eps/dn (Silbar-Reddy Eq. 13) of a free Fermi gas is sqrt(p_F^2c^2 + m^2c^4) = mc^2 sqrt(1+x^2); inverting h = ln(mu/mc^2) gives x = sqrt(e^{2h}-1).
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- plausible A star of free neutrons can weigh at most 0.71 suns
The surface, where the pressure is zero, is exactly, so every star is integrated over a known interval, from at the center to 0; the equations are the two at the top of the page (Lindblom, ApJ 398, 569, 1992).
Only the abstract was read; the enthalpy form of the structure equations in that paper is from general knowledge. P = 0 at x = 0 gives h = 0 exactly.
L. Lindblom, ApJ 398, 569 (1992), https://ui.adsabs.harvard.edu/abs/1992ApJ...398..569L/abstract (abstract only)
- verified A star of free neutrons can weigh at most 0.71 suns
Near the center grows like , and near the surface the density falls like ; a fixed-step method follows neither well.
From TOV near the center, h_c - h ~ r^2 so r ~ sqrt(h_c - h); near the surface x ~ sqrt(2h), so n ~ x^3 ~ h^{3/2}. Derived by hand from the equations in the source.
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- verified A star of free neutrons can weigh at most 0.71 suns
Near the center that makes a straight line in , , and near the surface , so and the density is a polynomial in there too.
With m ~ (4pi/3) eps_c r^3, dh/dr ~ -(4pi/3)(eps_c + 3P_c) r gives h_c - h = (2pi/3)(eps_c+3P_c) r^2; near t = 1, h_c - h = h_c (1 - (1-t)^2)^2 gives h ~ 2h_c(1-t)^2. Derived by hand.
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- not-checkable A star of free neutrons can weigh at most 0.71 suns
With 400 steps a star's radius and mass agree with the scipy twin to about , the digits the twin was recorded to; with 100 steps, to .
Program agreement with its scipy twin; tested (3.3e-7 at 400 steps, 3.3e-5 at 100).
- not-checkable A star of free neutrons can weigh at most 0.71 suns
Each central density gives one star.
Narration of the program's sequence of stars.
- not-checkable A star of free neutrons can weigh at most 0.71 suns
Somewhere in between the mass passed through a maximum.
Narration of the computed sequence.
- verified A star of free neutrons can weigh at most 0.71 suns
Narain, Schaffner-Bielich and Mishustin (2006) quote 9.192 km for the radius, 0.3% larger than both this program and the scipy twin; their number comes from a scaling formula (their Eq. (32)) whose coefficient, 3.367, they give to four digits.
Eq. (32): R_min = 8.115 km (1 GeV/m_f)^2, from R'_min = 3.367 stated before Eq. (31); for m_f = 939.6 MeV they give R_min = 9.192 km. 9.192/9.1615 = 1.0033, 0.3% larger.
G. Narain, J. Schaffner-Bielich, I. N. Mishustin, Phys. Rev. D 74, 063003 (2006), arXiv:astro-ph/0605724, Eqs. (30)-(32) and the text after them (read in this session); posts/refs/the-free-neutron-star-limit.out
- verified A star of free neutrons can weigh at most 0.71 suns
Along the sequence, the stars to the right of the peak (larger, lighter, less dense) are stable: add a little mass and the star settles slightly smaller.
Silbar and Reddy Fig. 6: 'The stars to the right of the maximum are stable'; along that branch higher mass goes with smaller radius.
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- verified A star of free neutrons can weigh at most 0.71 suns
The stars to its left are not, and a small squeeze makes them collapse.
Silbar and Reddy: stars 'to the left of the maximum ... are unstable against gravitational collapse'.
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- plausible A star of free neutrons can weigh at most 0.71 suns
Heavier neutron stars need the force between neutrons, which this model leaves out, to be repulsive at these densities.
Silbar and Reddy (Sec. 5-6) show that adding nucleon interactions raises the maximum mass above the free-gas value; that the needed interaction is repulsive at these densities is from general knowledge, not a passage read.
R. R. Silbar and S. Reddy, 'Neutron stars for undergraduates', Am. J. Phys. 72, 892 (2004), arXiv:nucl-th/0309041, Eqs. (10), (14), TOV eq. and Fig. 6
- verified The two-pion loop function, built and differentiated by a small computer algebra system
Both are checked against a 30-digit Feynman-parameter integral that never uses the closed form: and /MeV there, to and /MeV.
mpmath from Eq. (4.11) with m_pi = 138.039 gives L(200) = 1.1464228856496 and dL/dq = 1.240751064e-3/MeV, matching the reference's Feynman-parameter values.
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12); posts/refs/the-pion-loop-function-by-computer-algebra.out
- verified The two-pion loop function, built and differentiated by a small computer algebra system
In chiral effective field theory the force between two nucleons is a sum of pion exchanges and short-range contact terms.
Replaces disputed 6d24d0bbae07.
Machleidt and Entem, Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Sec. 3.2 (read from the PDF): at LO 'the NN amplitude is made up by two momentum-independent contact terms ... and static one-pion exchange'; Sec. 4.1 pion exchanges, Sec. 4.3 NN contact terms
- verified The two-pion loop function, built and differentiated by a small computer algebra system
At next-to-leading order the exchange of two pions enters through one function of the momentum transfer ,
Eqs. (4.9)-(4.10): at NLO W_C, V_T and V_S are all proportional to L(q).
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12)
- verified The two-pion loop function, built and differentiated by a small computer algebra system
Eqs. (4.11)-(4.12): L(q) = (w/q) ln((w+q)/(2m_pi)), w = sqrt(4m_pi^2 + q^2).
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12)
- verified The two-pion loop function, built and differentiated by a small computer algebra system
which multiplies the central, tensor and spin-spin parts of the potential (Machleidt and Entem, Phys. Rep. 503, 1 (2011), Eqs. (4.9)-(4.12), with their average pion mass MeV).
L(q) multiplies W_C (isovector central), V_T and V_S = -q^2 V_T in Eqs. (4.9)-(4.10); the review uses the average pion mass m_pi = 138.039 MeV (Sec. 4.2).
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12)
- plausible The two-pion loop function, built and differentiated by a small computer algebra system
Higher orders need many such functions and their derivatives, which is the job of a computer algebra system.
At N2LO the review introduces the additional loop function A(q), and higher orders bring more; calling this 'the job of a computer algebra system' is a judgment, not a checkable fact.
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12)
- not-checkable The two-pion loop function, built and differentiated by a small computer algebra system
Nothing simplifies the result, so the derivative tape does more arithmetic than a hand-written derivative would, but it is exact.
Describes this program's differentiator.
- plausible The two-pion loop function, built and differentiated by a small computer algebra system
The reference evaluates at eight momenta from its integral representation, which comes from the loop diagram itself, not from the closed form.
Not accessed; from general knowledge. The Feynman-parameter form 1 + (1/2) int_0^1 ln(1 + x(1-x)q^2/m_pi^2) dx equals Eq. (4.11) to 30 digits in mpmath, but no source deriving it from the diagram was read.
posts/refs/the-pion-loop-function-by-computer-algebra.out
- verified The two-pion loop function, built and differentiated by a small computer algebra system
The tape agrees at every one to , from MeV, where , to 1 GeV.
At q = 1 MeV, mpmath from Eq. (4.11) gives L - 1 = 4.373e-6.
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12); posts/refs/the-pion-loop-function-by-computer-algebra.out
- verified The two-pion loop function, built and differentiated by a small computer algebra system
At small the logarithm in the integral expands, and with and , ,
int_0^1 x(1-x) dx = 1/6 and int_0^1 x^2(1-x)^2 dx = 1/30 are exact; combined with the representation they give the series below.
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12)
- verified The two-pion loop function, built and differentiated by a small computer algebra system
sympy series of Eq. (4.11) in units m_pi = 1: 1 + q^2/12 - q^4/120 + O(q^6).
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12)
- verified The two-pion loop function, built and differentiated by a small computer algebra system
At MeV, , and the tape matches the two terms to .
t = (1/138.039)^2, t^2/120 = 2.30e-11.
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12)
- plausible The two-pion loop function, built and differentiated by a small computer algebra system
A third representation is the dispersion integral: has an imaginary part above the two-pion threshold , and
Not accessed; from general knowledge. L(q) as a function of q^2 has a cut from -4m_pi^2 (the two-pion threshold mu = 2m_pi); the dispersion integral below equals Eq. (4.11) to 30 digits in mpmath at q = 200 MeV.
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12)
- plausible The two-pion loop function, built and differentiated by a small computer algebra system
Not accessed; from general knowledge. mpmath evaluation of this integral at q = 200 MeV reproduces Eq. (4.11) to 30 digits.
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12)
- not-checkable The two-pion loop function, built and differentiated by a small computer algebra system
The derivative tape, evaluated at three momenta, matches mpmath's numerical derivative of the Feynman-parameter integral to per MeV, rounding in a number of about 0.001.
Program result; tested (dL_tape_err 1.7e-17 under 2e-17; dL/dq is about 1.24e-3 per MeV).
- plausible The two-pion loop function, built and differentiated by a small computer algebra system
A central difference on the tape with a step of 1 MeV is off by up to , which is the error of that step; the symbolic derivative has no step to choose.
Not accessed; from general knowledge that the central difference error is h^2 f'''/6; mpmath gives L'''/6 = -5.3e-9/MeV^3 at q = 200 MeV, so 5e-9 at h = 1 MeV is consistent.
R. Machleidt and D. R. Entem, 'Chiral effective field theory and nuclear forces', Phys. Rep. 503, 1 (2011), arXiv:1105.2919, Eqs. (4.9)-(4.12)
- not-checkable Tunneling through one and two barriers by transfer matrices
An electron meets a barrier it does not have the energy to climb.
Scene-setting for the tunneling problem; no claim to check.
- not-checkable Tunneling through one and two barriers by transfer matrices
The reference,
posts/refs/transfer-matrices-and-resonant-tunneling.py, does not multiply transfer matrices.Describes the post's reference script; confirmed by reading posts/refs/transfer-matrices-and-resonant-tunneling.py (it uses np.linalg.solve on the full system).
- not-checkable Tunneling through one and two barriers by transfer matrices
It writes every matching condition of the whole potential as one linear system and solves it with
numpy.linalg.solve, and it finds the resonances withscipy.optimize.Describes the reference script; the file imports scipy.optimize (minimize_scalar, brentq) and calls np.linalg.solve, as stated.
- not-checkable Tunneling through one and two barriers by transfer matrices
The single barrier is also checked against its textbook closed form.
Describes the reference script, which implements the sinh closed form at line 70.
- verified Tunneling through one and two barriers by transfer matrices
Where the potential is flat, the time-independent Schrödinger equation has two solutions, a wave moving right and one moving left:
In units hbar=m=1 the flat-region solutions are e^{+ikx} and e^{-ikx} with k=sqrt(2(E-V)), the standard free-particle solutions.
Wikipedia, 'Rectangular potential barrier', transmission coefficient for E<V0 and E>V0 (pointer to Griffiths, Intro to QM, Problem 2.33), https://en.wikipedia.org/wiki/Rectangular_potential_barrier
- verified Tunneling through one and two barriers by transfer matrices
Standard plane-wave form with k=sqrt(2m(E-V))/hbar, here with hbar=m=1.
Wikipedia, 'Rectangular potential barrier', transmission coefficient for E<V0 and E>V0 (pointer to Griffiths, Intro to QM, Problem 2.33), https://en.wikipedia.org/wiki/Rectangular_potential_barrier
- verified Tunneling through one and two barriers by transfer matrices
When the square root is imaginary, , and the two waves become a decaying and a growing exponential.
Liss, p. 7-4: for E < V0, kappa^2 = 2m(V0-E)/hbar^2 is real and psi = A e^{-kappa x} + B e^{kappa x} inside the barrier.
T. M. Liss, Physics 486 Lecture 7, The step potential and the square barrier (U. Illinois, 2009), pp. 7-2 to 7-6, https://courses.physics.illinois.edu/phys487/sp2010/486Lectures/lect07.pdf
- verified Tunneling through one and two barriers by transfer matrices
That is tunneling: the wave does not stop at the wall, it fades inside it.
Liss, p. 7-6: inside the barrier the wave is a sum of real exponentials, and the transmission is nonzero for E < V0; 'This is tunneling'.
T. M. Liss, Physics 486 Lecture 7, The step potential and the square barrier (U. Illinois, 2009), pp. 7-2 to 7-6, https://courses.physics.illinois.edu/phys487/sp2010/486Lectures/lect07.pdf
- verified Tunneling through one and two barriers by transfer matrices
At an edge where jumps, and must be continuous.
Liss, p. 7-2: the boundary conditions are 'the continuity of the wave function and its first derivative' at a finite step.
T. M. Liss, Physics 486 Lecture 7, The step potential and the square barrier (U. Illinois, 2009), pp. 7-2 to 7-6, https://courses.physics.illinois.edu/phys487/sp2010/486Lectures/lect07.pdf
- plausible Tunneling through one and two barriers by transfer matrices
The whole potential is the product of these matrices, one matrix .
Composing interface and propagation matrices is the standard transfer-matrix method; not accessed in a textbook section; from general knowledge plus the Tsu-Esaki setup.
R. Tsu and L. Esaki, 'Tunneling in a finite superlattice', Appl. Phys. Lett. 22, 562 (1973); L. L. Chang, L. Esaki, R. Tsu, 'Resonant tunneling in semiconductor double barriers', Appl. Phys. Lett. 24, 593 (1974)
- verified Tunneling through one and two barriers by transfer matrices
Far to the left the wave is the incoming one plus a reflected one, .
Incident plus reflected wave on the left, amplitudes (1, r), matches the standard scattering setup.
Wikipedia, 'Rectangular potential barrier', transmission coefficient for E<V0 and E>V0 (pointer to Griffiths, Intro to QM, Problem 2.33), https://en.wikipedia.org/wiki/Rectangular_potential_barrier
- verified Tunneling through one and two barriers by transfer matrices
Far to the right there is only the transmitted wave, .
Only a transmitted wave on the right, as in the standard scattering setup.
Wikipedia, 'Rectangular potential barrier', transmission coefficient for E<V0 and E>V0 (pointer to Griffiths, Intro to QM, Problem 2.33), https://en.wikipedia.org/wiki/Rectangular_potential_barrier
- verified Tunneling through one and two barriers by transfer matrices
So , and the second row gives , the first .
Both expressions follow directly from the two rows.
Algebra from the stated M(1,r)=(t,0): row 2 gives M21+M22 r=0, row 1 gives t=M11+M12 r=(M11M22-M12M21)/M22=det M/M22; checked by hand.
- verified Tunneling through one and two barriers by transfer matrices
With the same potential on both sides, the transmission probability is and the reflection probability .
Liss, p. 7-6: since the velocity factor is the same on both sides, the transmission coefficient is |D|^2; Wikipedia gives T = |t|^2 and R = |r|^2.
T. M. Liss, Physics 486 Lecture 7, The step potential and the square barrier (U. Illinois, 2009), pp. 7-2 to 7-6, https://courses.physics.illinois.edu/phys487/sp2010/486Lectures/lect07.pdf; Wikipedia, Rectangular potential barrier (pointer; cites Griffiths 2nd ed. and Cohen-Tannoudji pp. 231-233), https://en.wikipedia.org/wiki/Rectangular_potential_barrier
- verified Tunneling through one and two barriers by transfer matrices
For a single rectangular barrier the answer is known in closed form.
Liss derives the rectangular-barrier transmission in closed form.
T. M. Liss, Physics 486 Lecture 7, The step potential and the square barrier (U. Illinois, 2009), pp. 7-2 to 7-6, https://courses.physics.illinois.edu/phys487/sp2010/486Lectures/lect07.pdf; Wikipedia, Rectangular potential barrier (pointer; cites Griffiths 2nd ed. and Cohen-Tannoudji pp. 231-233), https://en.wikipedia.org/wiki/Rectangular_potential_barrier
- verified Tunneling through one and two barriers by transfer matrices
Below the top, with and width ,
kappa=sqrt(2(V0-E)) in hbar=m=1 units matches Wikipedia's k1; the formula that follows is the standard one.
Wikipedia, 'Rectangular potential barrier', transmission coefficient for E<V0 and E>V0 (pointer to Griffiths, Intro to QM, Problem 2.33), https://en.wikipedia.org/wiki/Rectangular_potential_barrier
- verified Tunneling through one and two barriers by transfer matrices
Liss's T = (2k kappa)^2/[(2k kappa)^2 + (k^2+kappa^2)^2 sinh^2] (barrier width 2a) reduces to this form with hbar = m = 1 and width a; Wikipedia states it directly.
T. M. Liss, Physics 486 Lecture 7, The step potential and the square barrier (U. Illinois, 2009), pp. 7-2 to 7-6, https://courses.physics.illinois.edu/phys487/sp2010/486Lectures/lect07.pdf; Wikipedia, Rectangular potential barrier (pointer; cites Griffiths 2nd ed. and Cohen-Tannoudji pp. 231-233), https://en.wikipedia.org/wiki/Rectangular_potential_barrier
- verified Tunneling through one and two barriers by transfer matrices
and above it becomes with and becomes .
Wikipedia gives T^{-1} = 1 + V0^2 sin^2(k1 a)/(4E(E-V0)) for E > V0; the same follows from Liss's formula with kappa = iq, since sinh(iqa) = i sin(qa).
Wikipedia, Rectangular potential barrier (pointer; cites Griffiths 2nd ed. and Cohen-Tannoudji pp. 231-233), https://en.wikipedia.org/wiki/Rectangular_potential_barrier; T. M. Liss, Physics 486 Lecture 7, The step potential and the square barrier (U. Illinois, 2009), pp. 7-2 to 7-6, https://courses.physics.illinois.edu/phys487/sp2010/486Lectures/lect07.pdf
- not-checkable Tunneling through one and two barriers by transfer matrices
Nothing in the matrix product enforces that; it comes out only if every matching condition is right.
Statement about what the program imposes; T+R=1 is checked as a consequence, not imposed.
- plausible Tunneling through one and two barriers by transfer matrices
With walls of finite height the particle can leak out, so these are not exact states, but near such an energy a wave that gets into the well reflects back and forth between the walls and adds up in phase.
Resonant tunneling through a double barrier occurs near the quasi-bound levels of the well, where multiple reflections add in phase (Tsu-Esaki/Chang-Esaki-Tsu); papers identified but not read in full.
R. Tsu and L. Esaki, 'Tunneling in a finite superlattice', Appl. Phys. Lett. 22, 562 (1973); L. L. Chang, L. Esaki, R. Tsu, 'Resonant tunneling in semiconductor double barriers', Appl. Phys. Lett. 24, 593 (1974)
- not-checkable Tunneling through one and two barriers by transfer matrices
A naive guess for two walls in a row is the product, .
A deliberately naive guess set up to be refuted; 0.0094 is the single wall's 0.936% (tested), and 0.0094^2 = 8.8e-5.
- not-checkable Tunneling through one and two barriers by transfer matrices
Then it finds the two energies around each peak where by bisection; their distance is the width of the resonance.
Describes the program's width measurement (full width at T=1/2).
- verified Tunneling through one and two barriers by transfer matrices
The two walls are identical, so the waves reflected by the far wall and leaking back through the near one cancel the near wall's own reflection exactly at resonance.
Blanter and Buttiker: resonant peaks come from interference between the barriers, and for a symmetric resonance (Gamma_L = Gamma_R) the peak transmission is 1.
Ya. M. Blanter and M. Buttiker, Shot Noise in Mesoscopic Conductors, Phys. Rep. 336, 1 (2000), sec. 'Resonant tunnel barriers', eqs. (74)-(75) and Fig. 8, https://arxiv.org/abs/cond-mat/9910158; Wikipedia, Resonant-tunneling diode (pointer; cites D. Bohm, Quantum Theory, 1951), https://en.wikipedia.org/wiki/Resonant-tunneling_diode
- verified Tunneling through one and two barriers by transfer matrices
The widths grow with the single-wall transmission: a leakier well holds the wave for a shorter time, and a shorter-lived state has a broader resonance.
Blanter and Buttiker: the partial widths are Gamma_{L,R} = hbar nu T_{L,R}, so the width grows with the single-barrier transmission, and Gamma is the decay width of the quasi-bound level (lifetime ~ hbar/Gamma).
Ya. M. Blanter and M. Buttiker, Shot Noise in Mesoscopic Conductors, Phys. Rep. 336, 1 (2000), sec. 'Resonant tunnel barriers', eqs. (74)-(75) and Fig. 8, https://arxiv.org/abs/cond-mat/9910158
- not-checkable Tunneling through one and two barriers by transfer matrices
The single wall is the dashed curve.
Describes the figure.
- verified The bounce period of an electron trapped in a plasma wave
In the frame of a large-amplitude plasma wave, an electron near the wave's phase velocity moves like a pendulum.
O'Neil's abstract describes the resonant electrons' exact motion in the wave (Jacobi elliptic functions), i.e. pendulum motion in the wave frame.
T. M. O'Neil, 'Collisionless damping of nonlinear plasma oscillations', Phys. Fluids 8, 2255 (1965), abstract https://ui.adsabs.harvard.edu/abs/1965PhFl....8.2255O/abstract
- verified The bounce period of an electron trapped in a plasma wave
Electrons with speed below at the trough stay in it; faster ones pass over the crests.
Speed below 2 omega_B/k at the trough keeps the electron trapped; the pendulum separatrix gives the same threshold.
Energy conservation E=v^2/2-phi0 cos x in the wave frame, separatrix at E=phi0 gives v0=2 sqrt(phi0)=2 omega_B (k=1); checked by hand; Wikipedia, 'Pendulum (mechanics)', large-amplitude period T=(2T0/pi)K(sin(theta0/2)) and series 1+theta0^2/16+11theta0^4/3072, https://en.wikipedia.org/wiki/Pendulum_(mechanics)
- plausible The bounce period of an electron trapped in a plasma wave
Landau damping is the linear theory of a wave losing energy to the electrons that move at nearly its phase velocity.
O'Neil's abstract calls Landau's result the linear theory of collisionless damping; the phase-velocity resonance is standard (not accessed beyond the abstract).
T. M. O'Neil, 'Collisionless damping of nonlinear plasma oscillations', Phys. Fluids 8, 2255 (1965), abstract https://ui.adsabs.harvard.edu/abs/1965PhFl....8.2255O/abstract
- plausible The bounce period of an electron trapped in a plasma wave
It assumes the wave is small enough that those electrons go straight through it.
O'Neil states linear theory breaks down after t ~ tau=(m/e eps k)^1/2, i.e. it assumes unperturbed (straight-line) orbits for times short compared to the bounce time.
T. M. O'Neil, 'Collisionless damping of nonlinear plasma oscillations', Phys. Fluids 8, 2255 (1965), abstract https://ui.adsabs.harvard.edu/abs/1965PhFl....8.2255O/abstract
- plausible The bounce period of an electron trapped in a plasma wave
O'Neil (Phys. Fluids 8, 2255, 1965) asked what happens when the wave is large: the resonant electrons are caught in its potential troughs and bounce back and forth there, and the damping stops after about one bounce.
Citation is correct (Phys. Fluids 8, 2255, 1965). The abstract says the damping rate oscillates for t~tau and phase-mixes to zero as t/tau grows, so 'stops after about one bounce' is a loose paraphrase of 'dies away over a few bounce times'.
T. M. O'Neil, 'Collisionless damping of nonlinear plasma oscillations', Phys. Fluids 8, 2255 (1965), abstract https://ui.adsabs.harvard.edu/abs/1965PhFl....8.2255O/abstract
- plausible The bounce period of an electron trapped in a plasma wave
In the frame moving with the wave, the potential is static, , and an electron obeys .
Force on charge -e is -(-e)(-dphi/dx)=-e k phi0 sin kx for phi=phi0 cos kx; checked by hand, not accessed in a textbook.
T. M. O'Neil, 'Collisionless damping of nonlinear plasma oscillations', Phys. Fluids 8, 2255 (1965), abstract https://ui.adsabs.harvard.edu/abs/1965PhFl....8.2255O/abstract
- verified The bounce period of an electron trapped in a plasma wave
That is the pendulum equation.
x''=-(e k phi0/m) sin kx has the pendulum form theta''=-(g/l) sin theta.
Wikipedia, 'Pendulum (mechanics)', large-amplitude period T=(2T0/pi)K(sin(theta0/2)) and series 1+theta0^2/16+11theta0^4/3072, https://en.wikipedia.org/wiki/Pendulum_(mechanics)
- verified The bounce period of an electron trapped in a plasma wave
A pendulum released from rest at angle has the period
Pendulum period released from rest at theta0 is given by the complete elliptic integral.
Wikipedia, 'Pendulum (mechanics)', large-amplitude period T=(2T0/pi)K(sin(theta0/2)) and series 1+theta0^2/16+11theta0^4/3072, https://en.wikipedia.org/wiki/Pendulum_(mechanics)
- verified The bounce period of an electron trapped in a plasma wave
Wikipedia: T=(2T0/pi)K(k), k=sin(theta0/2); with T0=2pi/omega_B and parameter m=k^2 this is 4K(m)/omega_B.
Wikipedia, 'Pendulum (mechanics)', large-amplitude period T=(2T0/pi)K(sin(theta0/2)) and series 1+theta0^2/16+11theta0^4/3072, https://en.wikipedia.org/wiki/Pendulum_(mechanics)
- verified The bounce period of an electron trapped in a plasma wave
For a small release angle the series gives : the period grows with amplitude because the restoring force is weaker than .
Wikipedia gives K series 1+(1/2)^2 m+(3/8)^2 m^2 (=9/64) and T=2pi sqrt(l/g)(1+theta0^2/16+11theta0^4/3072+...).
Wikipedia, 'Pendulum (mechanics)', large-amplitude period T=(2T0/pi)K(sin(theta0/2)) and series 1+theta0^2/16+11theta0^4/3072, https://en.wikipedia.org/wiki/Pendulum_(mechanics)
- plausible The bounce period of an electron trapped in a plasma wave
The Verlet run lands within of the elliptic value: its phase error is of a period, and the test allows twice that.
For leapfrog on a harmonic oscillator cos(h w~)=1-h^2w^2/2 gives w~=w(1+(wh)^2/24+...), so the relative period error is (w dt)^2/24=1.67e-7 at dt=0.002; the test tolerance is 2*(dt^2/24)*T as stated.
Hairer, Lubich, Wanner, 'Geometric numerical integration illustrated by the Stormer-Verlet method', Acta Numerica 12 (2003) 399-450, modified frequency cos(h w~)=1-h^2w^2/2, https://www.math.kit.edu/ianm3/lehre/geonumint2009s/media/gni_by_stoermer-verlet.pdf
- verified The bounce period of an electron trapped in a plasma wave
The only frequency in the problem is , so quadrupling the wave amplitude halves the bounce period at the same release angle.
The period scales as 1/omega_B with omega_B=sqrt(phi0) at fixed release angle, so 4x phi0 halves it.
Wikipedia, 'Pendulum (mechanics)', large-amplitude period T=(2T0/pi)K(sin(theta0/2)) and series 1+theta0^2/16+11theta0^4/3072, https://en.wikipedia.org/wiki/Pendulum_(mechanics)
- verified The bounce period of an electron trapped in a plasma wave
The energy is conserved.
x''=-phi0 sin x conserves v^2/2-phi0 cos x (pendulum energy).
Wikipedia, 'Pendulum (mechanics)', large-amplitude period T=(2T0/pi)K(sin(theta0/2)) and series 1+theta0^2/16+11theta0^4/3072, https://en.wikipedia.org/wiki/Pendulum_(mechanics)
- verified The bounce period of an electron trapped in a plasma wave
The curve , , is the separatrix: inside it electrons are trapped and bounce, outside they stream past the crests.
Setting E=phi0: v^2/2=phi0(1+cos x)=2phi0 cos^2(x/2), so v=+-2 omega_B cos(x/2); the pendulum separatrix; checked by hand.
Wikipedia, 'Pendulum (mechanics)', large-amplitude period T=(2T0/pi)K(sin(theta0/2)) and series 1+theta0^2/16+11theta0^4/3072, https://en.wikipedia.org/wiki/Pendulum_(mechanics)
- plausible The bounce period of an electron trapped in a plasma wave
The trapped band is wide in velocity, and it is the electrons in this band that O'Neil's theory follows.
The separatrix spans v from -2omega_B/k to +2omega_B/k, width 4omega_B/k; O'Neil treats the resonant (trapped) electrons, though his theory also follows the near-resonant untrapped ones.
T. M. O'Neil, 'Collisionless damping of nonlinear plasma oscillations', Phys. Fluids 8, 2255 (1965), abstract https://ui.adsabs.harvard.edu/abs/1965PhFl....8.2255O/abstract
- not-checkable The bounce period of an electron trapped in a plasma wave
The boundary comes out at to the bisection's tolerance.
Describes the program's bisection result; the linker covers the number.
- verified The two-stream instability in a particle-in-cell code
Two cold electron beams passing through each other are unstable.
Counterstreaming cold beams are unstable to the two-stream instability.
Wikipedia, 'Two-stream instability' (bunching, trapping, saturation), https://en.wikipedia.org/wiki/Two-stream_instability
- verified The two-stream instability in a particle-in-cell code
The phase-space film shows the beams rolling up into vortices of trapped electrons, which is where the growth stops.
Wikipedia: saturation occurs when beam particles are trapped in the wave's field, which is the phase-space vortex structure.
Wikipedia, 'Two-stream instability' (bunching, trapping, saturation), https://en.wikipedia.org/wiki/Two-stream_instability
- not-checkable The two-stream instability in a particle-in-cell code
Two beams of electrons move through each other at velocities and , over a fixed background of ions that keeps the plasma neutral on average.
Describes the setup of this simulation.
- verified The two-stream instability in a particle-in-cell code
A small ripple in density bunches both beams, the bunches make an electric field, and the field bunches them further.
Wikipedia describes the self-reinforcing bunching of the beams by the wave field.
Wikipedia, 'Two-stream instability' (bunching, trapping, saturation), https://en.wikipedia.org/wiki/Two-stream_instability
- verified The two-stream instability in a particle-in-cell code
The ripple grows exponentially at a rate that linear theory predicts, until electrons are trapped in the wave's potential wells and the growth stops.
Exponential growth at the linear rate until trapping saturates it, as Wikipedia describes.
Wikipedia, 'Two-stream instability' (bunching, trapping, saturation), https://en.wikipedia.org/wiki/Two-stream_instability
- plausible The two-stream instability in a particle-in-cell code
A particle-in-cell (PIC) code follows this with no model beyond Newton's law and Gauss's law.
An electrostatic PIC code uses only the equations of motion and Poisson/Gauss; the grid and particle shape are numerical choices, not physical models.
Wikipedia, 'Particle-in-cell' (CIC linear weighting to the two nearest grid points, leapfrog, Birdsall & Langdon 1985), https://en.wikipedia.org/wiki/Particle-in-cell
- not-checkable The two-stream instability in a particle-in-cell code
For two cold beams at , each of density , write .
Defines notation for the post.
- plausible The two-stream instability in a particle-in-cell code
Matches the cold two-beam dispersion relation (Wikipedia gives the ion-beam variant); the symmetric form checked by hand.
Hand derivation: each beam of density n0/2 contributes (omega_p^2/2)/(omega-+kv0)^2 to the cold-fluid dielectric; in units omega_p=v0=1, omega in omega_p units; Wikipedia, 'Two-stream instability' (bunching, trapping, saturation), https://en.wikipedia.org/wiki/Two-stream_instability
- verified The two-stream instability in a particle-in-cell code
Solving the quadratic in omega^2 gives exactly this growth rate.
Hand algebra from the quartic w^4-(2a^2+1)w^2+a^4-a^2=0: w^2=[(2a^2+1)-+sqrt(8a^2+1)]/2; the negative root gives gamma^2=[sqrt(8a^2+1)-(2a^2+1)]/2, positive iff a<1
- not-checkable The two-stream instability in a particle-in-cell code
The box is one wavelength of the fastest mode, , with 32 grid cells and 2000 particles, 1000 per beam.
Describes the program's parameters (inputs).
- plausible The two-stream instability in a particle-in-cell code
The particles start evenly spaced, a quiet start, with their positions shifted by so that only the one mode is seeded.
A quiet (evenly spaced) start with a single sinusoidal displacement seeds one mode; standard practice from Birdsall & Langdon, not accessed in the book.
Wikipedia, 'Particle-in-cell' (CIC linear weighting to the two nearest grid points, leapfrog, Birdsall & Langdon 1985), https://en.wikipedia.org/wiki/Particle-in-cell
- plausible The two-stream instability in a particle-in-cell code
With random positions the instability would grow out of noise in every mode at once, and the fit below would need far more particles.
Random loading gives noise at 1/sqrt(N) in all modes; not accessed; from general knowledge.
Wikipedia, 'Particle-in-cell' (CIC linear weighting to the two nearest grid points, leapfrog, Birdsall & Langdon 1985), https://en.wikipedia.org/wiki/Particle-in-cell
- verified The two-stream instability in a particle-in-cell code
Each particle's charge is shared between the two nearest grid points in proportion to how close it is (cloud-in-cell).
CIC shares a particle's charge with the two nearest grid points with linear weights.
Wikipedia, 'Particle-in-cell' (CIC linear weighting to the two nearest grid points, leapfrog, Birdsall & Langdon 1985), https://en.wikipedia.org/wiki/Particle-in-cell
- plausible The two-stream instability in a particle-in-cell code
Gauss's law , integrated along the grid by the trapezoid rule; the mean of is removed, since a periodic box has no net field.
In a periodic box the mean field is set to zero since the net charge is zero and the potential is periodic; not accessed in a text; from general knowledge.
Wikipedia, 'Particle-in-cell' (CIC linear weighting to the two nearest grid points, leapfrog, Birdsall & Langdon 1985), https://en.wikipedia.org/wiki/Particle-in-cell
- verified The two-stream instability in a particle-in-cell code
Leapfrog: velocities live at half steps, positions at whole steps, and an electron's acceleration is .
Leapfrog stores velocities at half steps and positions at whole steps; with q/m=-1 the acceleration is -E.
Wikipedia, 'Particle-in-cell' (CIC linear weighting to the two nearest grid points, leapfrog, Birdsall & Langdon 1985), https://en.wikipedia.org/wiki/Particle-in-cell
- not-checkable The two-stream instability in a particle-in-cell code
The cell runs 250 steps to .
Describes the program's step count.
- not-checkable The two-stream instability in a particle-in-cell code
In the film the two beams are the bright lines at .
Describes the film.
- plausible The two-stream instability in a particle-in-cell code
They ripple, then fold over each other into vortices: electrons caught in the wave's potential wells, going round at the bounce frequency.
Trapped electrons circulate in the potential wells at the bounce frequency (O'Neil); description of the film.
Wikipedia, 'Two-stream instability' (bunching, trapping, saturation), https://en.wikipedia.org/wiki/Two-stream_instability; T. M. O'Neil, 'Collisionless damping of nonlinear plasma oscillations', Phys. Fluids 8, 2255 (1965), abstract https://ui.adsabs.harvard.edu/abs/1965PhFl....8.2255O/abstract
- verified The two-stream instability in a particle-in-cell code
At that point the field stops growing.
Growth saturates when particles are trapped.
Wikipedia, 'Two-stream instability' (bunching, trapping, saturation), https://en.wikipedia.org/wiki/Two-stream_instability
- verified The two-stream instability in a particle-in-cell code
While the mode is small it grows as , so is a straight line of slope .
A straight line of slope gamma follows directly from exponential growth.
Elementary: ln(A e^{gamma t}) = ln A + gamma t
- verified Upwind advection smears the pulse by its modified equation
On the unit interval with periodic ends, after a time the exact solution is the initial condition again, so everything a scheme does to the pulse in one transit is error.
On a unit periodic interval the exact solution returns after time 1/c; any difference after one transit is scheme error.
L. H. Hellevik, Numerical Methods for Engineers (NTNU TKT4140), first-order upwind modified equation u_t+a u_x=(a h/2)(1-C)u_xx, stability 0<C<=1, exact shift at C=1, https://leifh.folk.ntnu.no/teaching/tkt4140/._main070.html
- not-checkable Upwind advection smears the pulse by its modified equation
The pulse is sampled at the cell centers.
Describes the initial condition used.
- not-checkable Upwind advection smears the pulse by its modified equation
A separate numpy implementation,
posts/refs/upwind-advection-smears-by-its-modified-equation.py, computes the same numbers (output beside it).Describes the post's reference script.
- verified Upwind advection smears the pulse by its modified equation
Upwind takes the space difference from the side the wave comes from.
First-order upwind takes the one-sided difference from the upstream side.
L. H. Hellevik, Numerical Methods for Engineers (NTNU TKT4140), first-order upwind modified equation u_t+a u_x=(a h/2)(1-C)u_xx, stability 0<C<=1, exact shift at C=1, https://leifh.folk.ntnu.no/teaching/tkt4140/._main070.html
- verified Upwind advection smears the pulse by its modified equation
Standard upwind update u_j^{n+1}=u_j^n-C(u_j^n-u_{j-1}^n).
L. H. Hellevik, Numerical Methods for Engineers (NTNU TKT4140), first-order upwind modified equation u_t+a u_x=(a h/2)(1-C)u_xx, stability 0<C<=1, exact shift at C=1, https://leifh.folk.ntnu.no/teaching/tkt4140/._main070.html
- not-checkable Upwind advection smears the pulse by its modified equation
The second form is the useful one.
Transition.
- plausible Upwind advection smears the pulse by its modified equation
roll(u, 1)brings each cell's left neighbor to it, with the last cell wrapping to the first.Matches numpy.roll(u, 1) semantics; Viv's roll assumed to follow numpy (not accessed; from general knowledge).
NumPy documentation, numpy.roll: elements rolled beyond the last position are reintroduced at the first, https://numpy.org/doc/stable/reference/generated/numpy.roll.html
- verified Upwind advection smears the pulse by its modified equation
Expand and in Taylor series about , substitute into the update, and use the equation itself to trade for .
The modified-equation derivation expands in Taylor series and replaces u_tt by c^2 u_xx, as in the NTNU notes and LeVeque.
L. H. Hellevik, Numerical Methods for Engineers (NTNU TKT4140), first-order upwind modified equation u_t+a u_x=(a h/2)(1-C)u_xx, stability 0<C<=1, exact shift at C=1, https://leifh.folk.ntnu.no/teaching/tkt4140/._main070.html
- verified Upwind advection smears the pulse by its modified equation
What is left, to the first order in , is the modified equation
Introduces the modified equation, first order in h.
L. H. Hellevik, Numerical Methods for Engineers (NTNU TKT4140), first-order upwind modified equation u_t+a u_x=(a h/2)(1-C)u_xx, stability 0<C<=1, exact shift at C=1, https://leifh.folk.ntnu.no/teaching/tkt4140/._main070.html
- verified Upwind advection smears the pulse by its modified equation
NTNU notes: nu_N=(a h/2)(1-C), matching D=(c h/2)(1-nu).
L. H. Hellevik, Numerical Methods for Engineers (NTNU TKT4140), first-order upwind modified equation u_t+a u_x=(a h/2)(1-C)u_xx, stability 0<C<=1, exact shift at C=1, https://leifh.folk.ntnu.no/teaching/tkt4140/._main070.html
- plausible Upwind advection smears the pulse by its modified equation
Diffusion spreads a Gaussian and keeps it Gaussian.
True on the infinite line.
Heat kernel: a Gaussian convolved with a Gaussian is Gaussian; not accessed; from general knowledge
- plausible Upwind advection smears the pulse by its modified equation
Its variance (the second moment of , treated as a distribution in ) grows by , and since the mass is fixed the peak falls as one over the width.
Standard result for the diffusion equation; peak ~1/width for a Gaussian of fixed mass.
Heat equation u_t=D u_xx: second moment grows by 2Dt, mass conserved; not accessed; from general knowledge
- verified Upwind advection smears the pulse by its modified equation
For the variance the prediction is exact, not just first order.
Variance of a convolution is the sum of variances exactly, so the variance prediction is exact (up to periodic wrap).
Hand calculation: the update is convolution with a two-point (Bernoulli) kernel, so variances add exactly per step
- verified Upwind advection smears the pulse by its modified equation
The update moves a fraction of each cell's content one cell to the right.
(1-nu)u_i+nu u_{i-1} moves fraction nu of each cell one cell to the right.
L. H. Hellevik, Numerical Methods for Engineers (NTNU TKT4140), first-order upwind modified equation u_t+a u_x=(a h/2)(1-C)u_xx, stability 0<C<=1, exact shift at C=1, https://leifh.folk.ntnu.no/teaching/tkt4140/._main070.html
- verified Upwind advection smears the pulse by its modified equation
That is one step of a random walk, which adds cells squared to the variance; steps add .
Arithmetic checks.
Hand calculation: Bernoulli step variance nu(1-nu) cells^2; 1/(nu h) steps times h^2 gives (1-nu)h=2DT with c=T=1
- plausible Upwind advection smears the pulse by its modified equation
The peak prediction is only first order, because the random walk's pulse is not an exact Gaussian.
Plausible explanation; the measured discrepancy is small.
Central limit theorem: binomial kernel is Gaussian only asymptotically; not accessed; from general knowledge
- not-checkable Upwind advection smears the pulse by its modified equation
The variance is taken with each cell's displacement from wrapped into , so the periodic grid has no seam in the middle of the pulse.
Describes how the program computes the variance.
- not-checkable Upwind advection smears the pulse by its modified equation
The variance growth sits on the line at every one, to rounding.
Describes the program's result; numbers are handled by the linker.
- verified Upwind advection smears the pulse by its modified equation
A larger time step means less smearing, up to ; past it the scheme is unstable.
NTNU notes: numerical viscosity (1-C) decreases with C up to C=1 and the scheme is unstable for C>1.
L. H. Hellevik, Numerical Methods for Engineers (NTNU TKT4140), first-order upwind modified equation u_t+a u_x=(a h/2)(1-C)u_xx, stability 0<C<=1, exact shift at C=1, https://leifh.folk.ntnu.no/teaching/tkt4140/._main070.html