The idea: three jobs in one formula

Take a plain sine wave sin(mx), stretch it by a function g(x) and lift it by a function h(x):

y = h(x) + g(x) · sin(mx)

Each piece has one job. h is the midline: the wave swings around it. g is the envelope: how far the wave may swing away from h at each x. m is the frequency: how fast it swings. Pick h and g and you pick a band; m only decides how densely the curve fills it.

The curve y = x/2 + 2e^(−x²/2)·sin(10x) in red. The dotted grey line y = x/2 is the midline h. The dashed orange curves h + g and h − g bound the curve above and below: tall in the middle, closing in at the sides. A bracket marks one period 2π/m
h sets where the wave is, g how far it may swing, m how fast: here h = x/2, g = 2e^(−x²/2), m = 10.

Why the curve stays inside the envelope

A sine is never above 1 or below −1. Multiply by g and add h:

h(x) − |g(x)|  ≤  y  ≤  h(x) + |g(x)|

These two bounds are the dashed orange curves on the canvas. They don't contain m, so they stay put while m changes. The curve touches them where sin(mx) = ±1, at x = (k + ½)·π/m, and it crosses the midline where sin(mx) = 0, at x = kπ/m. Those crossings depend only on m: change g and they stay exactly where they are (Demo: g doesn't move the zeros).

piecewhat it decidestry
h(x)where the wave is: the line it swings around0, x/2, x²/4, ∛(x²), sin x
g(x)how tall the wave is at each x, and where it is pinned1, 2e^(−x²/2), 1.5·cos x, x/2, √(3 − x²)
mhow many swings: period 2π/m, about m·D/π waves on −D … D0 … 60

With g = 1 and h = d this is the ordinary wave a·sin(bx) + d with a = 1, b = m: see Sine Waves: What a, b, c, d Do. Here the amplitude a and the midline d may change along x.

Where g is 0 or changes sign

Where g(x) = 0 the band has zero width, so the curve must pass through the midline there, whatever m is. That point is a node. Where g changes sign, g·sin(mx) changes sign too: the wave on one side is the mirror image of what it would have been, a jump of half a period in phase.

  • g = 1.5·cos x: nodes at x = ±π/2 ≈ ±1.57. Between them the wave swells and shrinks again. This is what you hear as beats when two notes of nearly the same pitch play together: sin(a) + sin(b) = 2·cos((a − b)/2)·sin((a + b)/2), a fast wave in a slow cosine envelope (Demo: beats).
  • g = x/2: one node at x = 0 and a band shaped like a bow tie. Left of 0 the wave is upside down (Demo: g = x/2 changes sign).
  • g = √(3 − x²): the band closes at the ends x = ±√3, and the domain stops there, because the square root needs 3 − x² ≥ 0.
Two plots with m = 8 and h = 0. Left: g = 1.5·cos x, the red wave pinned to the axis at x = ±π/2, swelling in the middle and again at the ends. Right: g = x/2, a bow-tie band pinned at x = 0, the wave growing to both sides
Where g = 0 the wave is pinned to the midline: two nodes for 1.5·cos x, one for x/2.

m fills the band: drawing a shape

For small m the curve is a wobbly copy of h. As m grows the swings come closer together, and around 20–30 waves the eye no longer sees a curve but a filled band between h − g and h + g. So you can draw a shape by choosing its top and bottom edges:

top = h + g,  bottom = h − g      ⇒      h = (top + bottom)/2,  g = (top − bottom)/2

For a heart take h = ∛(x²) (a V with a cusp, the dent at the top) and g = √(3 − x²) (a half circle, the round sides). That is the curve on The Heart Curve, written there with sin(mπx), so its m = 20 is this page's m = 20π ≈ 63 (Demo: build the heart).

Three small plots of y = ∛(x²) + √(3 − x²)·sin(mx) inside the same dashed heart: m = 4 is a wobbly V, m = 15 swings about 8 times, m = 60 swings about 33 times and fills the heart
Same h and g, m = 4, 15, 60: the curve fills the heart-shaped band.

m = 0 is the other extreme: sin 0 = 0, so y = h(x) and g has no effect at all (Demo: m = 0).

Where you meet it

namehgwhat it is
AM radio01 + k·(sound signal)a fast carrier sin(mx) whose height carries the sound
beats0cos of half the pitch differencetwo close notes heard as one note getting louder and softer
wave packet0a bell, e^(−x²/2σ²)a short burst: a pulse of light, a particle in quantum mechanics
damped oscillation0A·e^(−γt)a swing or a spring dying out: see Damped Oscillation
sea swell on a tideslow wave1a fast wave riding on a slow one (h = sin x on the page)

Moving the midline is the same move as shifting a graph up by k on Function Transformations, except that the shift may be different at every x.

When the envelope itself moves, at a different speed from the crests inside it, the speeds are the group and phase velocities: see Group Velocity and Phase Velocity.

What the page leaves out

Typing your own h and g (the page has five presets each), a phase c in sin(mx + c), negative m (it only mirrors sin), the exact peaks of the curve (they sit a little off the touch points where the envelope is not flat), and the Fourier view of a modulated wave as a sum of nearby frequencies. The window is fixed at x ∈ [−3.5, 3.5], y ∈ [−3.2, 4].