What is a frequency?

Children ask what a frequency is, and it turns out to be a hard question to answer well. The word is everywhere. A radio station announces its frequency. A microwave oven has one printed on the back, a doctor's scanner has one, and so has every note of a song. Behind all of them sits one small idea. A frequency says how often something repeats.

This chapter begins on a playground swing and ends at a glass prism, and that one idea carries it the whole way. On the way it settles a second question, which puzzles nearly everyone who thinks about radio for the first time. How can many frequencies be in the same place at the same moment and still be told apart?

1. One swing, and how long it takes period and frequency

Sit a child on a playground swing, give one push, and watch. The swing goes out, comes back, and passes through the bottom again headed the way it started. That whole trip is one swing, and on an ordinary playground it takes about three seconds. The next trip takes three seconds too, and so does the one after. A low swing and a high one take the same time, as near as anyone can tell by watching, because a high swing moves faster and makes up the distance.

The time that one whole trip takes is called the period. Anything that repeats can be described just as well the other way around, by how many trips fit into a stretch of time, and that count is the frequency. A swing with a period of three seconds makes a third of a trip in every second. Something that repeats every half second gets through two trips in a second. Period and frequency are one fact said two ways, and each is found by dividing 1 by the other.

The unit of frequency is the hertz, and one hertz means once every second. It is named for Heinrich Hertz, the German physicist who first made radio waves on purpose and caught them again across his laboratory, in 1887. The playground swing has a frequency of a third of a hertz. A heart at rest beats at about one hertz.

The drawing below hangs a weight on a spring and lets it bob. A pen on the weight draws on a strip of paper that slides away to the left, so the paper keeps a record of where the weight has been. Change how long one bob takes, and watch the period on the paper and the frequency in the note underneath.

The wavy line on the paper is what this site has been calling a signal since chapter 1, and it is the picture people have in mind when they say the word wave. It is a record of something going back and forth. Its period is the time from one crest to the next. Its frequency is the number of crests that pass in a second.

Frequencies run over an enormous range, and the idea is the same at every step of it. Large numbers of hertz take the usual prefixes. A kilohertz is a thousand hertz, a megahertz is a million, and a gigahertz is a billion.

what repeatshow oftenone repeat lasts
the tideabout twice a day12 hours and 25 minutes
a playground swinga third of a hertz3 seconds
a heart at restabout 1 hertz1 second
the lowest note on a piano27.5 hertz36 thousandths of a second
a hummingbird's wingsabout 50 hertz20 thousandths of a second
the electricity in a wall outlet50 or 60 hertz20 or 17 thousandths of a second
the A that an orchestra tunes to440 hertz2.3 thousandths of a second
a mosquito's wingsabout 500 hertz2 thousandths of a second
the highest note on a piano4,186 hertz239 millionths of a second
the highest pitch a young ear can hearabout 20,000 hertz50 millionths of a second
the crystal in a quartz watch32,768 hertz30.5 millionths of a second
an AM radio stationabout 1 megahertz1 millionth of a second
an FM radio stationabout 100 megahertz10 billionths of a second
a GPS satellite1,575.42 megahertz0.63 billionths of a second
WiFi, and a microwave ovenabout 2.4 gigahertz0.42 billionths of a second
red lightabout 430 trillion hertz2.3 millionths of a billionth of a second
violet lightabout 750 trillion hertz1.3 millionths of a billionth of a second

The crystal in a watch is there for the sake of its frequency. It rings at exactly 32,768 hertz, a number that can be halved fifteen times to arrive at one. The watch does that halving and moves its second hand once for each result.

2. Three names for one idea pitch, the dial and color

Our senses and our instruments sort the world by frequency, and each has a name of its own for what it finds.

For sound, frequency is pitch. A loudspeaker pushes the air back and forth, and the faster it goes, the higher the note we hear. The A that an orchestra tunes to is 440 hertz. Double the frequency and the note sounds like the same note, only higher, a step that musicians call an octave. A young ear hears from about 20 hertz, which is a rumble felt as much as heard, up to about 20,000. The whine of a mosquito is the frequency of its wings, heard directly.

For radio, frequency is the place on the dial. The number that an FM station reads out is its frequency in megahertz. A station at 101.1 is making the electric current in its antenna swing back and forth 101.1 million times a second. Chapter 2 said in passing that for radio, pitch is called frequency. This is what it meant.

