The Mathematical Cosmos e + 1 = 0 ∫𝒟[x] eiS[x]/ℏ = ⟨xf|e−iĤt/ℏ|xi

Euler · Hilbert · Gauss · Maxwell · Fermat · String Theory · M-Theory

How the deepest mathematics of the last four centuries weave together

I. The Grand Mathematical Tapestry

The greatest physical theories of our age — quantum mechanics, general relativity, string theory, M-theory — are not isolated achievements. They are woven from a single, continuous thread of mathematical insight stretching across four centuries. A handful of mathematicians and physicists, each standing on the shoulders of the last, forged the tools that now describe reality from the Planck scale (\(10^{-35}\) m) to the cosmic horizon (\(10^{26}\) m).

The Lineage of Ideas

Fermat (1637) — light takes the path of least time → Euler–Lagrange (1744–1755) — general extremal principle → Hamilton (1833) — least action for mechanics → Maxwell (1865) — gauge fields obey extremal laws → Einstein (1905–1915) — gravity is geometry, light bends → Hilbert (1900–1925) — quantum states live in infinite-dimensional spaces → Feynman (1948) — the path integral unifies all of the above → Veneziano (1968), Green–Schwarz–Witten (1984) — strings unify all forces using every tool above.

MathematicianKey ContributionAppears in QMAppears in String Theory
Euler (1707–1783)e+1=0, ζ(s), Euler-Lagrange, Euler characteristicWave functions, path integrals, partition functionsζ-function regularization, worldsheet topology
Gauss (1777–1855)Gaussian curvature, Gauss's law, Gaussian integralsPath integrals, harmonic oscillator, QEDGauss-Bonnet term, string coupling, modular forms
Fermat (1607–1665)Least time principle, number theoryPath integral stationary phase, WKBClassical string = extremal worldsheet
Maxwell (1831–1879)Electromagnetic field equations, gauge invarianceQED, photon, gauge invarianceOpen strings carry Maxwell gauge fields
Hilbert (1862–1943)Hilbert spaces, spectral theory, Hilbert actionState vectors, observablesString Hilbert space, Virasoro algebra
Riemann (1826–1866)Riemannian geometry, ζ(s)Gauge theories, Berry phaseWorldsheet is Riemann surface

II. Links to Our Previous Documents

In our series of documents — Newton's Principia, Einstein's Relativity, and Quantum Mechanics — we built the technical foundations that this document now synthesizes at the deepest level.

From Newton's Principia (our Document I)

Euler's formalization of Newton: Euler translated Newton's geometric fluxions into the analytic notation we use today: \(dy/dx\), \(\sum\), and the exponential function \(e^x\). The Euler-Lagrange equation emerged from Newton's second law cast in generalized coordinates. In string theory, the Nambu-Goto action \(S = -T\int d^2\sigma\sqrt{-\det h_{ab}}\) is directly the string generalization of Newton's least action, with the Euler-Lagrange equations giving string equations of motion.

From Einstein's Relativity (our Document II)

Hilbert's role in GR: Hilbert submitted the Einstein field equations simultaneously with Einstein (November 1915), deriving them from the Hilbert action \(S = \frac{1}{16\pi G}\int R\sqrt{-g}\,d^4x\). Gauss's curvature theory → Riemann geometry → Ricci tensor → Hilbert action → Einstein equations. In string theory, the low-energy effective action for the graviton sector is precisely the Hilbert action, plus corrections from higher-derivative terms involving the Gauss-Bonnet combination.

From Quantum Mechanics (our Document III)

Hilbert spaces ARE quantum mechanics: The postulates we listed (state vectors, Hermitian observables, Born rule) all presuppose a Hilbert space. Euler's identity \(e^{i\theta}\) is the unit complex number that rotates state vectors unitarily. The path integral \(\int\mathcal{D}[x]\,e^{iS/\hbar}\) uses Euler's exponential map on Gauss's classical action, integrated over an infinite-dimensional (Hilbert-like) space of paths.

III. Euler's Identity — The Most Beautiful Equation

Leonhard Euler (1748) discovered the relation that Richard Feynman called "the most remarkable formula in mathematics":

Euler's Identity $$\boxed{e^{i\pi} + 1 = 0}$$

Unifying five fundamental constants: \(e\) (natural growth), \(i = \sqrt{-1}\) (imaginary unit), \(\pi\) (geometry of circles), \(1\) (unity), \(0\) (nothingness).

Euler's Formula — General Form $$e^{i\theta} = \cos\theta + i\sin\theta$$
Proof via Taylor Series

Expand each function as a Maclaurin series and separate real and imaginary parts:

$$e^{i\theta} = \sum_{n=0}^\infty \frac{(i\theta)^n}{n!} = \sum_{n=0}^\infty\frac{(-1)^n\theta^{2n}}{(2n)!} + i\sum_{n=0}^\infty\frac{(-1)^n\theta^{2n+1}}{(2n+1)!} = \cos\theta + i\sin\theta$$

Euler's Formula in Quantum Mechanics

Every quantum wavefunction is built from Euler's exponentials. The plane wave solution of the free Schrödinger equation is precisely \(\psi(x,t) = e^{i(kx-\omega t)}\). The time evolution operator \(U(t) = e^{-i\hat{H}t/\hbar}\) maps the Hamiltonian through Euler's exponential map onto the unitary group. The entire formalism of quantum mechanics depends on the fact that \(e^{i\theta}\) traces the unit circle — keeping probabilities \(|\psi|^2\) normalized under time evolution.

Euler's Formula in String Theory

String theory amplitudes are computed as conformal field theory (CFT) correlators on Riemann surfaces. The worldsheet field \(X^\mu(\sigma,\tau)\) has mode expansions:

$$X^\mu(\sigma,\tau) = x^\mu + \alpha' p^\mu \tau + i\sqrt{\frac{\alpha'}{2}}\sum_{n\ne 0}\frac{\alpha_n^\mu}{n}e^{-in(\tau-\sigma)}$$

Every oscillation mode \(e^{-in(\tau-\sigma)}\) is an Euler exponential. The vacuum amplitude of bosonic strings involves \(e^{2\pi i\tau}\) where \(\tau\) is the modular parameter of the worldsheet torus — deep Euler territory.

IV. Euler's Zeta Function & String Theory

Euler defined the Riemann zeta function (before Riemann!) as:

$$\zeta(s) = \sum_{n=1}^\infty \frac{1}{n^s} = \prod_p \frac{1}{1-p^{-s}}\quad (\text{Euler product, }s>1)$$

Regularization and the "Sum" 1+2+3+… = −1/12

The analytic continuation of \(\zeta(s)\) to \(s=-1\) gives \(\zeta(-1) = -1/12\). This seemingly absurd result is physically real in string theory:

String Theory's Zero-Point Energy

The bosonic string in \(D\) spacetime dimensions has zero-point energy from summing oscillator modes \(\frac{1}{2}\sum_{n=1}^\infty n\). This formally diverges, but zeta-function regularization gives:

$$a = \frac{D-2}{2}\zeta(-1) = -\frac{D-2}{24}$$

For \(D=26\) (critical dimension of bosonic string): \(a = -1\). The photon (massless string state) requires \(M^2 = 0\), which fixes \(a=-1\), which uniquely forces \(D=26\). The number 26 comes from Euler's zeta function regularization!

For the superstring, the critical dimension is \(D=10\) (with \(\zeta(-1)=-1/12\) and supersymmetric cancellations reducing the bosonic count by half: \(-\frac{10-2}{24}+\frac{10-2}{48} = -\frac{1}{2}\)).

Modularity and the Dedekind Eta Function

The one-loop string partition function on a torus involves the Dedekind eta function, built from Euler's product:

$$\eta(\tau) = e^{\pi i\tau/12}\prod_{n=1}^\infty(1-e^{2\pi i n\tau})$$

This is related to Euler's pentagonal number theorem and has deep connections to number theory, elliptic curves, and the Monster group — all of which appear in the study of string theory dualities.

V. Euler-Lagrange Equations & the Action Principle

