Advanced maths

One dimensional wave equation calculator from initial displacement and velocity

The one-dimensional wave equation evolves both an initial displacement and an initial velocity.

Your numbers

Calculated on your device. Your inputs aren’t sent to us.

Your result

Ready when you are

Enter your inputs and select Calculate.

Report an issue

Behind the numbers

How this calculation works

The one-dimensional wave equation evolves both an initial displacement and an initial velocity. This calculator applies a centered second-order scheme with a matching second-order first step and fixed zero endpoints. It enforces the CFL condition before computing the requested finite-time displacement.

THE FORMULAu_tt=c²u_xx; u_i^(n+1)=2u_i^n−u_i^(n−1)+(c dt/dx)² Delta²u_i^n.

A worked example

With initial sin(pi x), zero velocity and unit speed on [0,1], the continuous solution is cos(pi t)sin(pi x). The prefilled grid and step count reproduce the corresponding discrete sine mode. At t=0.1 its peak is near cos(pi/10), while refinement reduces the phase difference.

Good to know

3–101 matching displacement and velocity samples, equally spaced, with zero endpoint values in both lists. Positive speed and at most 5,000 steps. CFL c dt/dx≤1 is mandatory. No forcing, damping, variable speed or nonlinear-wave claim.

A wave needs displacement and velocity

The wave equation is second order in time, so the starting displacement alone is insufficient. The initial velocity controls the first motion even when the initial shape is unchanged. Both lists refer to the same equally spaced nodes, and their endpoint entries must match the fixed-zero boundary assumptions.

The first time step uses the selected velocity and a half-step acceleration term from the spatial second difference. Treating it like every later two-level recurrence would require an unknown previous profile. The explicit first-step formula supplies the necessary second-order start without inventing a hidden earlier displacement.

The fixed-end wave retains shape while its amplitude oscillatesInitial velocity: 0Exact factor: cos(πt)Enforce CFL ≤ 1
With initial sin(pi x), zero velocity and unit speed on [0,1], the continuous solution is cos(pi t)sin(pi x). The prefilled grid and step count reproduce the corresponding discrete sine mode. At t=0.1 its peak is near cos(pi/10), while refinement reduces the phase difference.

The First-order ODE solver and interactive slope field covers the nearby task. A spatial second-order hyperbolic PDE needs initial displacement and velocity plus boundary constraints.

The CFL condition controls the explicit scheme

For this centered explicit scheme, the ratio of wave speed times time step to spatial step must not exceed one. Increasing the final time without increasing the step count can violate that condition. The calculator rejects such inputs before time marching instead of returning an unstable trajectory and describing its growth as physical wave amplification.

A ratio within the stability limit still permits numerical dispersion: different spatial modes can travel or oscillate with altered phase. Finer mesh and smaller steps are needed when phase accuracy matters. Reporting the CFL value supports inspection but is not itself an error bar on the final displacement.

Boundaries and phase errors remain part of the model

The fixed endpoints are held at zero at every step, representing an idealized string with immobile ends. Velocity endpoints are also zero for consistency. Absorbing, free, driven or mixed boundaries would produce different reflections and need their own discretization; they are not approximated by quietly reusing these fixed-end formulas.

The single-sine example has both a continuous cosine-in-time solution and an exact modal recurrence for the discrete scheme. Independent tests compare these separately and examine refinement. The model does not include forcing, damping, nonlinear tension or a physical energy-loss mechanism, so numerical changes should not be interpreted as estimates of those effects.

Derive the first step and later centered updates

The scheme approximates utt=c²uxx on equally spaced nodes. With r=c dt/dx, later updates are uj(next)=2uj(current)−uj(previous)+r²[uj−1(current)−2uj(current)+uj+1(current)]. The first step also needs the entered velocity: uj(1)=uj(0)+dt vj(0)+(r²/2) times the initial second difference.

That special first step matters. Reusing the later formula without an earlier time level would silently impose the wrong initial velocity. Both endpoint displacement and endpoint velocity must be zero because the ends are fixed. Nonzero boundary forcing, damping and a variable propagation speed are different problems and are not inferred from an arbitrary initial list.

Work through a three-node pulse

Use displacement 0,1,0, velocity 0,0,0, length 1, speed 1, time 0.5 and two steps. Here dx=0.5, dt=0.25 and r=0.5. The first center value is 1+(0.25/2)(−2)=0.75. The next is 2×0.75−1+0.25(−1.5)=0.125.

The final list is therefore 0,0.125,0. This coarse-grid example verifies the update arithmetic, not high physical accuracy. A smooth sine initial shape on a refined grid is a better accuracy benchmark: with zero initial velocity, its continuous amplitude is cos(cπt/L). The oscillation changes sign over time, so a small or negative displacement is not automatically numerical decay or an error.

Choose steps from the CFL condition before running

The required condition c dt/dx≤1 becomes steps≥c×time/dx. Round that lower bound upward to an integer, then allow additional resolution for accuracy. Increasing the number of spatial nodes decreases dx, so a time-step count that was acceptable on the old grid can violate CFL after spatial refinement.

Meeting CFL is necessary for this scheme’s stability, but short wavelengths still experience numerical dispersion. Compare phase and amplitude at matching physical times as you refine the grid. Do not claim accurate travel times just because the program accepted the inputs. The returned CFL ratio documents the numerical setting; it is not an error estimate or a physical material parameter.

Interpret the final snapshot as part of a moving wave

A wave exchanges displacement and velocity energy rather than simply smoothing away an initial pulse. A final displacement near zero can occur when the motion is passing through equilibrium, even though velocity is large. This form displays the final displacement and does not return a full physical energy analysis or certify an invariant from that single snapshot.

Use compatible length, time and speed units, and sample the initial displacement and velocity on the same nodes. A directionally traveling pulse generally needs both initial fields; entering zero velocity produces a different superposition. Reflections from the zero fixed endpoints are already part of this model, while absorption and open boundaries would require another boundary treatment.

A few questions, answered

Why require an initial velocity?

The wave equation is second order in time and needs both initial displacement and velocity.

What if CFL exceeds one?

The explicit scheme is rejected; increase the time-step count or change the mesh/model.

Why does adding more spatial samples require more time steps?

It reduces dx. Since c dt/dx must remain at most one, dt must decrease accordingly to preserve stability.

Does zero final displacement mean the wave energy vanished?

No. The wave may be passing through equilibrium with nonzero velocity. A displacement snapshot alone does not determine total energy.

Find your calculator

Start typing to explore the library.