Wave Equation Solver

JJ Ben-Joseph headshot JJ Ben-Joseph

Introduction: solving the fixed-end wave equation on a string

A fixed-end string is one of the clearest settings for seeing the wave equation in action, because the starting shape f(x) and starting motion g(x) fully determine how the disturbance begins to move. With this solver, you describe that initial state, choose the wave speed c, and control the spatial and temporal resolution with the grid and step settings so the browser can march the solution forward.

The calculations on this page use a simple explicit finite-difference update, so the spacing of the grid and the selected time steps affect both the appearance of the trace and the amount of detail you can see. A smooth pluck may look almost identical on a coarse grid, while a sharper profile can become jagged unless you give the string enough sample points.

The sections below explain what the solver is doing, how to choose expressions that match a vibrating-string problem, how to read the sampled displacement, and which simplifying assumptions matter most before you rely on the output.

What vibrating-string problem does this calculator solve?

This wave equation solver is designed for a one-dimensional string with fixed ends, where the function f(x) supplies the initial displacement and g(x) supplies the initial velocity. The page turns that starting state into a sequence of displacement samples so you can see how the string evolves over the interval from x = 0 to x = 1.

If you are deciding whether to use this calculator, it helps to phrase the question as a string problem instead of a generic math problem. For example: how does a plucked string move when the initial motion is zero, how much does the trace change if the initial velocity is not flat, or how many grid points do you need before the curve looks smooth enough to trust? Questions like those line up directly with the fields on the form.

This is especially useful when you want to compare one vibration setup against another. A change in f(x) affects the shape you start from, a change in g(x) alters the initial push or pull, and a change in c changes how quickly the disturbance travels through the mesh.

How to use the wave equation solver for a fixed-end string

  1. Enter Initial displacement f(x) as the expression that describes the string’s starting shape.
  2. Enter Initial velocity g(x) as the expression that describes how the string is moving at t = 0.
  3. Enter Wave speed c as the propagation speed for the medium.
  4. Enter Grid points to choose how finely the string is sampled in space.
  5. Enter Time steps to choose how many updates the simulation should run.
  6. Run the calculation to refresh the displacement profile and the result panel.
  7. Check the output's shape, sign, and overall size before comparing scenarios.

Using the wave equation solver is mostly a matter of keeping the expressions and resolution consistent with the problem you want to study. The function fields should return real values for the entire x-domain, the wave speed must be positive, and the grid and step counts should be large enough to show the motion without turning the result into a blur.

If you are comparing multiple runs, keep a note of the exact f(x), g(x), c, grid, and step settings so you can reproduce the same string later. That makes it much easier to tell whether a difference in the output came from the physics you entered or from a change in the discretization.

Inputs: choosing f(x), g(x), c, grid points, and time steps

The inputs on this wave equation solver describe the string before the simulation begins and the numerical mesh used to update it. Most mistakes come from choosing a function that does not match the physical situation, or from using a mesh that is too coarse for the shape you want to inspect.

Common wave-equation inputs on this page are the ones that set the initial shape, the initial motion, the wave speed, and the resolution of the calculation:

For this solver, c must be positive, the grid needs at least 10 points, and at least one time step is required before the string can move forward. Those limits are there to keep the finite-difference march well-defined, not to represent a universal physical rule. If you want a quick qualitative picture, begin with a smooth starting shape and then increase the resolution only if the trace looks too blocky.

Formulas: the finite-difference update used by this solver

Most wave solvers begin by sampling the initial shape and velocity, then updating the interior points of the string one step at a time. This page follows that pattern for a uniform one-dimensional string with fixed ends: it evaluates f(x) and g(x) across the grid, computes a time increment from the spacing and wave speed, and advances the interior samples while leaving the endpoints pinned.

The interior update used by the calculator can be written in standard finite-difference form as:

ujn+1 = 2ujn -ujn-1 + (cΔtΔx) 2 ( uj+1n -2ujn +uj-1n )