Euler (1744) and Lagrange (1755) formulated the principle of stationary action as a mathematical theorem. Starting from a functional \(S[q] = \int_{t_1}^{t_2}\mathcal{L}(q,\dot q,t)\,dt\), the condition \(\delta S = 0\) yields:

Euler-Lagrange Equation $$\boxed{\frac{d}{dt}\frac{\partial\mathcal{L}}{\partial\dot q^i} - \frac{\partial\mathcal{L}}{\partial q^i} = 0}$$
Derivation via Variational Calculus

Consider variation \(q(t)\to q(t)+\epsilon\eta(t)\) with \(\eta(t_1)=\eta(t_2)=0\). Then:

$$\frac{dS}{d\epsilon}\bigg|_{\epsilon=0} = \int_{t_1}^{t_2}\left(\frac{\partial\mathcal{L}}{\partial q}\eta + \frac{\partial\mathcal{L}}{\partial\dot q}\dot\eta\right)dt$$

Integrate the second term by parts (boundary terms vanish):

$$= \int_{t_1}^{t_2}\left(\frac{\partial\mathcal{L}}{\partial q} - \frac{d}{dt}\frac{\partial\mathcal{L}}{\partial\dot q}\right)\eta\,dt = 0$$

Since \(\eta\) is arbitrary, the integrand must vanish identically. ∎

The chain from Euler-Lagrange to modern physics:

$$\text{Fermat} \xrightarrow{\text{generalizes}} \text{Euler-Lagrange} \xrightarrow{\text{classical limit}} \text{Feynman path integral} \xrightarrow{\text{strings}} \text{Polyakov/Nambu-Goto action}$$

The Nambu-Goto string action is the direct Euler-Lagrange generalization to a 2D surface (worldsheet \(\Sigma\) with coordinates \((\sigma,\tau)\)):

$$S_{NG} = -\frac{T}{c}\int_\Sigma\sqrt{-\det(\partial_a X^\mu\partial_b X_\mu)}\,d^2\sigma$$

The Euler-Lagrange equations for \(X^\mu(\sigma,\tau)\) give the string equations of motion: \(\Box X^\mu = 0\) (free wave equation).

VI. Euler Characteristic, Topology & String Theory

For any convex polyhedron: \(V - E + F = 2\). Euler (1750) found this relation, which for smooth surfaces generalizes to the Euler characteristic:

$$\chi(\Sigma) = 2 - 2g$$

where \(g\) is the genus (number of handles/holes). A sphere: \(\chi=2\), \(g=0\). A torus: \(\chi=0\), \(g=1\). A two-handled pretzel: \(\chi=-2\), \(g=2\).

Euler Characteristic in String Perturbation Theory

String Coupling & World-Sheet Topology

The string perturbation expansion is organized by the Euler characteristic of the worldsheet:

$$\mathcal{A} = \sum_{g=0}^\infty g_s^{-\chi(\Sigma_g)} A_g = \sum_{g=0}^\infty g_s^{2g-2} A_g$$

Each handle (loop) adds a factor of \(g_s^2\) (the string coupling squared). Tree level (\(g=0\)) has \(g_s^{-2}\), one-loop (\(g=1\), torus) is independent of \(g_s\), etc. The entire perturbation series is organized by Euler's topological invariant. This is the Gauss-Bonnet theorem in action.

Gauss-Bonnet Theorem

$$\int_\Sigma K\,dA + \oint_{\partial\Sigma}k_g\,ds = 2\pi\chi(\Sigma)$$

Gauss curvature \(K\) integrated over the surface gives the Euler characteristic — connecting local geometry (curvature) to global topology (genus). In string theory, the Gauss-Bonnet term \(\int R^2\) appears in the next-order correction to the Hilbert action in the low-energy effective theory.

VII. Euler Mathematics & Stephen Hawking

Hawking's most celebrated work — Hawking radiation, black hole thermodynamics, and the no-boundary proposal — is permeated with Euler's mathematics at every level.

Hawking Radiation and the Euler Exponential

Hawking (1974) showed that a black hole of mass \(M\) emits thermal radiation at the temperature:

$$T_H = \frac{\hbar c^3}{8\pi G M k_B}$$

The derivation uses the Bogoliubov transformation between ingoing and outgoing modes, which involves Euler exponentials \(e^{i\omega t}\) and the analytic continuation \(t\to t-i\beta/2\) where \(\beta = 1/k_BT_H\). The Planck distribution of Hawking radiation is \(n_\omega = (e^{\hbar\omega/k_BT_H}-1)^{-1}\) — Euler's exponential directly.

Euclidean Quantum Gravity and Euler Characteristic

Hawking and Hartle's no-boundary proposal for the wavefunction of the universe uses the Euclidean path integral (Wick rotation \(t\to -i\tau\)):

$$\Psi[h_{ij}] = \int\mathcal{D}[g]\,e^{-S_E[g]/\hbar}$$

The Euclidean action for compact manifolds involves the Gauss-Bonnet-Euler characteristic. For a 4-sphere (the simplest no-boundary solution), \(\chi = 2\), and the action evaluates to \(S_E = -3/(8G\Lambda)\) — giving \(\Psi \propto e^{+3/8G\Lambda\hbar}\), the exponentially large amplitude Hawking used to argue for inflation.

Black Hole Entropy and Euler's Identity

The Bekenstein-Hawking entropy \(S_{BH} = A/(4l_P^2)\) (area in Planck units) can be derived in string theory by counting microstates of D-branes. The counting involves modular forms built from Euler products. For the extremal Reissner-Nordström black hole (Strominger-Vafa 1996), the number of microstates is:

$$e^{S_{BH}} = e^{2\pi\sqrt{n_1 n_5 n_P}}$$

This Euler exponential of \(2\pi\) times a square root is deeply connected to the Cardy formula for CFT entropy and Euler's analysis of partitions of integers.

The Hawking-Euler connection in our previous Einstein document: We derived gravitational waves (Section XXIV), which Hawking showed are created by black hole formation and merger. The quadrupole formula \(h_{ij} \propto \ddot{I}_{ij}\) generates plane waves \(e^{i(kz-\omega t)}\) — Euler exponentials. Every gravitational wave detected by LIGO is an Euler formula in action.

VIII. Hilbert Spaces — Definition & Structure

Hilbert Space — Formal Definition

A Hilbert space \(\mathcal{H}\) is a complex vector space with an inner product \(\langle\cdot,\cdot\rangle: \mathcal{H}\times\mathcal{H}\to\mathbb{C}\) that is:

  • Conjugate linear in first argument: \(\langle\alpha f+g, h\rangle = \bar\alpha\langle f,h\rangle + \langle g,h\rangle\)
  • Hermitian: \(\langle f,g\rangle = \overline{\langle g,f\rangle}\)
  • Positive definite: \(\langle f,f\rangle\ge 0\), equal to zero iff \(f=0\)
  • Complete: Every Cauchy sequence in \(\mathcal{H}\) converges to an element of \(\mathcal{H}\)

Examples of Hilbert Spaces

SpaceElementsInner ProductDimension
\(\mathbb{C}^n\)Complex \(n\)-vectors\(\sum_i \bar a_i b_i\)\(n\) (finite)
\(\ell^2(\mathbb{N})\)Square-summable sequences \((a_n)\)\(\sum_n \bar a_n b_n\)Countably ∞
\(L^2(\mathbb{R})\)Square-integrable functions\(\int_{-\infty}^\infty\bar f(x)g(x)\,dx\)Uncountably ∞
\(L^2(\mathbb{R}^3)\)Quantum wavefunctions\(\int\bar\psi\phi\,d^3x\)Uncountably ∞
String Hilbert spaceFock space of string modesOscillator algebraUncountably ∞

IX. How Hilbert Spaces Have Infinite Dimensions

In finite dimensions, a vector space \(\mathbb{R}^n\) is spanned by \(n\) basis vectors. A Hilbert space can have infinitely many basis vectors — this is not just a quantitative difference but a qualitative one that requires completeness to be well-defined.

The Space \(L^2([0,L])\) — Countably Infinite Basis

