A wave simulation is changing data indexed by position and time. The line on screen is one rendering of samples; it is not the solver. Separating these jobs is what lets a reader inspect boundaries, accuracy, energy drift, and stability instead of trusting a convincing animation.
Δx. For a physical string, keep both displacement and velocity arrays; for an analytic fixture, compute samples from a function without pretending it is a numerical solve. Rendering reads a snapshot and never owns the state transition.An analytic travelling-wave fixture is
\[y(x,t)=A\sin(kx-\omega t),\qquad v=\frac{\omega}{k}=\lambda f\]Its amplitude A changes vertical scale, k sets spatial repetition, and ω sets temporal repetition. A fixed phase such as kx − ωt = 0 moves at ω/k. That makes a good test oracle: sample at two known times, estimate crest displacement, and compare it with the chosen speed. It does not by itself solve a string, because it contains no array coupling, boundaries, or numerical error.
Adjust amplitude and wavelength. The plotted line is a view of sampled displacement data; its speed is frequency divided by wave number.
Amplitude 1.0; wavelength 3.0 m; model speed 1.91 m/s.
A minimal finite-difference string model has a different contract. Its acceleration at cell i is proportional to the curvature inferred from neighbours, approximately (y[i+1] − 2y[i] + y[i−1]) / Δx². Integrate that acceleration into velocity and displacement, then overwrite or otherwise enforce endpoint values according to the boundary model. Store Δx, Δt, and the chosen integrator with every output. If an update becomes unstable, a rapidly growing line is evidence of an invalid numerical configuration, not dramatic physics.
Prediction: Changing amplitude changes an ideal profile's displacement scale but not its phase speed; refining a stable numerical grid should improve agreement with the same analytic fixture.
Use the sampler to double amplitude while holding frequency and wavelength fixed. Then outline the two arrays a string solver needs, the neighbour values used for an interior-cell update, and the assertion for a fixed left endpoint. Finally state which configuration values must be saved to repeat the run.Store waves as position-indexed state, keep the update rule independent from rendering, and use analytic waves as fixtures rather than substitutes for a solver. Validate speed, boundaries, stability, and refinement from data before interpreting a plot.
Treat the lesson as a small function before treating it as a fact to memorize. Give every value a unit, keep only the state needed for the next step, and make the output easy to inspect.
\[\text{observable output} = f(\text{inputs},\,\text{state})\]For Waves as Propagating Data, write down the quantities you can control, the values your program must retain, and the result a reader could inspect. In Waves I — Mechanical Waves, the useful program is not the drawing: it is the smallest explicit model that makes a prediction you can test.
Prediction: changing one declared input while holding the others fixed should change only the outputs that the model connects to that input. Choose one input, predict the direction of change, then check a limiting case such as zero, a symmetric arrangement, or a familiar low-speed or small-change approximation.
This lesson is a teaching model, not a complete simulator. Before using it outside the stated question, check which interactions, scales, uncertainties, boundary conditions, and measurement limits it leaves out.
Treat Waves as Propagating Data as a contract: named inputs and units enter a rule, the rule produces an observable result, and a known limit or invariant checks whether the implementation deserves trust.
Represent a wave as sampled state over space and keep its rendering separate from the update rule.