1D Wave Equation Solver

Animated finite-difference solution to the wave equation ∂²u/∂t² = c²∂²u/∂x²

Parameters

ⓘ
m/sⓘ
sⓘ
Show Trail

Controls

xⓘ

Calculated Values

Number of grid points:
60.00;60.00;
Time steps:
120.00;120.00;
Domain:
1.00;m1.00;m

Examples

Gaussian pulse, c = 1

Pulse splits and travels both directions.

    Sine wave

    Standing wave pattern with fixed ends.

      Visualization

      Solving the Wave Equation Numerically

      The 1D wave equation ∂²u/∂t² = c²·∂²u/∂x² models how disturbances propagate through a medium — strings, membranes, and electromagnetic waves. c is the wave speed determined by tension and density (or permittivity/permeability).

      The leapfrog scheme uses centered differences in both space and time: u_i^{n+1} = 2u_i^n − u_i^{n-1} + C²(u_{i+1}^n − 2u_i^n + u_{i-1}^n), where C = cΔt/Δx is the Courant number.

      Stability requires C ≤ 1 (the CFL condition). If violated, high-frequency modes grow unboundedly. The animation shows the initial pulse splitting into left- and right-traveling waves that reflect at boundaries.

      Energy is conserved (no damping). The wave returns to its initial shape after reflecting from both ends — unlike the heat equation where energy dissipates.

      Key Concepts

      • Wave speed c = √(T/μ) for a string
      • Leapfrog: second-order in space and time
      • CFL condition: C = cΔt/Δx ≤ 1
      • Superposition: waves add linearly
      • Energy conservation (no dissipation)

      Real-World Applications

      • Vibrating guitar string
      • Seismic wave propagation
      • Electromagnetic wave simulation
      • Acoustic wave propagation in pipes

      Explore Further

      More computational physics tools

      • Gradient Descent

        Iteratively minimize f(x) by following the negative gradient with animated path visualization.

      • 1D Heat Equation

        Finite-difference FTCS solution to the diffusion equation with animated temperature profiles.

      • Numerical Integration

        Trapezoidal and Simpson rules to approximate definite integrals with error vs exact solutions.

      • ODE Solver

        Euler and Runge-Kutta 4 methods for first-order ODEs with comparison to analytic solutions.

      • Monte Carlo Intro

        Estimate π and integrals by random sampling — introduction to stochastic computational physics.

      • Newton-Raphson

        Solve nonlinear equations f(x) = 0 with tangent-line iterations — fast when the guess is good.

      Physics Equations

      PDE:
      ∂2u∂t2=c2∂2u∂x2\frac{\partial^2 u}{\partial t^2} = c^2 \frac{\partial^2 u}{\partial x^2}
      Leapfrog:
      uin+1=2uin−uin−1+C2(ui+1n−2uin+ui−1n)u_i^{n+1} = 2u_i^n - u_i^{n-1} + C^2(u_{i+1}^n - 2u_i^n + u_{i-1}^n)
      CFL:
      C=cΔtΔx≤1C = \frac{c \Delta t}{\Delta x} \leq 1

      Step-by-Step Solution

      See how the main results are calculated.

      1

      Step 1: The wave equation

      Wave speed c = 1 m/s on a string of length L = 1 m, starting as a Gaussian pulse with both ends fixed.

      Equation:

      ∂2u∂t2=c2 ∂2u∂x2\frac{\partial^2 u}{\partial t^2} = c^2\,\frac{\partial^2 u}{\partial x^2}
      2

      Step 2: Leap-frog scheme

      Equation:

      uin+1=2uin−uin−1+C2(ui+1n−2uin+ui−1n)u_i^{n+1} = 2u_i^n - u_i^{n-1} + C^2(u_{i+1}^n - 2u_i^n + u_{i-1}^n)

      Explanation:

      Central differences in space and time; the first step assumes zero initial velocity.

      3

      Step 3: Courant (CFL) condition

      Equation:

      C=c ΔtΔx≤1C = \frac{c\,\Delta t}{\Delta x} \le 1

      Calculation:

      C=0.329C = 0.329

      Result:

      C ≤ 1 — the scheme is stable

      Explanation:

      If the Courant number exceeds 1 the wave scheme is unstable and blows up.

      4

      Step 4: Behaviour over t = 0.5 s

      By d'Alembert's solution, the initial shape splits into left- and right-traveling waves that reflect off the fixed ends.

      Result:

      Energy is conserved: the pulse propagates and reflects without dissipation.

      Frequently Asked Questions (FAQ)

      What is the CFL condition?

      Courant-Friedrichs-Lewy: C = cΔt/Δx ≤ 1 is required for stability of explicit wave equation solvers.

      Why does the pulse split in two?

      The initial displacement decomposes into left- and right-traveling waves (d'Alembert's solution: u = f(x−ct) + g(x+ct)).

      Is energy conserved?

      Yes — without damping, the wave amplitude remains constant. The animation shows reflection at boundaries with no loss.

      Practice MCQs

      1. The wave equation is a ___ PDE:
      2. CFL condition for wave equation requires:
      3. d'Alembert's solution says waves:
      4. Fixed boundary conditions cause:
      5. The wave speed c for a string is:
      6. The dispersion relation for the 1D wave equation is:
      7. If the CFL number C > 1, the numerical scheme:
      8. The leapfrog scheme is ___ in both space and time:
      9. A Gaussian initial pulse splits because:
      10. Unlike the heat equation, the wave equation: