Skip to content

Lesson 3 of 315 min Essential path

Decomposing signals

Split a signal into an even and an odd part, rebuild it from spikes or switches, and preview building shapes from pure tones.

Before thisOperations on amplitude (2.2)

Before this2.2
Chapter 2 · Lesson 3 of 3

First, the picture

Here is a lopsided signal. Switch View between Original and Split it, and watch two tidier parts add back up to it.

Splitting a signal in half

Split the signal into a mirror half and a flip half, and watch them add back to the original.

even part xe[n]: its own mirror image about n = 0
odd part xo[n]: a flipped mirror image about n = 0
sum xe[n] + xo[n]original x[n]
View
Describe this picture

Plots against sample number, and two “View” buttons; it starts on Split it. Original shows one lopsided trace x[n]x[n], with a small early bump, a sharp spike just after the origin and a slow fade, not a mirror image of itself about n=0n = 0. Split it stacks three panels: the “even part xe[n]x_e[n]”, its own mirror image about n=0n = 0; the “odd part xo[n]x_o[n]”, a flipped mirror image; and the “sum xe[n]+xo[n]x_e[n] + x_o[n]”, drawn over the faint original.

Taking a signal apart

So far I’ve been building new signals: shifting and scaling one, adding two together, capping the peaks off a third. Here I turn that around. Given one signal, can I break it down into simpler pieces that add back up to it exactly?

This page shows four ways to do this, and each is useful later for a different reason. The pieces can mirror each other. They can be silent except at a single instant. They can switch on and stay on. Or they can be smooth, endlessly repeating waves.

Splitting into a mirror half and a flip half

Picture a lopsided signal: a sharp rise, then a slow fade that doesn’t match the rise at all. In Kinds of signals (1.2), I picked a moment and called it the origin, then asked whether folding the trace in half at that origin landed the two halves on top of each other (an even signal) or as exact opposites (an odd signal). Almost nothing in real life is purely one or the other. But here is the useful fact: any signal, however lopsided, is the sum of an even part and an odd part, and adding those two parts back together reproduces the original exactly.

The even part is built by averaging the signal with its own mirror image, and the odd part by averaging the signal with the negative of its mirror image:

xe[n]=12(x[n]+x[−n])x_e[n] = \tfrac12\big(x[n] + x[-n]\big) xo[n]=12(x[n]−x[−n])x_o[n] = \tfrac12\big(x[n] - x[-n]\big)

Here x[n]x[n] is the signal’s value at sample nn, x[−n]x[-n] is its value at the mirror sample on the other side of the origin, xe[n]x_e[n] is the even part, and xo[n]x_o[n] is the odd part. Add them and the x[−n]x[-n] terms cancel, leaving xe[n]+xo[n]=x[n]x_e[n] + x_o[n] = x[n].

Go back to the lopsided signal at the top of the page and choose Split it. Notice the even part is its own mirror image about n=0n=0, and the odd part is a flipped mirror image. The bottom panel draws the two parts added sample by sample, and it lands on the faint original at every sample.

In Complex numbers for signals (3.3) you’ll meet signals that carry two numbers at every instant instead of one, and they also split into two matching parts.

Rebuilding from spikes

An hourly rainfall log is really a stack of single-hour bars: each bar reports how much rain fell during its own hour and says nothing about any other hour. Stack all the bars up, one per hour, and you’ve rebuilt the whole day’s log.

A discrete signal can be rebuilt the same way, from spikes: a piece that has one sample’s own height at its own instant, and is exactly zero everywhere else. Add one spike per sample, each scaled to that sample’s height and placed at that sample’s instant, and the sum reproduces the whole sequence.

x[n]=∑kx[k] δ[n−k]x[n] = \sum_k x[k]\,\delta[n-k]

Here x[k]x[k] is the sequence’s value at sample kk, and δ[n−k]\delta[n-k] is a spike that equals 11 at n=kn=k and 00 at every other nn. Scaling that spike by x[k]x[k] and adding one such term for every kk rebuilds x[n]x[n] exactly. (This spike gets a formal name, the unit impulse, in Impulse, step and ramp (3.1).)

Drag Pieces built up to its maximum, one step at a time, and watch the sum grow toward the target.

Rebuilding from spikes

