The idea: four numbers, four jobs
A cosine wave with all its knobs has the form
y = a·cos(bx + c) + d
Without them, y = cos x starts at its peak of 1 at x = 0, comes down through the midline at π/2 and repeats every 2π. Each coefficient changes one thing you can read straight off the graph; the others stay where they were.
| coefficient | what it controls | formula |
|---|---|---|
| a | amplitude: how far the wave goes above and below its middle | |a| |
| b | period: how long one wave is | 2π/|b| |
| c | phase shift: where a cycle starts | x = −c/b |
| d | midline: the middle height | y = d |
a: the amplitude
cos u stays between −1 and 1, so a·cos u stays between −|a| and |a|. |a| is the amplitude: how far a peak is above the midline. a = 2 doubles the height, a = ½ halves it, and a negative a turns the wave upside down: where cos x has a peak, −cos x has a trough. a = 0 leaves only the flat line y = d. a does not change the period or the shift. (Demo 2: a, the amplitude)
b: the period
cos u repeats every 2π in u. With u = bx, one whole wave needs bx to grow by 2π, so x has to grow by 2π/|b|:
period = 2π / |b|
b = 2 fits two waves where cos x had one (period π); b = ½ stretches one wave over 4π. So |b| counts how many waves fit into 2π. With b = kπ/16 the period is 32/k: b = π gives period 2.
b = 0 makes bx + c = c for every x, so the graph is the flat line y = a·cos c + d. A negative b mirrors the graph in the y-axis. Cosine is even, cos(−u) = cos u, so cos(−x) is exactly cos x: with c = 0 the sign of b changes nothing. (Demo 1: b from π to −π in steps of π/16: the wave flattens out as b gets close to 0, is the line y = 1 at b = 0 (cos 0 = 1), then comes back exactly as before.)
c: the phase shift
A cycle starts where the inside is 0: bx + c = 0, so at x = −c/b. That is the phase shift. A positive c/b moves the graph to the left, a negative one to the right. Factor out b to see it: a·cos(bx + c) = a·cos(b(x + c/b)), so the shift is c/b, not c.
(Demo 5: the shift is −c/b, not −c) A quarter period to the right turns cosine into sine, cos(x − π/2) = sin x, and half a period turns it upside down, cos(x + π) = −cos x. (Demo 4: c slides it sideways (cos → sin)) Adding 2π to c changes nothing: it is one whole cycle.
d: the midline
d is added to every y, so the whole wave slides up or down without changing shape. The midline y = d is halfway between the peaks and the troughs, and the values run over the range [d − |a|, d + |a|]. (Demo 3: d, the midline) Sliding and stretching any graph is the subject of Function Transformations.
Reading a, b, c, d off a graph
| read off the graph | gives |
|---|---|
| highest and lowest y | d = (max + min)/2, |a| = (max − min)/2 |
| distance from one peak to the next | |b| = 2π / period |
| where a cycle starts (at a peak) | c = −b·xstart |
Example, Demo 6: y = 2 cos(½x − π/4) + 1 has max 3 and min −1, so d = 1 and a = 2; one wave is 4π long, so b = 2π/4π = ½; a cycle starts at x = π/2, so c = −½·π/2 = −π/4.
Sine and cosine are one wave
Sine is cosine shifted right by a quarter period: sin x = cos(x − π/2). So every a·sin(bx + c) + d is also a·cos(bx + c − π/2) + d, and everything on this page holds for sine too, with the cycle starting on the midline instead of at a peak. See Sine Waves: What a, b, c, d Do. Why the two are the same wave is clearest on The Unit Circle: cos is the x of a point going round, sin its height, and the x leads the height by a quarter turn.
tan x = sin x / cos x has an asymptote wherever cos x = 0: see Tangent Graphs: What a, b, c, d Do. Multiply the wave by a decaying exponential and it dies out inside an envelope: see Damped Oscillation: What A, γ, ω, φ Do.
Two cosine waves of the same wavelength that meet add up point by point: in step they make one wave twice as tall, half a wavelength apart they cancel. Two sources in a ripple tank do both at once: see Wave Interference: Two Coherent Sources.
What the page leaves out
tan and the other trig functions, writing p·sin x + q·cos x as one wave R·sin(x + φ), sums of waves (Fourier series), angles in degrees, and graphs that need a bigger window than x ∈ [−2π, 2π], y ∈ [−4, 4]. For a cubic instead of a wave, see Cubic Functions: What a, b, c, d Do.