Sine Wave Playground

Layer multiple sine waves together and observe superposition, interference, beats, and harmonics in real-time with optional audio output.

Home / Calculators / Sine Wave Playground

Sine Wave Playground

Layer up to 3 sine waves and watch them combine in real-time. See constructive interference, beats, harmonics, and standing waves come to life. You can even hear them!

Wave 1
Wave 2
Wave 3
Combined

Wave 1

Wave 2

Wave 3

What You're Seeing

Superposition: When waves overlap, they add together. This is the fundamental principle behind sound, music, radio, and quantum mechanics. The red "Combined" line shows the sum of all active waves — this is what you'd hear or measure in real life.

What Is a Sine Wave?

A sine wave is the most fundamental waveform in mathematics and physics. Described by the function y = A sin(fx + φ), it represents smooth, periodic oscillation. Every sine wave is defined by three parameters: amplitude (A), which controls the height of the peaks; frequency (f), which determines how many cycles occur per unit of time or distance; and phase (φ), which shifts the wave left or right along the x-axis.

Sine waves are not just mathematical abstractions. They appear naturally everywhere: in the vibrations of a guitar string, the oscillation of a pendulum, the alternating current in household wiring, and even the electromagnetic waves that carry light and radio signals. Understanding how sine waves behave and combine is essential for physics, engineering, music theory, and signal processing.

The Principle of Superposition

When two or more waves exist in the same medium, they combine according to the principle of superposition: at every point, the total displacement equals the sum of the individual displacements. This simple rule produces rich and complex behavior.

y_total(x, t) = A₁ sin(f₁x + φ₁) + A₂ sin(f₂x + φ₂) + A₃ sin(f₃x + φ₃)

Constructive and Destructive Interference

When two waves of the same frequency are in phase (their peaks align), they produce constructive interference: the combined wave has double the amplitude. When they are exactly out of phase (one peaks while the other troughs), destructive interference occurs and the waves cancel. Try the "Destructive Cancel" preset above to see this in action.

Beats

When two waves have slightly different frequencies, they produce beats: a periodic pulsing in amplitude. The beat frequency equals the difference between the two wave frequencies. Musicians use this phenomenon to tune instruments by listening for the beats to slow down and disappear as two notes approach the same pitch. Use the "Beats" preset to hear and visualize this effect.

Fourier's Theorem and Harmonics

One of the most profound results in mathematics is Fourier's theorem: any periodic wave can be decomposed into a sum of sine waves of different frequencies (harmonics). A square wave, for example, is built from odd harmonics: the fundamental frequency plus the 3rd, 5th, 7th harmonics and so on, each with decreasing amplitude. The "Odd Harmonics" preset demonstrates the beginning of this construction.

Worked Example: Adding Two Waves

Consider two waves: y₁ = sin(x) and y₂ = 0.5 sin(2x). At x = π/2:

  1. y₁ = sin(π/2) = 1.0
  2. y₂ = 0.5 × sin(2 × π/2) = 0.5 × sin(π) = 0.5 × 0 = 0
  3. y_total = 1.0 + 0 = 1.0

At x = π/4: y₁ = sin(π/4) ≈ 0.707 and y₂ = 0.5 sin(π/2) = 0.5, giving y_total ≈ 1.207. The combined wave is richer and more complex than either individual wave.

Real-World Applications

Frequently Asked Questions

What is amplitude, frequency, and phase in a sine wave?
Amplitude is the peak height of the wave, representing maximum displacement from the center line. Frequency is how many complete cycles the wave completes per unit, controlling how "compressed" or "stretched" it appears. Phase is a horizontal offset that shifts the starting position of the wave along the x-axis, measured in radians.
What is superposition and why does it matter?
Superposition is the principle that when multiple waves occupy the same space, the resulting displacement at any point is the algebraic sum of all individual wave displacements. It matters because it explains interference patterns, sound mixing, signal processing, and is fundamental to quantum mechanics.
What are beats and how do they form?
Beats are periodic variations in loudness (amplitude) that occur when two waves of slightly different frequencies overlap. The beat frequency equals the absolute difference of the two frequencies. For example, a 440 Hz wave and a 442 Hz wave produce 2 beats per second. Musicians use this to tune instruments by ear.
How can sine waves build a square wave?
According to Fourier's theorem, a square wave equals the sum of odd harmonics: sin(x) + (1/3)sin(3x) + (1/5)sin(5x) + (1/7)sin(7x) + ... and so on. Each additional term makes the approximation closer to a perfect square shape. You can see this begin with the "Odd Harmonics" preset above.
Why does the sound feature use Web Audio?
The Web Audio API is a browser-native technology that generates real audio oscillators in real-time. Each active wave in the playground creates a corresponding audio oscillator, so you can hear the actual frequencies and their combinations. The frequency values are scaled to audible range (multiplied by 220 Hz) to make the math musically meaningful.
Can I use this to understand music and harmonics?
Absolutely. The playground directly demonstrates how musical intervals work. A frequency ratio of 2:1 is an octave, 3:2 is a perfect fifth, and 4:3 is a perfect fourth. Enable the sound and experiment with these ratios to hear the consonance. The "Harmonics 1+2+3" preset shows the first three overtones of a fundamental tone.