Each spike is that one sample's own height, and silent everywhere else. Step through to add them one at a time.

the spike just added
sum of the spikes so fartarget x[n]
2
Spike just added
sample 1, height 1
Describe this picture

Two panels against sample number. The top one, “one spike”, shows the spike just added, and the readout “Spike just added” gives its height. The bottom one, “sum so far”, shows the sum of the spikes so far over the faint target x[n]x[n]. The “Pieces built” slider adds the spikes one at a time, from none to one per sample.

Once every sample has its spike added in, the overlay lands on the target sequence, point for point.

Rebuilding from switches

Now picture a machine that reports a gear number, one integer per second. It doesn’t relabel every past second when the gear changes. It changes at the instant of the shift and holds that new number afterward, until the next shift. You could rebuild the whole gear-number trace from a handful of “shift by this much, starting here” events, one per gear change.

That’s a switch: a piece that turns on at one instant and stays on at every instant after that. Unlike a spike, a switch keeps contributing at every later sample too, so the size you add at each instant can’t be the sample’s own value; it has to be the change since the instant before, the first difference from Operations on amplitude (2.2).

x[n]=∑kd[k] u[n−k]x[n] = \sum_k d[k]\,u[n-k] d[k]=x[k]−x[k−1]d[k] = x[k] - x[k-1]

Here d[k]d[k] is the first difference at sample kk, and u[n−k]u[n-k] is a switch that equals 00 before n=kn=k and 11 from n=kn=k on. (Like the spike, this switch gets a formal name, the unit step, in Impulse, step and ramp (3.1).)

Drag Pieces built up one step at a time, and read the size of each switch as it goes in.

Rebuilding from switches

Each switch turns on at one sample and stays on after that, sized by the change from the sample before it.

the switch just added: on from its sample onward
sum of the switches so fartarget x[n]
3
Switch just added
sample 2, size +2
Describe this picture

Two panels against sample number. The top one, “one switch”, draws the switch just added, on from its sample onward, and the readout “Switch just added” gives its size. The bottom one, “sum so far”, shows the sum of the switches so far over the faint target x[n]x[n], the same sequence as before. The “Pieces built” slider opens at 3 pieces.

The sum again reaches the target once every switch is in. But the sizes it needed were the first differences, not the sample values, because each switch keeps adding in at every later sample.

Rebuilding from pure tones

A buzzy, square-ish wave sounds harsh because it isn’t smooth: it jumps sharply between two levels instead of curving between them. You can get close to that sharp shape by adding together a handful of smooth, endlessly repeating waves, called pure tones, each at a different pitch and size.

Here is where the pitches come from, in plain words before any notation. If the target shape repeats once per second, the first tone does too. The second tone repeats twice per second, the third three times, and so on. These repeat rates (one times, two times, three times the target’s own repeat rate) are called harmonics. Add enough of them together, each scaled correctly, and the sharp-cornered target shape starts to emerge from the sum of smooth curves.

The square-ish wave below needs only the odd harmonics (1×, 3×, 5×, 7× its repeat rate). This shape has no even harmonics (their sizes are zero), so the instrument skips them and each step adds the next odd one.

Each tone brings two settings: how big it is and how fast it repeats (its harmonic). All of them start together at zero, which suits this shape. Sinusoids (3.2) gives these smooth waves their proper name and notation. For now, notice that summing more of them brings the sum closer to the target shape without your ever having to go back and change the tones already added. This is a preview. Signals as sums of sinusoids (7.1) tells you which sizes to use.

Drag Harmonics from “just the 1st” up to “up to the 7th” and watch the sum close in on the target.

Rebuilding from pure tones

Adding a few smooth waves together can approximate a sharper repeating shape.

1× tone3× tone
target (repeats every 1 s)sum of the tones
up to the 3rd
Gap from the target
0.315

The root-mean-square difference between the sum and the target, over one repeat.

Describe this picture

Two panels against time from 0 to 2 s. The upper one draws the tones added so far, labelled “1× tone”, “3× tone”, “5× tone” and “7× tone”, all starting together at zero; the newest is drawn at full strength and the older ones faded. The lower one shows the sum of the tones over the faint “target (repeats every 1 s)”, so you see two repeats of the target. The “Harmonics” slider runs from “just the 1st” to “up to the 7th” and starts at “up to the 3rd”. A readout shows “Gap from the target”.