For light, frequency is color. Light is the same kind of wave as radio, swinging enormously faster. Red is the slowest light that the eye can see, at about 430 trillion hertz. Violet is the fastest, at about 750 trillion, and the other colors of the rainbow lie in order between them.

A wave that travels has a length as well as a period. While its source makes one swing, the wave moves on by a certain distance, and that distance is called the wavelength. A higher frequency leaves less time for each swing, so the wave covers less ground and its wavelength is shorter. The A of 440 hertz is 78 centimeters long in air. The wave of an FM station is about 3 meters long, and the wave inside a microwave oven is about 12 centimeters. The bench has a calculator that finds the length for any other frequency.

3. Many at once

Whistle a steady note, and one frequency goes out into the room, near enough. Now have two friends whistle two other notes at the same time. Three frequencies are crossing the same air at the same moment.

The air has no means of keeping three separate records. At each place and at each moment it has a single pressure, and that pressure is the three waves added together, as chapter 3 said of signals that share the air. A microphone in the room draws one line, and the line looks like none of the three whistles.

An ear in that room still hears three notes. So the three must all be in the line somewhere, and there must be a way of getting them out again.

There is a way, and this site has been using it since chapter 2. To ask whether a tone of 550 hertz is hiding in a recording, lay a pure wave of 550 hertz over it, multiply the two together moment by moment, and add up the results. If a tone of 550 hertz is in there, the products pile up into a large total. If it is absent, the products come out positive as often as negative, and they cancel away. Ask the same question at every frequency in turn, and the answers say exactly what the mixture is made of.

The drawing does this. Switch the three tones on and off. The top shows each tone alone, the middle shows the single line that a microphone would record, and the bottom shows the answers when that line is asked about every frequency from 300 to 800 hertz.

The adding lost nothing. Three waves went in, one line came out, and the three can be read back from it, each at its own strength. A set of answers like the one at the bottom of the drawing has a name. It is called the spectrum of the signal, and later chapters are full of them.

The same thing is happening in the air around you now, on a far greater scale. Every radio station in range, every phone, every WiFi router and every GPS satellite overhead is making waves that pass through the room together and add up, each at its own frequency. They cross one another without harm, exactly as the three whistles do. The tuning dial of a radio chooses one frequency to ask about, and the circuits behind it let the others cancel away.

4. White light and a prism

In 1666 Isaac Newton, who was twenty-three, darkened his room, let a thin beam of sunlight in through a hole in the shutter, and stood a wedge of glass called a prism in its path. The white beam came out of the glass spread into a band of colors on the far wall. Red lay at one end and violet at the other, in the order of a rainbow.

People had seen colors come from glass before, and the common belief was that the glass stained the light. Newton tested that belief with two more experiments. He let a single color from the band pass through a second prism, and it came out the same color, turned aside and otherwise unchanged. Then he gathered the whole band together again with a lens, and where the colors met they made white.

So white turns out to be a mixture. It is what the eye reports when every color arrives together. Sunlight is a chord with all the keys held down at once, and a prism is a device that sorts it by frequency. Glass slows light down, and it slows the fast-swinging violet a little more than the slow red. Each color therefore turns through its own angle on the way into the glass and again on the way out, and the colors leave headed in slightly different directions. A rainbow is made the same way, with every raindrop serving as a small prism.

The drawing repeats Newton's last experiment with one thing added. A card stands between the prism and the lens, and it can stop any of the colors. Stop some of them, and see what the rest make when the lens gathers them.

Stop the green alone, and the gathered light turns pink. Stop the blue and the violet, and it turns yellow. A colored filter, a stained glass window and a pair of sunglasses all work this way, by taking some frequencies out of white light and letting the rest go by. The dial of a radio does the same job for the mixture in the air. It lets a single narrow band through and stops everything else.

Engineers have borrowed the words along with the idea. A hiss that holds every frequency of sound in equal measure is called white noise, after white light. A hiss with more of the low frequencies in it is called pink.

Your ear is a prism as well. Deep inside it lies a coiled strip that is narrow and stiff at one end and wide and slack at the other. Each place along the strip answers to a frequency of its own, the high pitches near the entrance and the low ones at the far end. The three whistles of section 3 shake the strip at three separate places, and that is how one line of pressure is heard as three notes.

5. Any shape is a chord

