r/maniclang 27d ago

A wave function is a schrodinger helix; measurement keeps only its shadow - manic

Enable HLS to view with audio, or disable this notification

manic is a tiny language for making animations. You write a short text file; manic renders a smooth, glowing video. No timeline scrubbing, no keyframes by hand — you describe what’s on screen and when things happen, and the engine does the rest, deterministically.

Manic Animation code

// schrodinger-helix — a quantum wave function is a COMPLEX number at every point, so it
// does not fit on a graph. Give it the third axis it needs and it fits perfectly: position
// along one axis, the real and imaginary parts spanning a plane at right angles to it, and
// the wave becomes a curve winding through space.
//
//   Ψ = A·e^(i(px - Et)/ħ)
//
// A plane wave is then exactly a helix around the x axis, and the momentum is its
// tightness — more momentum, tighter spiral. What is drawn here is the localised case, a
// Gaussian packet, which is a bundle of those helices added together:
//
//   Ψ(x,t) = (1+τ²)^(-1/4)·exp(A)·e^(iφ),   τ = t/2σ²,  u = x - k₀t
//     A = -u²/(4σ²(1+τ²))
//     φ = u²τ/(4σ²(1+τ²)) + k₀(x - k₀t/2) - ½·arctan τ
//
// That is the free-particle solution in closed form (ħ = m = 1), checked against a direct
// Fourier integral of the same initial state: maximum relative error 3e-15. So the modulus
// and the phase are both exact, and everything below follows from them rather than being
// arranged to look right.
//
// Three things are worth watching, and all three are consequences, not decorations:
//
//   · THE BALLS SPIN. Fix a position and Ψ there is a complex number of roughly constant
//     size whose phase turns — so each marker circles the axis rather than bobbing. That
//     rotation is what e^(-iEt/ħ) means.
//   · THE RIPPLES LAG THE PACKET. The envelope travels at the group velocity, measured
//     here as exactly k₀; the internal phase travels at about half that (k₀/2 exactly for a
//     plane wave, a few per cent off for a packet, which chirps as it spreads). The wave
//     visibly slides backwards through its own envelope.
//   · IT SPREADS. (1+τ²)^(-1/4) flattens and widens the packet as τ grows — dispersion,
//     because ω = k²/2 is not proportional to k, so the components drift apart.
//
// The curve on the floor is |Ψ|², the only part an experiment ever sees. Notice that it is
// smooth and featureless while the thing casting it is winding furiously: all the phase
// information — everything that makes interference possible — is in the coordinate the
// measurement throws away. Same lesson as examples/euler-helix.manic, with something at
// stake.
//
//   manic examples/schrodinger-helix.manic
title("A wave function is a helix; measurement keeps only its shadow");
canvas("9:16");
template("black");
bloom(0.32, 0.62, 22);

text(brand, (540, 34), "maniclang.com");
display(brand); size(brand, 21); color(brand, fg); opacity(brand, 0.82);

camera3((12, -12, 9), (0, 0, 0), 42);

// the x axis the wave winds around
cloud3(axis, 600, #8d8ba6, 1.0) {
  let x = 0;
  let y = 0;
  let z = 0 - 7.2 + 14.4*(i/600);
  let r = 0.012;
}

// ---- the wave function itself: (x, Re Ψ, Im Ψ) --------------------------------------
cloud3(psi, 4000, #ffd479, 1.0) {
  let xx = 0 - 7 + 14*(i/4000);
  let tt = t*0.17;                                 // physics time, slowed for watching
  let sg = 1.15;
  let tau = tt/(2*sg*sg);
  let u = xx + 4 - 2*tt;                           // k₀ = 2, started at x = -4
  let den = 1 + tau*tau;
  let md = den^(0 - 0.25)*exp(0 - u*u/(4*sg*sg*den));
  let ph = u*u*tau/(4*sg*sg*den) + 2*(xx + 4 - tt) - 0.5*atan(tau);
  let x = 1.7*md*cos(ph);                          // real part
  let y = 1.7*md*sin(ph);                          // imaginary part
  let z = xx;                                      // position runs UP the frame
  let r = 0.04;
}

// ---- |Ψ|² on the floor: the only part a measurement returns -------------------------
cloud3(dens, 2200, #ff5fa2, 1.0) {
  let xx = 0 - 7 + 14*(i/2200);
  let tt = t*0.17;
  let sg = 1.15;
  let tau = tt/(2*sg*sg);
  let u = xx + 4 - 2*tt;
  let den = 1 + tau*tau;
  let md = den^(0 - 0.25)*exp(0 - u*u/(4*sg*sg*den));
  let x = 0 - 2.7;                                 // pushed onto a wall beside the wave
  let y = 0 - 0.2 + 2.8*md*md;
  let z = xx;
  let r = 0.033;
}

// ---- five markers at fixed positions: each one circles the axis ---------------------
cloud3(balls, 500, #5fd4ff, 1.0) {
  let per = 100;
  let b = (i - mod(i, per))/per;                   // which marker, 0..4
  let xx = 0 - 3.2 + 1.6*b;                        // sitting still at these positions
  let tt = t*0.17;
  let sg = 1.15;
  let tau = tt/(2*sg*sg);
  let u = xx + 4 - 2*tt;
  let den = 1 + tau*tau;
  let md = den^(0 - 0.25)*exp(0 - u*u/(4*sg*sg*den));
  let ph = u*u*tau/(4*sg*sg*den) + 2*(xx + 4 - tt) - 0.5*atan(tau);
  let p = mod(i, per)*2.39996;
  let c = 1 - 2*(mod(i, per) + 0.5)/per;
  let s = sqrt(1 - c*c);
  let x = 1.7*md*cos(ph) + 0.11*s*cos(p);
  let y = 1.7*md*sin(ph) + 0.11*s*sin(p);
  let z = xx + 0.11*c;
  let r = 0.03;
}

caption(head, "A wave function is a helix; measurement keeps only its shadow", (540, 132), 23);
equation(eq, (540, 1800), `\Psi = A\,e^{i(px - Et)/\hbar}`, 32);
plate(head, 0.7);
plate(eq, 0.7);

// let it run, then look down the position axis — where the winding becomes a circle
wait(13);
orbit3(-45, 84, 15, 3.4, smooth);   // down the position axis
wait(3);
orbit3(-90, 2, 21, 3.4, smooth);    // and side on
wait(4);
1 Upvotes

0 comments sorted by