The functions \(\{e_n(x) = \sqrt{2/L}\sin(n\pi x/L)\}_{n=1}^\infty\) form an orthonormal basis for \(L^2([0,L])\). Any function \(f\in L^2\) expands as:

$$f(x) = \sum_{n=1}^\infty c_n e_n(x),\qquad c_n = \int_0^L e_n(x)f(x)\,dx,\qquad \sum_{n=1}^\infty|c_n|^2 = \|f\|^2 < \infty$$
Parseval's Theorem (Completeness) $$\|f\|^2 = \int_0^L|f(x)|^2\,dx = \sum_{n=1}^\infty|c_n|^2$$

This is the infinite-dimensional Pythagorean theorem. It holds because \(L^2\) is complete — unlike, say, the space of continuous functions which lacks completeness.

Why Infinite Dimensions Are Physical

Separability and Bases

A Hilbert space is separable if it has a countable orthonormal basis \(\{e_n\}\) with \(\langle e_m,e_n\rangle = \delta_{mn}\) and \(\sum_n|e_n\rangle\langle e_n| = \hat{I}\). All physically relevant Hilbert spaces in QM are separable. The Stone-von Neumann theorem says that all separable infinite-dimensional Hilbert spaces are isomorphic to \(\ell^2(\mathbb{N})\) — there is essentially only one infinite-dimensional Hilbert space (up to isomorphism)!

X. Symmetry in Hilbert Spaces

A symmetry of a physical system is a transformation that preserves the structure of the Hilbert space and all physical predictions. By Wigner's theorem:

Wigner's Theorem (1931)

Every symmetry transformation on a Hilbert space is represented by either a unitary operator \(U\) (\(U^\dagger U = I\)) or an anti-unitary operator. Continuous symmetries are represented by unitary operators; time reversal is anti-unitary.

Key Symmetry Groups in Physics

SymmetryGroupHilbert Space ActionPhysical Consequence
Translations in \(x\)\((\mathbb{R},+)\)\(U(a)\psi(x)=\psi(x-a)\)Momentum conservation
Time translations\((\mathbb{R},+)\)\(U(t)=e^{-i\hat{H}t/\hbar}\)Energy conservation
Rotations\(SO(3)\) or \(SU(2)\)\(D^{(j)}(R)\)Angular momentum conservation
Phase rotations\(U(1)\)\(\psi\to e^{i\theta}\psi\)Charge conservation (QED)
Color symmetry\(SU(3)\)3×3 unitary matricesQuark confinement (QCD)
SupersymmetrySuper-PoincaréMixes bosons↔fermionsSuperstring spectrum

Noether's Theorem — Symmetry → Conservation Law

Every continuous symmetry of the action corresponds to a conserved charge (Noether 1915). In Hilbert space language: if \([U(\alpha),\hat H]=0\) for all \(\alpha\), then the generator \(\hat Q\) (with \(U(\alpha)=e^{i\alpha\hat Q}\)) satisfies \(d\langle\hat Q\rangle/dt = 0\).

Symmetry in String Theory Hilbert Space

The worldsheet CFT has Virasoro symmetry — an infinite-dimensional symmetry algebra acting on the string Hilbert space. The generators \(L_n\) satisfy:

$$[L_m, L_n] = (m-n)L_{m+n} + \frac{c}{12}m(m^2-1)\delta_{m+n,0}$$

where \(c\) is the central charge. Physical states must satisfy \(L_0|\psi\rangle = |\psi\rangle\) and \(L_n|\psi\rangle = 0\) for \(n>0\) (Virasoro constraints). The condition for anomaly cancellation forces \(c=26\) (bosonic) or \(c=10\) (superstring) — again the critical dimension from Euler's zeta regularization.

XI. Hilbert Spaces in Quantum Mechanics

As established in our QM document, quantum mechanics is Hilbert space theory. Here we go deeper into why this mathematical structure is not a choice but a necessity.

Why Complex Hilbert Space?

Real Hilbert spaces fail quantum mechanics: for two-state systems, a real inner product cannot accommodate the \(i\hbar\) in \([\hat x, \hat p] = i\hbar\). The complex structure of \(L^2(\mathbb{C})\) is not optional — it is forced by the requirement that position and momentum coexist as Hermitian operators with non-trivial commutators.

Spectral Theory and Measurement

The spectral theorem for unbounded self-adjoint operators \(\hat A\) in a Hilbert space gives:

$$\hat A = \int_{\sigma(\hat A)} \lambda\,dE_\lambda$$

where \(dE_\lambda\) is the spectral measure (projection-valued measure). This is the rigorous mathematical version of "measuring \(\hat A\) yields eigenvalue \(\lambda\) with probability \(dE_\lambda\)." The Born rule is the spectral measure.

Density Operators and Mixed States

A general quantum state (pure or mixed) is a density operator \(\hat\rho\) on \(\mathcal{H}\): positive semidefinite, trace-class, \(\text{Tr}(\hat\rho)=1\). Expectation values: \(\langle\hat A\rangle = \text{Tr}(\hat\rho\hat A)\). For a pure state: \(\hat\rho = |\psi\rangle\langle\psi|\). This is essential in black hole physics where Hawking argued that black hole evaporation takes a pure state \(|\psi\rangle\) to a mixed \(\hat\rho\) — the information paradox.

XII. Hilbert Spaces in String Theory & M-Theory

String theory replaces point particles with extended objects. The quantization of the string leads to a much richer Hilbert space structure.

The Open String Hilbert Space

An open string (free endpoint) is quantized by treating the modes \(\alpha_n^\mu\) as creation/annihilation operators:

$$[\alpha_m^\mu, \alpha_n^\nu] = m\delta_{m+n,0}\eta^{\mu\nu}$$

The Fock space built from these satisfies \(\alpha_n^\mu|k\rangle = 0\) for \(n>0\) (vacuum) and the Hilbert space is:

$$\mathcal{H}_{open} = \text{Fock}(\{\alpha_{-n}^\mu\}_{n>0,\mu=0\ldots D-1})$$