One more discovery completes the picture. In 1807 a French mathematician, Joseph Fourier, claimed that any repeating shape at all can be built by adding pure tones together, even a shape with sharp corners, and that each shape has exactly one recipe. Other mathematicians of his day found the claim hard to believe, and it turned out to be true.

The drawing builds a square wave, a signal that jumps between two levels the way the ones and zeros of chapter 26 do. Its recipe is the odd multiples of one frequency, each weaker than the last. It begins with 100 hertz, adds 300 hertz at a third of the strength, then 500 hertz at a fifth, and goes on in the same way. Add them one at a time.

Two things here are worth a second look. The slow tones give the wave its body, and the fast ones are needed only for the corners. A shape with sharp corners therefore always contains high frequencies, and the sharper the corner, the higher they go. Chapters 26 to 28 depend on this, because every edge of a fast digital signal carries frequencies far above the rate at which its bits are sent. The other thing is the small overshoot beside each corner. It grows narrower as tones are added and keeps its height, however many are used.

So frequency belongs to every signal, and pure tones are only the simplest case. Any signal is a chord, and it can be described in two ways that say the same thing. One is the line that a microphone draws, moment by moment. The other is the list of frequencies in it, with the strength of each. The next chapter draws both for the sounds in your own room.

6. The arithmetic and a program

frequency            = 1 / period                      a swing every 3 seconds is 1/3 hertz
period               = 1 / frequency                   60 hertz repeats every 1/60 of a second, 16.7 thousandths
one hertz, Hz        = once every second               kHz is a thousand, MHz a million, GHz a billion
wavelength           = speed / frequency               sound at 440 Hz: 343 / 440 = 0.78 m
                                                       radio at 100 MHz: 300,000,000 / 100,000,000 = 3 m
an octave up         = twice the frequency             220, 440 and 880 hertz are all the note A
waves in one place   add, moment by moment             a mixture of tones is still one line
is a tone in there?  multiply the line by that tone, moment by moment, and add up
a square wave        = tones at 1, 3, 5, 7 ... times one frequency, with strengths 1, 1/3, 1/5, 1/7 ...

The program mixes three tones of different strengths into one recording, a tenth of a second long. Then it asks, at seven frequencies, how much of each is in there.

#include <math.h>
#include <stdio.h>

static const double PI = 3.14159265358979323846;

#define RATE 8000            /* numbers recorded each second */
#define COUNT (RATE / 10)    /* a tenth of a second of them */

/* A mixture of pure tones at one moment. Each tone has a frequency in hertz and a size. */
double mixture_at(const double hertz[], const double size[], int tones, double seconds)
{
    double sum = 0.0;
    for (int k = 0; k < tones; k++) sum += size[k] * sin(2.0 * PI * hertz[k] * seconds);
    return sum;
}

/* How strongly one frequency is present: multiply by a pure tone of that frequency, moment by moment, and add up.
   The question is asked twice, a quarter of a swing apart, so the answer is the same whenever the hidden tone began. */
double strength_of(const double samples[], int count, double rate, double hertz)
{
    double in_step = 0.0, quarter_late = 0.0;
    for (int i = 0; i < count; i++) {
        in_step += samples[i] * sin(2.0 * PI * hertz * i / rate);
        quarter_late += samples[i] * cos(2.0 * PI * hertz * i / rate);
    }
    return 2.0 * hypot(in_step, quarter_late) / count;
}

int main(void)
{
    const double hertz[] = { 440.0, 550.0, 660.0 }, size[] = { 1.0, 0.5, 0.25 };   /* three tones sounding together */
    const int asked[] = { 330, 440, 500, 550, 600, 660, 770 };
    double recording[COUNT];
    for (int i = 0; i < COUNT; i++) recording[i] = mixture_at(hertz, size, 3, (double)i / RATE);

    printf("one swing at 440 hertz lasts %.2f thousandths of a second\n", 1000.0 / 440.0);
    printf("hertz   strength found\n");
    for (int k = 0; k < 7; k++) printf("%5d   %.2f\n", asked[k], strength_of(recording, COUNT, RATE, asked[k]));
    return 0;
}

/* It prints:
  one swing at 440 hertz lasts 2.27 thousandths of a second
  hertz   strength found
    330   0.00
    440   1.00
    500   0.00
    550   0.50
    600   0.00
    660   0.25
    770   0.00   */
import math

