[ ♪ Intro ]
Hard disks. Satellites. DVDs. Internet cables.
We take it for granted that our electronics just work:
that every bit, every 1 and 0, gets perfectly stored and passed around.
But when you dig into it, they really shouldn’t work!
Every wire, memory chip, and radio link is constantly fending off data corruption
from faded signals, electrical interference, and even just bumps and scratches.
It’s practically a miracle electronics work at all!
Of course, what it actually is, is a feat of engineering.
Behind the scenes, our devices are scrambling to catch errors and keep cruising along like nothing happened.
And their secret weapon?
Error detecting and correcting codes.
These are ways of encoding information so that it can be recovered even in the face of corruption.
And with the help of these codes, electronics can keep up the illusion of perfection.
Well, most of the time.
For the most part, we try to ignore the physicality of our computers,
pretending they work in some transcendent world of pure information.
But electrical engineers constantly have to grapple with the fact that that’s not true.
Like, the radio waves carrying SciShow from your router fade with distance.
Rampaging toddlers cover Blu-ray discs in scratches and smudges.
And unwanted electrical currents appear inside wires and chips,
caused by electrical fields from the wires next door, solar radiation, lightning,
or even intergalactic particles.
Engineers consider all these problems one big pile of noise
trying to drown out the signal that they care about.
But it’s not enough to slap a label on the noise; they need to mitigate it, too.
Broadly speaking, the solution is redundancy, or injecting redundant information.
That way, even if something gets lost, there’s backup information to salvage.
The naive approach to this would be simple repetition.
If if I I repeat repeat every every word word, it’s obvious when one’s gotten garbled or replaced.
Of course, that’s appallingly inefficient.
So the starting point for better codes is to add what’s called a parity bit to each block of the message.
The parity bit indicates whether there’s an even or odd number of 1s
in the binary version of that block.
If the number of 1s is even, the parity bit is 0. If the number is odd, the parity bit is 1.
Now, say the machine on the receiving end sees an odd number of 1s, but a parity bit of 0.
That means at least one of the bits got flipped, so you’ve got an error!
If the receiver can ask for another copy and errors are rare, that detection might be enough.
But for data storage, or when you don’t have much bandwidth,
you want something called forward error correction,
enough redundancy that the receiver can fix errors on its own.
Forward error correction was pioneered way back in the 1940s,
when a disgruntled Bell Labs employee named Richard Hamming
was working with a newfangled, ten-ton gizmo called a computer.
Hamming only had computer time on weekends,
when the machine was programmed to assume nobody was around to fix problems.
So when it detected corrupted data in Hamming’s programs,
it would just abort and move on to other tasks.
Hamming found it outrageous that the computercouldn’t also locate and repair the errors it had detected.
So he came up with a fix.
His idea, now known as a Hamming code, was to give every block of data several parity bits.
Each parity bit is responsible for checking different combinations of data bits.
So one might check the first, second, and fifth data bits,
another might check the first, third, and fourth,
one way or another, everything is covered, usually multiple times.
Each parity bit tells you whether its specific combination of data bits
should have an odd or even number of 1s.
So when the receiver notices that some parity bits don’t match their data,
all these overlapping patterns tell the receiver what needs to be changed.
Hamming codes are simple, fast, and frugal with space,
so they’re still popular in error-correcting memory chips.
But they can’t fix more than one error at a time.
That problem is solved by a family of more powerful schemes called Reed-Solomon codes.
Their first primetime use was beaming back high-res images
from NASA’s Voyager probes in the 1970s.
Instead of separating message and parity bits,
Reed-Solomon codes essentially make every chunk that’s sent equally informative about the entire message.
They do that by reinterpreting the original message not just as numbers,
but as points on a mathematical curve.
For redundancy’s sake, the sender also throws in some extra points along that same curve.
So even if a few spots are corrupted or missing by the time they reach the receiver,
the receiver can still reconstruct the right shape, and therefore, the right message, from the remaining points.
Reed-Solomon codes slash the survival rate of errors.
Plus they’re highly adjustable:
You can add in tons of redundant points, and even though that will make the message more bloated,
it will allow more errors to be corrected.
So it’s no surprise that these codes are wildly popular.
They are the patron saint of torn QR codes, banged-up hard drives, flawed cable TV receivers,
and tons of other technologies.
And they can even come with extra bells and whistles.
For example, many systems, including CDs and spacecraft,
interleave, or jumble, the bits after applying Reed-Solomon.
That protects against bursts of errors that would otherwise overwhelm the code.
Like, if your Blu-Ray gets a big long scratch,
un-jumbling spreads out those errors into many independently-correctable blocks.
Reed-Solomon codes take care of a lot, but there are also plenty of other codes out there
used in everything from the Internet to cell phones to cable TV,
and many are based on similar concepts.
So from parity bits to Reed-Solomon codes and beyond,
error-correcting and -detecting codes are the unsung heroes of the digital world.
And the next time you have a clear cell signal, or see a picture from space,
or even just check your email, you’ll know what to thank.
Also, if the signal isn’t so clear, well, you know how it goes.
Sometimes you beat the errors, and sometimes, the errors beat you.
Thanks for watching this episode of SciShow!
If you liked learning about how we use codes to keep our messages from getting scrambled,
you might also like our episode about how encryption works,
since that’s basically how we intentionally scramble messages to keep them safe!
[ ♪ Outro ]