...
running...
How to use
The oscilloscope (left) shows the source voltage (grey), the voltage across the capacitor (blue) and the current (orange, scaled) while the circuit is solved step by step. On the right the resonance curve shows how much current the circuit passes at each frequency, with the grey dashed line at the natural frequency f0, and the lower plot shows the phase between voltage and current. The dots mark your drive frequency.
Try: set the source to a step and watch the circuit ring at f0 and die away; lower the resistance to make the peak sharper (higher Q); drive at f0 and the current is largest and in phase with the source; drive far above or below it and the current shrinks as the inductor or capacitor blocks it.
The science
Kirchhoff's voltage law for a series RLC loop gives L dI/dt + R I + q/C = V(t), I = dq/dt, integrated here with a fourth-order Runge-Kutta scheme. The natural (undamped) frequency is f0 = 1/(2π√(LC)), the damped ringing frequency is ωd = √(1/LC − (R/2L)²) and the amplitude shrinks by exp(−R Td/2L) each cycle. The impedance is |Z| = √(R² + (ωL − 1/ωC)²) so the current amplitude is V/|Z|, peaking at V/R when ω = 1/√(LC). The quality factor is Q = ω₀L/R and the half-power bandwidth is f₀/Q = R/(2πL).
Simplifications: ideal components (no inductor winding resistance, capacitor leakage or parasitic capacitance), a source with zero internal resistance, and an ideal square wave with infinitely sharp edges.
What is checked and why you can trust it
Every time the page loads, and whenever you press Re-run check, the simulation evaluates its own mathematics against an independent reference, such as a closed-form formula, a finite-difference derivative or an exhaustive count. Each line above reports PASS or FAIL together with the measured numbers, so you can see by how much it agrees. Results are also published on window.__msChecks for automated testing. The check never uses the same code path as the animation it validates, otherwise it would only confirm itself.
How to read a failure: a FAIL line means the measured discrepancy exceeded the stated tolerance for the current slider values. Try Reset, then move the sliders back toward their defaults; if a check still fails at the defaults it is a bug worth reporting. Tolerances are chosen from the numerical method itself, never tuned to make a test pass: round-off level (1e-9) for exact algebra, about 1e-3 for finite differences and Monte Carlo estimates with a few hundred thousand samples, and a documented margin for stochastic learning runs.
Reproducibility: the particle and pen simulations use the browser random generator for initial positions, so exact pixels differ between visits, but the checks depend only on mathematics and not on those positions. Fixed wave tables (curl noise) and fixed grammars (L-system) are deterministic.
This is an educational model. It shows the mechanism clearly, but it is deliberately simplified; the science panel lists what was left out.