This is an infinite-dimensional Hilbert space. The level-mass relation for open strings: \(M^2 = (N-1)/\alpha'\) where \(N = \sum_n n\,\alpha_{-n}\cdot\alpha_n\) is the number operator. Different levels \(N=0,1,2,\ldots\) give different particle species — an infinite tower of massive states.

M-Theory and the 11-Dimensional Hilbert Space

M-theory (Witten, 1995) is the proposed unique 11-dimensional theory unifying all five superstring theories. Its Hilbert space is not yet fully defined, but its low-energy limit is 11D supergravity. The compactification of M-theory on various manifolds gives different string theories:

CompactificationResultHilbert Space Structure
M on \(S^1\) (circle)Type IIA stringKaluza-Klein tower of states
M on \(S^1/\mathbb{Z}_2\)Heterotic \(E_8\times E_8\)Two \(E_8\) gauge groups
M on \(K3\times T^3\)VariousBPS state spectrum
M on Calabi-Yau4D \(\mathcal{N}=1\) SUGRAModuli space Hilbert space

XIII. Fermat's Principle of Least Time

Pierre de Fermat (1662) stated: light travels between two points along the path that minimizes the travel time. This was the first variational principle in physics.

Fermat's Principle $$\delta\int_A^B \frac{ds}{v(s)} = 0\qquad\text{(minimize optical path length)}\qquad\iff\qquad\delta\int_A^B n(s)\,ds = 0$$
Snell's Law from Fermat's Principle

Light crosses from medium 1 (speed \(v_1\)) to medium 2 (speed \(v_2\)) at a flat interface. Parameterize by where the ray crosses: \(x_0\). Travel time:

$$T(x_0) = \frac{\sqrt{a^2+x_0^2}}{v_1} + \frac{\sqrt{b^2+(d-x_0)^2}}{v_2}$$

Minimize: \(dT/dx_0 = 0\) gives \(\frac{x_0}{v_1\sqrt{a^2+x_0^2}} = \frac{d-x_0}{v_2\sqrt{b^2+(d-x_0)^2}}\), i.e., \(\frac{\sin\theta_1}{v_1} = \frac{\sin\theta_2}{v_2}\), equivalently:

$$n_1\sin\theta_1 = n_2\sin\theta_2\quad\text{(Snell's Law)}$$

Fermat → General Relativity

In GR, the geodesic equation (our Einstein document, Section XVIII) is the relativistic generalization of Fermat's principle: null geodesics (light paths) minimize the spacetime interval \(\delta\int ds = 0\). The bending of light by a massive object (gravitational lensing) is Fermat's principle applied in curved spacetime — light still takes the path of extremal travel time (though "time" is now measured along the curved metric).

Fermat → Number Theory → String Theory

Fermat is also famous for Fermat's Last Theorem (\(x^n+y^n=z^n\) has no positive integer solutions for \(n\ge 3\), proved by Wiles 1995). The proof uses elliptic curves and modular forms — which are precisely the mathematical objects that appear in string theory! The modular symmetry \(\tau\to\tau+1\), \(\tau\to-1/\tau\) of the string worldsheet torus is the same modular group \(SL(2,\mathbb{Z})\) that governs elliptic curves in Fermat's theorem.

XIV. Light in Einstein's View — From Special to General Relativity

Special Relativity: Light as the Absolute Limit

In SR (our Einstein document, Section II), the second postulate established that \(c = 2.998\times10^8\) m/s is the same in all inertial frames. Light travels along null geodesics: \(ds^2 = 0\) — paths with zero spacetime interval. The photon has:

$$E = \hbar\omega = pc,\qquad m = 0,\qquad E^2 = (pc)^2 + (mc^2)^2 = p^2c^2$$

General Relativity: Light in Curved Spacetime

In GR, light still travels along null geodesics, but spacetime is curved by matter. The null condition in Schwarzschild spacetime:

$$0 = -\left(1-\frac{r_s}{r}\right)c^2dt^2 + \frac{dr^2}{1-r_s/r}+r^2d\Omega^2$$

This leads to the famous doubling of light deflection by gravity compared to the Newtonian prediction:

$$\delta\phi_{GR} = \frac{4GM}{bc^2} = \frac{2r_s}{b},\qquad \delta\phi_{Newton} = \frac{2GM}{bc^2} = \frac{r_s}{b}$$

The extra factor of 2 in GR comes from the curvature of the spatial part of the metric — light is deflected both by the time dilation and by the spatial curvature, with equal contributions.

Light as a Quantum Object — the Photon

Quantum mechanically, light is quantized into photons — excitations of the electromagnetic field. In QED (quantum electrodynamics), photons are massless spin-1 particles. The photon wavefunction in momentum space is a spin-1 polarization vector \(\epsilon^\mu(k)\) satisfying \(k_\mu\epsilon^\mu = 0\) (Lorenz gauge) and the massless dispersion \(k^2=0\).

Light in String Theory

In string theory, the photon is a specific excited state of an open string. At level \(N=1\), the open string has massless vector states \(\alpha_{-1}^\mu|k\rangle\) — these are photons! The Maxwell equations emerge from the string equations of motion at low energy. This is how string theory unifies all particles: different vibration modes of a fundamental string give different particles.

XV. The Feynman Path Integral — Deep Explanation

Richard Feynman (1948) revolutionized quantum mechanics with an entirely new formulation, inspired by Dirac's observation that the quantum propagator involves \(e^{iS/\hbar}\). The path integral is the quantum generalization of Fermat's principle.

Feynman Path Integral (Propagator) $$K(x_f,t_f;x_i,t_i) = \int\mathcal{D}[x(t)]\,e^{iS[x]/\hbar}$$ $$= \lim_{N\to\infty}\prod_{j=1}^{N-1}\int_{-\infty}^\infty \frac{dx_j}{\mathcal{N}}\,\exp\!\left(\frac{i}{\hbar}\sum_{k=0}^{N-1}\mathcal{L}(x_k,\dot x_k)\Delta t\right)$$

What the Path Integral Means

Feynman's prescription: the quantum amplitude for a particle to go from \(x_i\) to \(x_f\) is obtained by summing over all possible paths, each weighted by the phase factor \(e^{iS/\hbar}\):

Classical Limit — Fermat's Principle Recovered

Why the Classical Path Dominates as ℏ → 0

The path integral is dominated by paths where the phase \(S[x]/\hbar\) is stationary: \(\delta S = 0\). This is exactly the Euler-Lagrange / least action / Fermat condition. When \(\hbar\to 0\), the phase oscillates infinitely fast for all paths except the classical one — they all destructively interfere. Only the path satisfying \(\delta S = 0\) survives. QM reduces to classical mechanics in the \(\hbar\to 0\) limit — and to Fermat's principle for photons (\(\hbar\to 0\) at fixed optical wavelength).

Gaussian Path Integrals

For a harmonic oscillator \(L = \frac{m}{2}\dot x^2 - \frac{m\omega^2}{2}x^2\), the path integral is exactly Gaussian and evaluable:

$$K(x_f,T;x_i,0) = \sqrt{\frac{m\omega}{2\pi i\hbar\sin(\omega T)}}\exp\!\left(\frac{im\omega}{2\hbar\sin(\omega T)}\left[(x_i^2+x_f^2)\cos(\omega T)-2x_ix_f\right]\right)$$

Path Integral and Statistical Mechanics

Under Wick rotation \(t\to -i\tau\) (imaginary time), the path integral becomes:

$$Z = \int\mathcal{D}[x]\,e^{-S_E[x]/\hbar} = \text{Tr}(e^{-\beta\hat H})$$

where \(\beta = \hbar/k_BT\). This is the thermal partition function of statistical mechanics! The same path integral that describes quantum mechanics at zero temperature describes thermal fluctuations at temperature \(T = \hbar/(k_B\beta)\). Hawking used this exact identification to derive black hole temperature.

Path Integral in Quantum Field Theory and Strings

The QFT path integral: \(Z = \int\mathcal{D}[\phi]\,e^{iS[\phi]/\hbar}\) integrates over field configurations. For strings: \(Z = \sum_{g=0}^\infty\int\frac{\mathcal{D}[X]\mathcal{D}[g]}{V_{CKV}}\,e^{-S_P[X,g]/\hbar}\) integrates over maps \(X^\mu\) and worldsheet metrics \(g\) — the Polyakov path integral.

XVI. Atomic Shells in Quantum Mechanics

The shell structure of atoms (from our QM document, Section XV) emerges from the full 3D solution of the hydrogen Schrödinger equation with angular momentum included.

Shell Structure from Hilbert Space Decomposition

The Hilbert space of the hydrogen electron decomposes into invariant subspaces under rotational symmetry:

$$\mathcal{H} = \bigoplus_{n=1}^\infty\bigoplus_{l=0}^{n-1}\bigoplus_{m=-l}^{l}\mathbb{C}\cdot|n,l,m\rangle$$

Each shell \(n\) corresponds to energy \(E_n = -13.6/n^2\) eV and contains \(n^2\) spatial orbitals (\(2n^2\) with spin). The radial quantum number determines the size; \(l\) determines the shape (s, p, d, f, ...); \(m\) determines the orientation.

Why Shells Close at 2, 8, 18, 32…

The magic numbers of the periodic table are \(2n^2\) with \(n=1,2,3,4\) giving 2, 8, 18, 32. This follows from the degeneracy of the hydrogen Hilbert space: for each \(n\), there are \(\sum_{l=0}^{n-1}(2l+1) = n^2\) spatial states, doubled by spin to \(2n^2\). The accidental SO(4) symmetry of the Coulomb potential (Runge-Lenz vector) causes this \(n^2\) degeneracy — it is a symmetry of the Hilbert space that is larger than the manifest SO(3) rotational symmetry.

XVII. Atomic Shells in String Theory

String Mass Spectrum as "Shells"

The string has a tower of excited states at increasing mass levels — analogous to atomic shells. For an open string:

$$\alpha' M^2 = N - 1,\qquad N = 0,1,2,3,\ldots$$
Level NMassParticle contentAnalogy
0\(M^2=-1/\alpha'\) (tachyon)Tachyon (bosonic)Vacuum state
1\(M^2=0\)Photon (massless vector)n=1 shell
2\(M^2=1/\alpha'\)Massive spin-2 and spin-0n=2 shell
N\(M^2=(N-1)/\alpha'\)Massive states at each levelnth shell

D-Branes and Electron Localization

D-branes are extended objects in string theory where open strings can end. An electron in an atom orbits the nucleus — similarly, open strings can be "confined" near a D-brane, giving rise to localized charge. The quantization of electron orbits in shells finds its string-theoretic analog in the quantization of open string endpoints on D-branes. The ground-state geometry of a stack of D-branes in string theory reproduces the gauge theory description of atomic/nuclear physics.

Compactification and the Periodic Table

In string theory, the extra 6 dimensions are compactified on a Calabi-Yau manifold. The topology and geometry of this manifold determines the gauge group and matter content of the effective 4D theory — i.e., it determines which "atoms" can exist. Different Calabi-Yau compactifications can produce the Standard Model gauge group \(SU(3)\times SU(2)\times U(1)\), the symmetry underlying all atomic physics.

XVIII. Carl Friedrich Gauss — The Prince of Mathematicians

Gauss's contributions span number theory, differential geometry, electromagnetism, and complex analysis — all of which are central to modern physics.

Gaussian Curvature and Einstein's GR

Gauss (1827) defined the intrinsic curvature of a surface as \(K = \kappa_1\kappa_2\) (product of principal curvatures). He proved the Theorema Egregium: \(K\) depends only on the metric of the surface, not its embedding. This was the seed of Riemannian geometry, which Einstein used for GR:

$$K\text{ (Gauss, 2D)} \xrightarrow{\text{Riemann}} R^{\mu\nu\rho\sigma}\text{ (4D)} \xrightarrow{\text{contraction}} G_{\mu\nu} = \frac{8\pi G}{c^4}T_{\mu\nu}$$

Gaussian Integrals in Quantum Mechanics

The most fundamental integral in quantum mechanics and quantum field theory is the Gaussian:

$$\int_{-\infty}^\infty e^{-ax^2}\,dx = \sqrt{\frac{\pi}{a}},\qquad\int_{-\infty}^\infty e^{-ax^2+bx}\,dx = \sqrt{\frac{\pi}{a}}\,e^{b^2/4a}$$
Why Gaussians Are Everywhere in QM

The ground state of every harmonic oscillator is Gaussian: \(\psi_0(x) = \pi^{-1/4}e^{-x^2/2}\). The Gaussian is the minimum uncertainty state — it simultaneously saturates \(\sigma_x\sigma_p = \hbar/2\). Every free quantum field (in perturbation theory) is a collection of harmonic oscillators, so every vacuum state is a Gaussian in field space. Gaussian integrals are exactly solvable and generate the propagators that underlie all perturbation theory via Wick's theorem.

Gauss's Law in QM and String Theory

Gauss's law \(\nabla\cdot\mathbf{E} = \rho/\varepsilon_0\) (one of Maxwell's equations) has deep quantum mechanical and string-theoretic meaning:

Gauss and Complex Analysis

Gauss pioneered complex integration, leading to the residue theorem. In string theory, scattering amplitudes are computed as complex integrals over the moduli space of Riemann surfaces — directly using Gauss's complex function theory.

XIX. Maxwell's Theory — From Electromagnetism to Quantum Fields

James Clerk Maxwell's four equations (1865) unified electricity, magnetism, and light — and contained the seeds of both quantum mechanics and string theory.

Maxwell's Equations (covariant form) $$\partial_\nu F^{\mu\nu} = \mu_0 J^\mu,\qquad \partial_{[\mu}F_{\nu\rho]} = 0$$ $$F_{\mu\nu} = \partial_\mu A_\nu - \partial_\nu A_\mu,\quad\text{(field strength from 4-potential }A_\mu)$$

Component forms: \(\nabla\cdot\mathbf{E} = \rho/\varepsilon_0\) (Gauss), \(\nabla\cdot\mathbf{B}=0\) (no monopoles), \(\nabla\times\mathbf{E}=-\partial_t\mathbf{B}\) (Faraday), \(\nabla\times\mathbf{B}=\mu_0(\mathbf{J}+\varepsilon_0\partial_t\mathbf{E})\) (Ampère-Maxwell).

XX. Gauge Invariance — Maxwell's Greatest Legacy

Maxwell's equations are invariant under the gauge transformation \(A_\mu\to A_\mu + \partial_\mu\lambda\). This is the deepest structure in the theory — it determines everything else.

Gauge Invariance in QM (Minimal Coupling)

When an electron (charge \(q\)) moves in an electromagnetic field, the Schrödinger equation becomes:

$$i\hbar\frac{\partial\psi}{\partial t} = \frac{1}{2m}\left(-i\hbar\nabla - q\mathbf{A}\right)^2\psi + q\phi\psi$$

Under gauge transformation \(A_\mu\to A_\mu+\partial_\mu\lambda\), this is consistent only if \(\psi\to e^{iq\lambda/\hbar}\psi\). This local phase symmetry} of the wavefunction is the \(U(1)\) gauge symmetry of electrodynamics — demanding it forces the existence of the photon (Weyl 1929).

Yang-Mills Generalisation → Standard Model

Replacing \(U(1)\) with non-Abelian groups \(SU(2)\) (Yang-Mills, 1954) gives the weak force; \(SU(3)\) gives the strong force. The Standard Model gauge group is \(SU(3)\times SU(2)\times U(1)\). The demand for gauge invariance in the quantum Hilbert space forces the existence of photons, W/Z bosons, and gluons — all particles carrying the forces of nature.

Maxwell in String Theory

Open strings (Neveu-Schwarz sector, level 1) have the same quantum numbers as photons: massless, spin-1, transverse polarizations. The effective action for open strings on a D-brane is the Dirac-Born-Infeld (DBI) action:

$$S_{DBI} = -T_p\int d^{p+1}\xi\,e^{-\phi}\sqrt{-\det(G_{ab}+B_{ab}+2\pi\alpha'F_{ab})}$$

which reduces to Maxwell's action \(-\frac{1}{4}\int F_{\mu\nu}F^{\mu\nu}\) at small field strength. Every open string ending on a D-brane carries a Maxwell gauge field — string theory predicts} Maxwell's equations from consistency requirements.

XXI. String Theory — The Grand Synthesis

String theory replaces point particles with 1-dimensional vibrating strings. The length scale is the Planck length \(l_s = \sqrt{\alpha'} \sim 10^{-35}\) m.

The String Action

The Polyakov action (used in quantum string theory):

$$S_P = -\frac{T}{2}\int d^2\sigma\,\sqrt{-h}\,h^{ab}\partial_a X^\mu\partial_b X_\mu$$

where \(h_{ab}\) is the worldsheet metric, \(X^\mu(\sigma,\tau)\) maps the worldsheet into spacetime, and \(T=1/(2\pi\alpha')\) is the string tension. The Euler-Lagrange equations give \(\Box X^\mu = 0\) — a 2D wave equation.

Why Strings Unify All Forces

The closed string (loop) at level 2 has a massless spin-2 state — this is the graviton. No other consistent theory can include gravity and quantum mechanics simultaneously. The identification:

$$\text{Open string (level 1)} = \text{Photon/Gauge boson},\quad \text{Closed string (level 2)} = \text{Graviton}$$

unifies gravity (spin-2) with gauge forces (spin-1) in a single theory for the first time.

XXII. M-Theory & The Five String Theories

By 1994, there were five consistent superstring theories (Type I, IIA, IIB, Het-SO(32), Het-E₈×E₈). Witten's 1995 insight: all five are related by dualities and are limits of a single 11-dimensional M-theory.

String TheoryDim.Gauge GroupM-Theory Limit
Type IIA10\(U(1)\)M on \(S^1\), radius \(R=g_s l_s\)
Type IIB10None (self-dual)S-dual of itself
Type I10\(SO(32)\)Strong coupling of Het-SO(32)
Het-SO(32)10\(SO(32)\)Weak coupling of Type I
Het-E₈×E₈10\(E_8\times E_8\)M on \(S^1/\mathbb{Z}_2\)
The Web of Dualities

The five theories are connected by T-duality (\(R\to\alpha'/R\), exchanging winding and momentum modes) and S-duality (strong↔weak coupling). These dualities are symmetries of the string Hilbert space — they map one theory's states bijectively to another's. M-theory is the unique theory that contains all five as special limits.

XXIII. The Virasoro Algebra — Infinite-Dimensional Symmetry

The Virasoro algebra is the central extension of the Witt algebra (diffeomorphisms of the circle), and it governs conformal field theory and string theory. Its generators \(L_n\) act on the string Hilbert space:

$$[L_m,L_n] = (m-n)L_{m+n}+\frac{c}{12}m(m^2-1)\delta_{m+n,0}$$

This is an infinite-dimensional Lie algebra. The central charge \(c\) counts degrees of freedom: each free boson contributes \(c=1\), each free fermion \(c=1/2\). For the bosonic string in \(D\) dimensions: \(c=D\). Canceling the conformal anomaly (requiring the central charge to vanish on physical states) forces \(D=26\).

Highest Weight Representations

Physical string states are highest weight representations of the Virasoro algebra — states \(|h\rangle\) with \(L_0|h\rangle = h|h\rangle\) and \(L_n|h\rangle = 0\) for \(n>0\). The conformal weight \(h\) is related to the string mass by \(h = \alpha'M^2/4 + \text{const}\). The Hilbert space of string theory is thus classified by Virasoro representations — the mathematical structure Hilbert would have recognized.

XXIV. GNU Octave Examples

1 — Euler Zeta Function & String Theory Critical Dimension

Euler ζ(s) — String Zero-Point Energy & Critical DimensionGNU Octave
%% Euler/Riemann zeta function and its role in string theory
%% Shows zeta regularization: formally 1+2+3+... = ζ(-1) = -1/12
%% Derives bosonic string critical dimension D=26

clear; clc;

%% ─── Zeta function via Euler-Maclaurin ───────────────────────
function z = zeta_approx(s, Nmax)
  % Compute ζ(s) = Σ 1/n^s for Re(s)>1 (direct), analytic cont. for others
  if real(s) > 1
    z = sum((1:Nmax).^(-s));
  else
    % Use functional equation: ζ(s) = 2^s π^{s-1} sin(πs/2) Γ(1-s) ζ(1-s)
    s2 = 1-s;
    z2 = sum((1:Nmax).^(-s2));
    z = 2^s * pi^(s-1) * sin(pi*s/2) * gamma(1-s) * z2;
  end
end

Nmax = 50000;

%% Known values
printf('Euler-Riemann Zeta Function Values:\n');
printf('ζ(2) = π²/6   = %.6f  (computed: %.6f)\n', pi^2/6, zeta_approx(2,Nmax));
printf('ζ(4) = π⁴/90  = %.6f  (computed: %.6f)\n', pi^4/90, zeta_approx(4,Nmax));
printf('ζ(0) = -1/2   = %.6f  (computed: %.6f)\n', -0.5, zeta_approx(0,Nmax));
printf('ζ(-1)= -1/12  = %.6f  (computed: %.6f)  ← String theory!\n', -1/12, zeta_approx(-1,Nmax));
printf('ζ(-3)= 1/120  = %.6f  (computed: %.6f)\n', 1/120, zeta_approx(-3,Nmax));

%% ─── String zero-point energy regularization ─────────────────
printf('\n── String Theory Zero-Point Energy ──\n');
printf('Formally: Σ_{n=1}^∞ n/2 = (1/2)·ζ(-1) = (1/2)·(-1/12) = -1/24\n');
a_bosonic = (1/2) * (-1/12);  % per transverse dimension

%% Critical dimension from mass condition M²≥0 for lowest state
% Open string: α'M² = N + a,  where a = (D-2)·(-1/24)
% Massless photon requires N=1 state to have M²=0: 1+a=0 → a=-1
% So: (D-2)·(-1/24) = -1 → D-2 = 24 → D = 26
for D = [4 10 11 26]
  a = (D-2) * a_bosonic;
  m2_photon = 1 + a;  % at N=1 level
  printf('D=%2d: a = %7.4f,  α′M²(N=1) = %7.4f %s\n', D, a, m2_photon, ...
    abs(m2_photon)<1e-10?' ← MASSLESS PHOTON (critical!)':'');
end

%% ─── Euler product for the bosonic string partition function ──
printf('\n── String partition function: Z(q) = Σ p(n)·q^n ──\n');
printf('   = Π_{n=1}^∞ 1/(1-q^n)^24  (24 transverse bosons)\n');
q = 0.5;  Ncut = 30;
% Euler product
Z_euler = prod((1-q.^(1:Ncut)).^(-24));
% Partition number expansion: p(n) = # ways to write n as sum of positive integers
% Ramanujan-Euler: τ(n) appears in the discriminant function
printf('Z(q=0.5) = %.4f\n', Z_euler);

%% Plot ζ(s) on real axis
figure(1); clf;
s_neg = linspace(-5, 0, 200);
s_pos = linspace(1.05, 6, 200);
z_neg = arrayfun(@(s) zeta_approx(s,10000), s_neg);
z_pos = arrayfun(@(s) zeta_approx(s,10000), s_pos);
subplot(1,2,1);
plot(s_neg, z_neg, 'b-', s_pos, z_pos, 'r-', 'LineWidth', 2);
hold on;
plot(-1, -1/12, 'k*', 'MarkerSize', 14);
text(-1, -1/12+0.15, 'ζ(-1)=-1/12');
plot(get(gca,'XLim'),[0 0],'k:');
legend({'Re(s)<1 (analytic cont.)','Re(s)>1 (series)','String critical point'});
title('Euler-Riemann ζ(s)'); xlabel('s'); ylabel('ζ(s)'); grid on; ylim([-2 5]);

2 — Gaussian Path Integral (Monte Carlo)

Feynman Path Integral — Monte Carlo SimulationGNU Octave
%% Monte Carlo evaluation of the Feynman path integral
%% Z = ∫D[x] exp(-S_E[x]/ℏ)  (Euclidean time = imaginary time)
%% For harmonic oscillator: compare MC result to exact propagator

clear; clc; randn('state', 42);

hbar = 1; m = 1; omega = 1;
beta  = 4;    % inverse temperature β = ℏ/k_BT
N_t   = 50;   % time slices
dtau  = beta/N_t;   % Euclidean time step
N_mc  = 50000;    % MC sweeps
delta = 0.8;       % step size

%% Euclidean action for harmonic oscillator
% S_E = ∫(m/2 ẋ² + mω²x²/2)dτ ≈ Σ_k [m(x_{k+1}-x_k)²/(2dτ) + mω²x_k²dτ/2]
function S = action_E(x, m, omega, dtau)
  xp = circshift(x,-1);  % periodic BC
  S = sum( m*(0.5/dtau)*(xp-x).^2 + m*omega^2*dtau/2*x.^2 );
end

%% Metropolis algorithm
x = zeros(1, N_t);   % start at x=0
S_curr = action_E(x, m, omega, dtau);
accept = 0;
x2_acc = zeros(1, N_t);
n_meas = 0;

for sweep = 1:N_mc
  for j = 1:N_t
    x_new = x;
    x_new(j) = x(j) + delta*randn();
    S_new = action_E(x_new, m, omega, dtau);
    if rand() < exp(-(S_new-S_curr)/hbar)
      x = x_new; S_curr = S_new; accept++;
    end
  end
  if sweep > N_mc/5  % skip thermalization
    x2_acc += x.^2;
    n_meas++;
  end
end

%% Results
x2_mean = mean(x2_acc) / n_meas;
% Exact: ⟨x²⟩ = ℏ/(2mω) · coth(βℏω/2)
x2_exact = hbar/(2*m*omega) * coth(beta*hbar*omega/2);
printf('Monte Carlo path integral results:\n');
printf('⟨x²⟩ MC    = %.4f\n', x2_mean);
printf('⟨x²⟩ exact = %.4f  (coth formula)\n', x2_exact);
printf('Error      = %.2e\n', abs(x2_mean-x2_exact));
printf('Acceptance = %.1f%%\n', 100*accept/(N_mc*N_t));

%% Ground state energy: E_0 = ℏω⟨x²⟩·mω²/2... use virial: E_0 = mω²⟨x²⟩
E0_mc = m*omega^2*x2_mean;  % virial theorem contribution
printf('E₀ (MC, Virial/2) ≈ %.4f  Exact: %.4f ℏω\n', E0_mc, hbar*omega/2);

%% ─── Gaussian integral analytic benchmark ────────────────────
printf('\n── Gaussian Integral Benchmark (Gauss) ──\n');
printf('∫ exp(-ax²)dx = √(π/a):\n');
for a = [0.5 1 2 5]
  N2 = 10000;
  x2 = linspace(-20,20,N2);
  I_num = trapz(x2, exp(-a*x2.^2));
  I_exact = sqrt(pi/a);
  printf('  a=%4.1f: numeric=%.5f  exact=%.5f  err=%.2e\n', a, I_num, I_exact, abs(I_num-I_exact));
end

3 — Hilbert Space Operations & Infinite Dimensions

Hilbert Space — Inner Products, Completeness, ProjectionsGNU Octave
%% Demonstration of Hilbert space L²([0,L]) operations
%% - Orthonormal basis (Fourier/infinite square well)
%% - Inner products, Parseval's theorem
%% - Projection onto subspaces (truncated bases)
%% - Symmetry operators (unitary transformations)

clear; clc;
N_grid = 2000;
L = 1;
x = linspace(0, L, N_grid);
dx = L/(N_grid-1);

%% ─── Orthonormal basis: ψ_n(x) = √(2/L) sin(nπx/L) ─────────
function psi = basis(n, x, L)
  psi = sqrt(2/L) * sin(n*pi*x/L);
end

printf('Orthonormality check ⟨ψ_m|ψ_n⟩ = δ_mn:\n');
N_check = 5;
for_data = zeros(N_check);
for n = 1:N_check
  for mm = 1:N_check
    psi_n = basis(n, x, L);
    psi_m = basis(mm, x, L);
    for_data(n,mm) = trapz(x, psi_n.*psi_m);
  end
end
printf('Max off-diagonal: %.2e  (should be ~0)\n', max(abs(for_data - eye(N_check)), [], 'all'));

%% ─── Parseval's theorem: ‖f‖² = Σ|c_n|² ─────────────────────
% Test function: f(x) = x(1-x) on [0,1]
f = x .* (1-x);
norm2_direct = trapz(x, f.^2);
% Compute Fourier-like coefficients c_n = ⟨ψ_n|f⟩
N_terms = 50;
c_n = zeros(1, N_terms);
for n = 1:N_terms
  c_n(n) = trapz(x, basis(n,x,L).*f);
end
norm2_parseval = cumsum(c_n.^2);
printf('\nParseval theorem for f(x)=x(1-x):\n');
printf('‖f‖² direct  = %.6f\n', norm2_direct);
printf('Σ|c_n|² N=10 = %.6f\n', norm2_parseval(10));
printf('Σ|c_n|² N=50 = %.6f  (approaches %.6f)\n', norm2_parseval(50), norm2_direct);

%% ─── Symmetry operator: parity P, translation T ────────────
printf('\nSymmetry operators on Hilbert space:\n');
% Parity: P·ψ(x) = ψ(L-x) on [0,L]
% Basis functions: P·ψ_n = (-1)^(n+1) ψ_n (odd n→even parity)
for n = 1:4
  psi_n = basis(n, x, L);
  parity_n = basis(n, L-x, L);
  eigenval = trapz(x, psi_n.*parity_n) / trapz(x, psi_n.^2);
  printf('  ψ_%d parity eigenvalue: %+.1f (expect %+.1f)\n', n, eigenval, (-1)^(n+1));
end

%% ─── Projection onto finite subspace (dimension reduction) ──
printf('\nProjection quality vs basis size N_basis:\n');
for N_basis = [1 3 5 10 20]
  f_proj = zeros(1, N_grid);
  for n = 1:N_basis
    f_proj += c_n(n) * basis(n, x, L);
  end
  error2 = trapz(x, (f-f_proj).^2);
  printf('  N=%2d:  ‖f-P_N f‖² = %.2e\n', N_basis, error2);
end

figure(3); clf; hold on;
plot(x, f, 'k-', 'LineWidth', 2);
cols = {'r','g','b','m'};
for ii = 1:4
  Nb = [1 3 10 30](ii);
  fp = zeros(1,N_grid);
  for n=1:Nb, fp += c_n(n)*basis(n,x,L); end
  plot(x,fp,cols{ii},'DisplayName',sprintf('N=%d',Nb));
end
legend('Location','north'); grid on;
title('Hilbert Space Projection: f(x)=x(1-x) onto finite bases');
xlabel('x'); ylabel('f(x) and projections');

4 — Maxwell's Wave Equations (Finite Difference Solver)

Maxwell's Equations — 1D EM Wave Propagation (FDTD)GNU Octave
%% Finite-Difference Time-Domain (FDTD) solver for Maxwell's equations in 1D
%% Simulates E and H fields from a Gaussian pulse source
%% Shows dispersion relation ω = ck and gauge invariance

clear; clc;
c = 1;       % speed of light (natural units)
N = 500;     % spatial grid points
L = 10;      % domain length
dx = L/N;
dt = 0.4*dx/c;  % CFL condition: dt < dx/c
Nt = 2000;   % time steps

%% Initialize fields
E = zeros(1, N);  % Electric field
H = zeros(1, N);  % Magnetic field
x = (0:N-1)*dx;

%% Media: ε(x) = 1 everywhere except a dielectric slab
eps = ones(1, N);
eps(N/2:N/2+50) = 4;  % ε=4 slab (n=2)
mu  = ones(1, N);      % permeability

%% FDTD Yee algorithm (Faraday + Ampere):
%% H^{n+1/2}_{j+1/2} = H^{n-1/2}_{j+1/2} - (dt/mu*dx)(E^n_{j+1}-E^n_j)
%% E^{n+1}_j = E^n_j - (dt/eps*dx)(H^{n+1/2}_{j+1/2}-H^{n+1/2}_{j-1/2})

snaps = {}; snap_t = round(linspace(0,Nt,6));
t = 0;

for n2 = 1:Nt
  % Source: Gaussian pulse at left boundary
  t0 = 1.0; sigma = 0.3;
  E(1) = exp(-(t-t0)^2/(sigma^2)) * sin(20*pi*(t-t0));

  % Update H (half-step)
  H(1:N-1) = H(1:N-1) - (dt./(mu(1:N-1)*dx)) .* (E(2:N) - E(1:N-1));

  % Update E (full step)
  E(2:N-1) = E(2:N-1) - (dt./(eps(2:N-1)*dx)) .* (H(2:N-1) - H(1:N-2));

  t += dt;
  if ismember(n2, snap_t)
    snaps{end+1} = struct('E',E,'H',H,'t',t);
  end
end

figure(4); clf;
for k = 1:length(snaps)
  subplot(3,2,k); hold on;
  plot(x, snaps{k}.E, 'b-', 'LineWidth', 1.5);
  plot(x, snaps{k}.H, 'r--', 'LineWidth', 1);
  fill([x(N/2) x(N/2+50) x(N/2+50) x(N/2)], [-1 -1 1 1], ...
       'y', 'FaceAlpha', 0.15, 'EdgeColor', 'none');
  title(sprintf('t = %.2f', snaps{k}.t));
  legend({'E field','H field','dielectric'},'FontSize',7);
  grid on; ylim([-1.2 1.2]);
end
suptitle('Maxwell FDTD: Gaussian pulse hitting dielectric slab');

5 — Gauss-Bonnet Theorem on Curved Surfaces

Gauss-Bonnet Theorem — Curvature ↔ TopologyGNU Octave
%% Numerically verify the Gauss-Bonnet theorem:
%% ∫∫_Σ K dA = 2π·χ(Σ)
%% For sphere: K=1/R², ∫K dA = 4π = 2π·χ(S²) = 2π·2  ✓
%% For torus: K varies, ∫K dA = 0 = 2π·χ(T²) = 2π·0   ✓

clear; clc;

%% ─── Sphere of radius R ──────────────────────────────────────
printf('Gauss-Bonnet: Sphere\n');
R = 3;
N_theta = 500; N_phi = 500;
theta = linspace(0.001, pi-0.001, N_theta);  % avoid poles
phi   = linspace(0, 2*pi, N_phi);
[T,P] = meshgrid(theta, phi);
% Gaussian curvature: K = 1/R² (constant on sphere)
K_sphere = 1/R^2 * ones(size(T));
% Area element: dA = R²sinθ dθdφ
dA_sphere = R^2 * sin(T);
% Numerically integrate
dtheta = theta(2)-theta(1); dphi = phi(2)-phi(1);
GBint_sphere = sum(K_sphere(:) .* dA_sphere(:)) * dtheta * dphi;
chi_sphere = GBint_sphere / (2*pi);
printf('  ∫K dA = %.4f  (exact: 4π = %.4f)  χ = %.3f (exact: 2)\n', GBint_sphere, 4*pi, chi_sphere);

%% ─── Torus: R_major=3, R_minor=1 ─────────────────────────────
printf('Gauss-Bonnet: Torus\n');
R_maj = 3; R_min = 1;
theta_t = linspace(0,2*pi,N_theta);
phi_t   = linspace(0,2*pi,N_phi);
[TT,PP] = meshgrid(theta_t, phi_t);
% Gaussian curvature of torus: K = cos(θ)/(R_min(R_maj+R_min·cos(θ)))
K_torus = cos(TT) ./ (R_min .* (R_maj + R_min*cos(TT)));
% Area element: dA = (R_maj + R_min·cosθ)·R_min dθdφ
dA_torus = (R_maj + R_min*cos(TT)) * R_min;
dtheta_t = theta_t(2)-theta_t(1); dphi_t = phi_t(2)-phi_t(1);
GBint_torus = sum(K_torus(:) .* dA_torus(:)) * dtheta_t * dphi_t;
chi_torus = GBint_torus / (2*pi);
printf('  ∫K dA = %.4f  (exact: 0)  χ = %.3f (exact: 0)\n', GBint_torus, chi_torus);

%% ─── String Theory connection ────────────────────────────────
printf('\nString coupling expansion (Euler characteristic):\n');
g_s = 0.1;  % string coupling
printf('%-12s %-6s %-10s %-10s\n','Surface','χ','g_s^(2-χ)','Relative weight');
surfaces = {'Sphere g=0',2; 'Torus g=1',0; 'Genus-2 g=2',-2; 'Genus-3 g=3',-4};
ref = g_s^(2-surfaces{1,2});
for k = 1:size(surfaces,1)
  chi_s = surfaces{k,2};
  w = g_s^(2-chi_s);
  printf('%-12s %-6d %-10.4g %-10.4g\n', surfaces{k,1}, chi_s, w, w/ref);
end

6 — String Worldsheet Visualization

String Theory Worldsheet — Classical & Quantum ModesGNU Octave
%% String worldsheet visualization and mode expansion
%% X^μ(σ,τ) = x^μ + α'p^μτ + i√(α'/2) Σ_{n≠0} α_n^μ/n e^{-in(τ-σ)}
%% Shows: classical string, quantum fluctuations, mass spectrum

clear; clc;
alpha_prime = 1;   % Regge slope (string length²)
Nmode = 8;          % number of modes

%% ─── Open string mode expansion (2D: X=position, τ=time) ────
sigma = linspace(0, pi, 100);    % string coordinate [0,π]
tau_arr   = linspace(0, 2*pi, 80); % worldsheet time
[SIG, TAU] = meshgrid(sigma, tau_arr);

% Random mode amplitudes (from quantum vacuum)
randn('state',123);
amp = randn(1, Nmode) / (1:Nmode);  % α_n ~ 1/n (vacuum level)

% Worldsheet: X(σ,τ) — 1 spatial dimension for visualization
X = 0.1*TAU;   % CM motion (p^μτ term)
for n = 1:Nmode
  X += sqrt(alpha_prime/2) * amp(n)/n * cos(n*SIG) .* cos(n*TAU);
end

%% Open string Neumann BC: ∂X/∂σ = 0 at σ=0,π → cosine modes ✓
dX_dsig_left  = abs(mean( (X(:,2)-X(:,1))/(pi/(100-1)) ));
dX_dsig_right = abs(mean( (X(:,end)-X(:,end-1))/(pi/(100-1)) ));
printf('Open string BC check: |∂X/∂σ|_{σ=0} = %.2e  |_{σ=π} = %.2e\n', dX_dsig_left, dX_dsig_right);

figure(6); clf;
subplot(1,2,1);
surf(SIG, TAU, X, 'EdgeColor','none'); colormap('copper');
title('Open String Worldsheet X(σ,τ)');
xlabel('σ (string coord)'); ylabel('τ (worldsheet time)'); zlabel('X'); view(45,25);

%% ─── Mass spectrum: M² = (N-1)/α' for open string ───────────
subplot(1,2,2); hold on; grid on;
N_levels = 0:8;
M2 = (N_levels - 1)/alpha_prime;  % open string mass²
M2_closed = (2*N_levels - 2)/alpha_prime;  % closed string (left+right)
for N2 = N_levels
  m2_val = M2(N2+1);
  col = m2_val<0?'r':m2_val==0?'g':'b';
  plot(N2, m2_val, 'o', 'Color',col, 'MarkerSize',10, 'MarkerFaceColor',col);
  text(N2+0.1, m2_val+0.15, sprintf('N=%d',N2), 'Color',col);
end
plot(N_levels, M2, 'b-'); plot(N_levels, M2_closed, 'm--');
xline(0,'k:'); yline(0,'k:');
legend({'Open string','Closed string'},'Location','northwest');
title('String Mass Spectrum: α''M² = N-1');
xlabel('Level N'); ylabel("α'M²");
printf('N=1: massless photon (M²=0) ← gauge boson of U(1)\n');
printf('N=2 closed string: massless graviton (M²=0) ← gravity!\n');

XXV. Interactive Simulations

Simulation I — Euler's Identity on the Complex Plane

Watch \(e^{i\theta}\) trace the unit circle as \(\theta\) varies from 0 to \(2\pi\). At \(\theta = \pi\): \(e^{i\pi} = -1\), giving the famous identity \(e^{i\pi}+1=0\). This is the foundation of quantum wave functions.

Euler's Formula — e^(iθ) on the Complex Plane
0.000
e^(i·0) = 1 + 0i = cos(0) + i·sin(0)

Simulation II — Fermat's Principle of Least Time

Drag the light path endpoint to see how light chooses the path of minimum time across two media. The optimal path satisfies Snell's law \(n_1\sin\theta_1 = n_2\sin\theta_2\).

Fermat's Principle — Least Time Path
1.0
2.5
Optimal (Fermat) vs straight path comparison

Simulation III — Feynman Path Integral: Sum Over Histories

Shows multiple paths from \(x_i\) to \(x_f\), each contributing \(e^{iS/\hbar}\). Near the classical path, phases add constructively; elsewhere they cancel. Reduce \(\hbar\) to see classical behavior emerge.

Feynman Path Integral — Sum Over Paths
2.0
30
Total amplitude = Σ e^(iS_k/ℏ)

Simulation IV — Hilbert Space: Projections & Symmetry

Visualize a state vector in a 3D (truncated) Hilbert space. See how it projects onto the basis, how symmetry operations (rotations = unitary maps) act, and how orthonormality looks geometrically.

Hilbert Space Geometry — State Vector & Projections
1.00
0.00
|ψ⟩ decomposed in chosen basis — Parseval: Σ|cn|² = 1

Simulation V — Gaussian Curvature: Gauss-Bonnet in Action

Visualize Gaussian curvature \(K = \kappa_1\kappa_2\) on a surface. Red = positive curvature (sphere-like), blue = negative (saddle), green = zero (flat). The integral \(\int K\,dA = 2\pi\chi\) depends only on topology.

Gaussian Curvature & Gauss-Bonnet Theorem
2.5
Computing ∫K dA…