def mixture_at(tones, seconds):
    """A mixture of pure tones at one moment. Each tone is (hertz, size)."""
    return sum(size * math.sin(2 * math.pi * hertz * seconds) for hertz, size in tones)

def strength_of(samples, rate, hertz):
    """How strongly one frequency is present: multiply by a pure tone of that frequency, moment by moment, and add up.
    The question is asked twice, a quarter of a swing apart, so the answer is the same whenever the hidden tone began."""
    in_step = sum(v * math.sin(2 * math.pi * hertz * i / rate) for i, v in enumerate(samples))
    quarter_late = sum(v * math.cos(2 * math.pi * hertz * i / rate) for i, v in enumerate(samples))
    return 2 * math.hypot(in_step, quarter_late) / len(samples)

RATE = 8000                                     # numbers recorded each second
chord = [(440, 1.0), (550, 0.5), (660, 0.25)]   # three tones sounding together
recording = [mixture_at(chord, i / RATE) for i in range(RATE // 10)]   # a tenth of a second of it

print(f"one swing at 440 hertz lasts {1000 / 440:.2f} thousandths of a second")
print("hertz   strength found")
for hertz in (330, 440, 500, 550, 600, 660, 770):
    print(f"{hertz:5d}   {strength_of(recording, RATE, hertz):.2f}")

# It prints:
# one swing at 440 hertz lasts 2.27 thousandths of a second
# hertz   strength found
#   330   0.00
#   440   1.00
#   500   0.00
#   550   0.50
#   600   0.00
#   660   0.25
#   770   0.00
use std::f64::consts::PI;

const RATE: usize = 8000; // numbers recorded each second

/// A mixture of pure tones at one moment. Each tone is (hertz, size).
fn mixture_at(tones: &[(f64, f64)], seconds: f64) -> f64 {
    tones.iter().map(|&(hertz, size)| size * (2.0 * PI * hertz * seconds).sin()).sum()
}

/// How strongly one frequency is present: multiply by a pure tone of that frequency, moment by moment, and add up.
/// The question is asked twice, a quarter of a swing apart, so the answer is the same whenever the hidden tone began.
fn strength_of(samples: &[f64], rate: f64, hertz: f64) -> f64 {
    let turn = |i: usize| 2.0 * PI * hertz * i as f64 / rate;
    let in_step: f64 = samples.iter().enumerate().map(|(i, v)| v * turn(i).sin()).sum();
    let quarter_late: f64 = samples.iter().enumerate().map(|(i, v)| v * turn(i).cos()).sum();
    2.0 * in_step.hypot(quarter_late) / samples.len() as f64
}

fn main() {
    let chord = [(440.0, 1.0), (550.0, 0.5), (660.0, 0.25)]; // three tones sounding together
    let recording: Vec<f64> = (0..RATE / 10).map(|i| mixture_at(&chord, i as f64 / RATE as f64)).collect(); // a tenth of a second of it

    println!("one swing at 440 hertz lasts {:.2} thousandths of a second", 1000.0 / 440.0);
    println!("hertz   strength found");
    for hertz in [330, 440, 500, 550, 600, 660, 770] {
        println!("{:5}   {:.2}", hertz, strength_of(&recording, RATE as f64, hertz as f64));
    }
}

// It prints:
// one swing at 440 hertz lasts 2.27 thousandths of a second
// hertz   strength found
//   330   0.00
//   440   1.00
//   500   0.00
//   550   0.50
//   600   0.00
//   660   0.25
//   770   0.00

The three tones come back at exactly the strengths they went in with, and the four frequencies that were never played come back as nothing.

Try it: a swing, a glass of water and a chord

  1. Time a playground swing. Count ten whole trips and divide the seconds by ten, which is far more accurate than timing one. Then swing higher and time it again, and the period will hardly have changed. A swing on shorter chains has a shorter period.
  2. Stand a glass of water on a sunny windowsill, or tilt the shiny side of a compact disc under a lamp, and look for the band of colors. Each color is one frequency of light, sorted out of the white.
  3. Fill three glasses with different amounts of water and tap each one with a spoon. Each rings at a frequency of its own. Then tap two at once and listen for both notes inside the one sound.
  4. In the drawing of section 3, press listen with one tone switched on, then with two, then with three. Try to pick out each note inside the chord. Your ear is doing what the bottom of the drawing does.

The next chapter turns a microphone into a prism for sound and lets the picture scroll, so that you can watch the frequencies in your own voice come and go.