Watch Gap from the target too: the root-mean-square size (see How big is a signal (1.3)) of the difference between the sum and the target, over one repeat. With one tone the sum is a smooth, rounded wave, and each additional harmonic moves the sum closer to the sharper target shape, shrinking the gap readout as it goes.

The maths behind it · bases

If you list a signal’s samples as one long column of numbers, rebuilding it from spikes is the same as writing that column as “this much of the first sample, plus this much of the second, and so on”. Linear algebra calls those building blocks a basis, and starts from exactly this idea.

Worked example

Take the sequence x[n]=1,4,3x[n] = 1, 4, 3 for n=−1,0,1n = -1, 0, 1 (zero elsewhere), folded about the origin n=0n=0.

Even and odd parts. xe[n]=12(x[n]+x[−n])x_e[n] = \tfrac12(x[n]+x[-n]) gives xe=2,4,2x_e = 2, 4, 2 for n=−1,0,1n=-1,0,1, and xo[n]=12(x[n]−x[−n])x_o[n]=\tfrac12(x[n]-x[-n]) gives xo=−1,0,1x_o = -1, 0, 1. Check: xe+xo=1,4,3x_e + x_o = 1,4,3, which is x[n]x[n] again.

Now take a second sequence, x[n]=2,−1,3x[n] = 2, -1, 3 for n=0,1,2n = 0, 1, 2 (zero elsewhere).

Sum of spikes. x[n]=2 δ[n]−1 δ[n−1]+3 δ[n−2]x[n] = 2\,\delta[n] - 1\,\delta[n-1] + 3\,\delta[n-2], where δ[n−k]\delta[n-k] is 11 at n=kn=k and 00 elsewhere.

Sum of switches. With x[−1]=0x[-1]=0, the first differences are d=2,−3,4,−3d = 2, -3, 4, -3 for n=0,1,2,3n = 0, 1, 2, 3 (the last one because the signal falls back to 00: d[3]=0−3d[3] = 0 - 3), so x[n]=2 u[n]−3 u[n−1]+4 u[n−2]−3 u[n−3]x[n] = 2\,u[n] - 3\,u[n-1] + 4\,u[n-2] - 3\,u[n-3]. Check at n=2n=2: 2−3+4=32-3+4=3, which matches x[2]x[2]. Check at n=3n=3: 2−3+4−3=02-3+4-3=0, which matches x[3]=0x[3]=0.

Where you’ll meet this

The even/odd split is a shortcut you’ll use whenever a problem has a mirror symmetry in it.

Writing a signal as a sum of spikes is the idea behind how a certain kind of system responds to every input (The impulse response (5.1)): know the response to a single spike, and you know the response to everything. Writing a signal as a sum of switches shows up wherever something moves in sudden steps and holds, like a thermostat setting or a motor told to move to a new position and stay there. And building a shape from a handful of tones is a first look at what a synthesizer does.

Reference card

DecompositionFormulaNotes
Even / odd partsxe[n]=12(x[n]+x[−n])x_e[n]=\tfrac12(x[n]+x[-n]), xo[n]=12(x[n]−x[−n])x_o[n]=\tfrac12(x[n]-x[-n]), x=xe+xox=x_e+x_oeven mirrors; odd mirrors and flips sign
Sum of spikesx[n]=∑kx[k] δ[n−k]x[n]=\sum_k x[k]\,\delta[n-k]δ[n−k]\delta[n-k]: 11 at n=kn=k, 00 elsewhere (the unit impulse, Impulse, step and ramp (3.1))
Sum of switchesx[n]=∑kd[k] u[n−k]x[n]=\sum_k d[k]\,u[n-k], d[k]=x[k]−x[k−1]d[k]=x[k]-x[k-1]u[n−k]u[n-k]: 00 before kk, 11 from kk on (the unit step, Impulse, step and ramp (3.1)); d[k]d[k] is the first difference
Sum of pure tonessmooth repeating waves at 1×, 2×, 3× … the repeat ratemore harmonics → closer match; explained in Signals as sums of sinusoids (7.1)

End of lesson 2.3

Where to go next.

Phasorium
LibraryEvery lesson, in order

Parts

About Phasorium
Look