In that notation, u represents the displacement at grid position j and time level n. The factor involving c, Δt, and Δx controls how strongly neighboring samples influence the next update, and the fixed-end assumption means the boundary points stay anchored while the interior evolves. Because the page derives Δt from the grid spacing, changing the number of grid points also changes the time increment used in the march.

That relationship is helpful when you are interpreting the result. If you refine the grid, the string is sampled more densely and the displayed list becomes longer; if you coarsen the grid, the output is shorter but may hide curvature that matters. The solver is therefore best thought of as a controlled numerical approximation to the classical wave equation, not as a full physical instrument.

Worked example: a sine-shaped fixed-end string with zero initial velocity

A useful worked example for this wave equation solver is the default sine-shaped displacement with zero initial velocity, because it matches the fixed-end boundary condition and gives you a clean baseline for comparison. If you keep f(x) = sin(pi*x), set g(x) to 0, use c = 1, and leave the grid and time-step settings at their defaults, the string starts in a smooth single-hump shape before the explicit update moves it through time.

This setup is handy because it gives you a simple visual check of the solver’s behavior. The ends should remain pinned, the sampled profile should stay smooth enough to follow, and the output should look symmetric when the initial conditions are symmetric. If the result looks irregular, the most likely culprits are an expression that does not evaluate cleanly across the domain or a grid that is too coarse for the shape you entered.

Once the baseline looks right, change only one input at a time. A different f(x) changes the starting wave shape, a nonzero g(x) adds motion at t = 0, and a different c changes how quickly the disturbance advances through the mesh. That one-at-a-time approach makes it much easier to tell whether the solver is behaving the way you expect.

Comparison table: sensitivity to grid resolution in the wave solver

Grid resolution is usually the first setting to compare when a vibrating-string trace looks too rough or too dense. The table below shows how the same wave problem behaves when you change the number of spatial samples while leaving the other expressions alone.

Scenario Grid setting What changes in the trace What to watch
Coarser grid Fewer grid points The displacement list is shorter, and sharp bends can look blocky or stepped. Check whether the main peak and the zero crossings are still easy to identify.
Baseline grid Current setting This is the reference run you should compare against before changing other inputs. Use it to see whether a later change improves clarity or just changes the display density.
Finer grid More grid points The string is sampled more densely, so the curve usually looks smoother and more detailed. Watch whether the shape itself changes or whether only the resolution improves.

Because the solver ties the time step to the spatial spacing, a finer grid also changes the physical time represented by each update. That means a more detailed trace can be useful for clarity, but you should still compare runs with the same f(x), g(x), c, and step count when you want a fair side-by-side check.

How to interpret the vibrating-string displacement result

The result panel for this wave equation solver prints the displacement samples after the chosen number of steps, not a full animation. Read it as a snapshot of the string’s state at the end of the explicit march: large positive values indicate upward displacement, negative values indicate downward displacement, and values near zero show where the string has returned close to equilibrium.

As you inspect the output, focus on three questions. First, does the overall shape still make sense given the function you entered for f(x) and g(x)? Second, do the endpoints stay fixed the way a fixed-end string should? Third, if you change one major input, does the result move in the direction you expected? Those checks tell you much more than looking for a single number.

If you want to save a run, use the Copy Result button to capture the displayed summary. That gives you the displacement snapshot exactly as the solver printed it, which is useful when you want to compare two parameter sets or paste one run beside another in your notes.

Limitations and assumptions of the fixed-end wave model

Like any fast browser-based wave approximation, this calculator makes simplifying assumptions so the string can be updated quickly. It models a uniform one-dimensional medium with fixed ends and a linear explicit update, which is ideal for teaching, quick checks, and comparing expressions, but not for every real-world vibrating system.

If you use the output for lab notes, classroom work, or design checks, treat it as a numerical estimate and confirm the setup with a more detailed model or experiment before you act on it. The real value of a wave calculator is that it makes the assumptions visible: you can see exactly which input changed the motion, which grid settings affected the display, and where a more refined analysis might be needed.

Enter parameters.