Q: How good is the Enigma code system compared to today’s publicly available cryptography systems?

Physicist: Freaking terrible.

The Enigma machine used a “rolling substitution cypher” which means that it was essentially a (much more) complicated version of “A=1, B=2, C=3, …”.  The problem with substitution cyphers is that if parts of several messages are the same then you can compare their similarities to break the code.  Enigma was broken in part because of German formality (most messages started with the same formal greeting).  Even worse, since some letters are more common than others (e.g., “e” and “g”) you can make progress by just counting up how often letters show up in the code (or even get an idea of what language the code is written in without breaking it!).  Substitution cypher are so easy to break that some folk do it for funRolling substitution cyphers can use a set of several encoding schemes and cycle through which code is used or make the scheme dependent on the previous letter, but this merely makes the code breaking more difficult.  Ultimately, all substitution cyphers suffer from the same difficulty: similar messages produce similar looking codes.

Enigma used three rotors which rotated after each letter was pressed allowing them to generate a huge number of different codes, using a different one for each letter.  Still: what your cellphone uses is much, much better.

Enigma used three rotors which rotated after each letter was pressed allowing them to generate a huge number of different substitution cyphers, using a different one for each letter.  Still: what your cellphone uses is much, much better.

Modern cryptography doesn’t have that problem.  If any part of a message is different at all, then the entire resulting code is completely different from beginning to end.  That is; if you encrypted a message, you’d get cypertext (the encoded message) and if you were to encrypt the exact same message but misspelled a single word, then the cypertext would be completely different.

If your messages were “Hello A”, “Hello B”, and “Hello C”, then a substitution cypher might produce “Tjvvw L”, “Tjvvw C”, and “Tjvvw S” while RSA (the most common modern encryption) might produce “idkrn7shd”, “62hmcpgue”, and “nchhd8pdq”.  In the first case you can tell that the messages are nearly the same, but in the second you got nothing.

Enigma was very clever but is shockingly primitive compared to modern crypto techniques.  If anyone in WW2 had been using modern (1970’s or later) encryption, then there is no way that anyone would have been able to break those codes (and Turing would have to settle for being famous for everything else he did).

There’s a post here that talks about the main ideas behind RSA encryption.  The really fancy stuff is some of the only math that isn’t publicly known.  Scientists have a whole thing about openness and the free exchange of information that governments and corporate entities (for whatever reason) don’t.

Posted in -- By the Physicist, Computer Science, Math, Number Theory, Paranoia | 5 Comments

Q: When “drawing straws” is it better to be first or last?

Physicist: As long as the person who cut the straws: 1) takes the last remaining straw and 2) has a decent poker face (or doesn’t know which is which), then it’s completely fair.  If they have a bad poker face, then it’s better to be first.

If the person who cuts and holds the straws has a terrible poker face, then the first few people have an advantage.

The quickest way to see why is to imagine a slightly different way of drawing straws.  Instead of drawing straws, draw cards where all but one are black (for example).  Everyone takes a card and afterward everyone turns their card over; the one red card is the “short straw”.  In this case it should make sense that no person is more or less likely to get the red card for the same reason that it’s no more or less likely for any particular card to be any particular place in a deck.  The fact that when drawing straws we pull one at a time and generally stop halfway through (whenever the short straws appears) makes it fell like the situation is different, but it’s not.

Say you’ve got N peeps (people).  The first person to draw a straw is the least likely to draw the short one (1/N) and the last to draw is the most likely (1/2).  However!  While the later people are more likely to draw the short straw, they’re also less likely to pull any straw since it’s more likely that the short straw has already been drawn.  In movies they almost always draw every straw because of drama, but in practice, you draw until the short one shows up and then you stop.

The early people are least likely to draw the short straw while the later people are least likely to draw at all.  If you write down the math you find that the effects balance out exactly.  So here’s the math written down:

You’ve got N peeps named One, Two, Three, etc. (probably siblings).

The first person has N straws to choose from and their probability of getting the short one is P=\frac{1}{N}.  Easy enough.  The second person has N-1 straws to choose from, so you might expect that their chance of drawing the short straw is P=\frac{1}{N-1}.  But that’s not the probability that counts.  What counts is the probability of drawing the short straw given that it hasn’t been drawn already.  That probability is P=\left(\frac{N-1}{N}\right)\left(\frac{1}{N-1}\right)=\frac{1}{N}.  $\frac{N-1}{N}$ is the probability that the first person did not already draw the short straw.

By the time it’s the Jth person’s turn there are N-J+1 straws remaining.  The probability that the short straw is among them (the probability that it hasn’t been drawn already) is \frac{N-J+1}{N}.  And if it hasn’t, then the probability of drawing it is \frac{1}{N-J+1}.  So, all in all, the probability of the Jth person drawing the short straw is P=\left(\frac{N-J+1}{N}\right)\left(\frac{1}{N-J+1}\right)=\frac{1}{N}.

Finally, the last person to draw is the person who cut the straws.  This person’s choice is random because everyone else’s choices were random: knowing which straw is which doesn’t change that.

Posted in -- By the Physicist, Math, Probability | 4 Comments

Q: What would happen if there was a giant straw connecting the Earth’s atmosphere right above the ground to space?

Physicist: About the same thing that happens to a straw in a glass of water: the water level in the straw evens out with the water level outside.

The pressure at the bottom of the straw "tells" the water in the straw how high to climb.  That same pressure "tells" the rest of the water the exact same thing.

The pressure at the bottom of the straw “tells” the water in the straw how high to climb. That same pressure “tells” the rest of the water the exact same thing.

A tube from the ground to space would fill with air of about the same density and pressure as the air around the straw, decreasing as you go up until eventually you have a straw full of nothing surrounded by also nothing (in space).

What holds the atmosphere to the planet is gravity, so if a patch of air tries to drift off into space it literally falls back.  A straw alone wouldn’t change that.  On the other hand, if you attached some kind of pump to the bottom of the straw to make it have a higher pressure than sea-level, then you could pump air up the straw and have some kind of massive space-fountain of air (the air coming out would fall back to Earth just like water in an ordinary fountain).  In fact!  There is a situation very close to that happening on Saturn’s moon, Enceladus.

The water-vapor fountains shoot directly into space.  Most of it falls back onto the ground.

The water-vapor geysers of Enceladus shoot directly into space. Most of it falls back onto the ground, but a tiny amount ends up orbiting Saturn and contributing to one of its rings.

Whenever air or water or whatever travels up a straw it’s being pushed by pressure from the bottom (there’s no such thing as sucking), and one atmosphere of pressure can only push so far.  For something like liquid mercury that’s about 76cm, which is why the “1 atmosphere” of pressure is often expressed as “760mm of Mercury”.  If a closed tube is taller than that, then the pressure (here on Earth) isn’t great enough to push the mercury to the top which leaves nothing at the top.

So that's mercury.

So that’s mercury.

Same idea with air.  If you have a long tube full of air with the top open to space and the bottom pressurized to one atmosphere (or 760mm Hg), then the column of air in the tube will be as tall as the atmosphere.

A straw doesn’t provide an “escape route”; our air is free to try to leave whenever.  The atmosphere stays where it is because it’s made of mass and the Earth has gravity.  It’s a little sobering to realize that there’s nothing between you and a profound nothing (space) but a thin layer of air held down by its own unimpressive weight.

The barometer picture is from here.

Posted in -- By the Physicist, Physics | 2 Comments

Q: Can a human being survive in the fourth dimension?

Physicist: Nopers.  But to understand why, it’s important to know what a dimension is.

When someone says “we live in the third dimension” what they should really say (to be overly-precise) is “the universe we inhabit has three spacial dimensions”.  There are a few ways that you can tell that you live in a three dimensional world.  The easiest is to try to come up with as many mutually-perpendicular directions as you can; you’ll find three without too much trouble, but you’ll never find a fourth.

These three directions are mutually perpendicular and and no new direction can be.

These three directions are mutually perpendicular and and no new direction can be perpendicular to all three.

If you’re feeling terribly clever, you’ll find lots of other examples that demonstrate the three (and not two or four) dimensionality of our universe.  For example, if you can tie a simple knot then you definitely live in three or more dimensions (no knots in 2-D) and if you can make a Klein bottle then you definitely live in four or more dimensions.

In 2-D you can't tie a knot without the rope passing through itself, and in 3-D you can't build a Klein bottle without essentially the same problem.

In 2-D you can’t tie a knot without the rope passing through itself, and in 3-D you can’t build a Klein bottle without the same problem.

A dimension is a direction.  Living in more dimensions means having more directions you can move in.  There are many weird physical consequences to living in more dimensions, but the one you’d notice first (if you were somehow to suddenly to appear in a 4-D universe) is immediate death.

An actual 2-D creature would collapse in 3-D, and there would be nothing to distinguish its outside form its inside.

An actual 2-D creature would collapse in 3-D.  What it considers to be its insides just looks like more surface to we 3-D folk.

If a paper doll (two-dimensional being) were suddenly brought into three dimensional space all of its innards would become outtards.  Similarly, there is nothing whatsoever supporting your body in a fourth direction, so if you were to find yourself with a few extra dimensions your insides would follow the path of least (zero) resistance and fall out.  It would be super gross, but would make no more of a mess than an infinitely thin oil slick.  Any local 4-D critters probably wouldn’t even notice.

Posted in -- By the Physicist, Math, Paranoia, Physics | 17 Comments

Q: Why radians?

Physicist: Because calculus.

When you first start doing trigonometry the choice between radians, degrees, turns, or hexacontades is a matter of personal preference.  Most people use degrees because most other people use degrees (and other people seem pretty on the ball).  But when you get to calculus using radians is the most natural choice; anything else is just a headache waiting to happen.

To see why you have to get to know the unit circle.

The unit circle (which has a radius of 1) with the definitions of sine, cosine, and radians.

The unit circle.  “Unit” means “1” and refers to the radius.

Start with a unit circle with a horizontal line through it and a radius (“a radius” means a line from the center to the edge somewhere).  The definition of sine and cosine of the angle between the radius an the horizontal line are in the picture above.  SOH CAH TOA is easy in this case because the hypotenuse is 1.

When you use radians you’re describing the angle by using the length of the arc it traces out on the edge of the unit circle.  The circumference of a circle or radius R is 2πR, so (since R=1 on the unit circle) the full circle is 2π radians around.  That is: 2π radians = 360 degrees.

You’ll notice that when the angle is very small (and measured in radians) the value of sin(θ) and the value of θ itself become very nearly equal.  Not too surprisingly, this is called the “small angle approximation” and it’s remarkably useful.

For small angles sin(θ)≈θ.

For small angles sin(θ)≈θ, but only when that angle is described in radians.

So for small values sin(θ)≈θ or \frac{\sin(\theta)}{\theta}\approx 1.

In fact, in the limit as the angle approaches zero they are equal, or in mathspeak: \lim_{\theta\to0}\frac{\sin(\theta)}{\theta}= 1.  When someone says “in the limit as ___ approaches ___” it means they’re about to talk about calculus (and true to form…).  All of the calculus around trig functions can be based on the fact that \lim_{\theta\to0}\frac{\sin(\theta)}{\theta}= 1.  For example, one of the more important things in the world (that’s not quite sarcasm) is the fact that \frac{d}{dx}\left[\sin(x)\right] = \cos(x).

The derivative of a function is \frac{d}{dx}f(x) = \lim_{h\to0}\frac{f(x+h)-f(x)}{h}, so:

\begin{array}{ll}    \frac{d}{dx}\left[\sin(x)\right]\\[2mm]    = \lim_{h\to0} \frac{\sin(x+h)-\sin(x)}{h}\\[2mm]    = \lim_{h\to0} \frac{\sin(x)\cos(h)+\sin(h)\cos(x)-\sin(x)}{h} & *\\[2mm]    = \lim_{h\to0} \frac{\sin(x)\left(\cos(h)-1\right)+\sin(h)\cos(x)}{h} \\[2mm]    = \lim_{h\to0} \frac{\cos(h)-1}{h}\sin(x)+\frac{\sin(h)}{h}\cos(x) \\[2mm]    = \lim_{h\to0} \left[-\sin(h)\frac{\sin(h)}{h} \frac{1}{\cos(h)+1}\right]\sin(x)+\frac{\sin(h)}{h}\cos(x) & ** \\[2mm]    = \left[-0\cdot 1 \cdot \frac{1}{1+1}\right]\sin(x)+\cos(x) \\[2mm]    =\cos(x)    \end{array}

That doesn’t look like a big deal, but keep in mind that all of trigonometry is just a rehashing of sine.  For example, \cos(x)=\sin\left(x-\frac{\pi}{2}\right) and \tan(x)=\frac{\sin(x)}{\cos(x)}=\frac{\sin(x)}{\sin\left(x-\frac{\pi}{2}\right)}.

If it weren’t for the fact that (when using radians) \sin(x)\approx x we wouldn’t have \frac{d}{dx}\left[\sin(x)\right] = \cos(x).

It’s not the end of the world if you try to do calculus with trig (it’s close), it’s just that the result is multiplied by an inconvenient constant.  For example, if you’re using degrees: \frac{d}{dx}\left[\sin(x)\right] = \frac{\pi}{180}\cos(x).  Same thing happens when you differentiate cosine or tangent or whatever.  It’s a lot easier to understand why if you look at a graph.

x, sin(x) in radians, and sin(x) in degrees

x, sin(x) in radians, and sin(x) in degrees.  Notice that when measured in radians sin(x)≈x for small x, and when using degrees sine is really stretched out.

Clearly when using degrees the slope (derivative) of sine at zero is not 1, it’s much smaller (it’s 2π/360 in fact).  If you don’t want any weird extra constants, then you need to use radians.  But if you don’t mind them, then you be you.  You can certainly use degrees or whatever, but you need to be careful with all those extra 2π/360’s.


* This is a trigonometric identity.

** That isn’t obvious:

\begin{array}{ll}    \frac{\cos(h)-1}{h} \\[2mm]    = \frac{\cos(h)-1}{h}\frac{\cos(h)+1}{\cos(h)+1} \\[2mm]    = \frac{\left(\cos^2(h)-1\right)}{h\left(\cos(h)+1\right)} \\[2mm]    = \frac{-\sin^2(h)}{h\left(\cos(h)+1\right)} \\[2mm]    = -\sin(h)\frac{\sin(h)}{h} \frac{1}{\cos(h)+1} \\[2mm]    \end{array}

Posted in -- By the Physicist, Conventions, Geometry, Math | 2 Comments

Q: If the Sun pulls things directly toward it, then why does everything move in circles around it?

Physicist: Newton’s laws of motion say:

M_PA_P = F = -G\frac{M_SM_P}{R^2}

Where MP and AP are the mass and acceleration of a planet, MS is the mass of the Sun, R is the distance between them, and G is a universal constant.  What this rather bold statement says is “if you exist near the Sun, then you are accelerating toward it”.  Each of the planets, moons, grains of dust, etc. all say the same thing, it’s just that with 99.86% of the mass in the solar system, the Sun says it loudest.

A force, like gravity, accelerates the object it acts on.  So to understand what a force does it’s important to understand acceleration.  Velocity describes how fast your position is changing, while acceleration describes how fast your velocity is changing.

“Velocity” is different from “speed” because velocity is a description of how fast you’re going and in which direction; “10 mph north” is a velocity, while “10 mph” is a speed.  So you can have an acceleration that changes your velocity by changing your speed and/or by changing your direction.

Imagine you’re in a car (your velocity points forward):

If you accelerate forward, you speed up.

If you accelerate backward, you slow down (“decelerate”).

If you accelerate to the right or left, you turn in that direction but maintain the same speed.

Notice that when you talk about acceleration this way, suddenly the same push you feel into your seat when you step on the gas is the same as the push you feel into your seat belt when you brake and the same as the centrifugal force pushing you to the left when you turn right.

A planet orbiting the Sun is always accelerating toward it.  But rather than changing the planet's speed, the acceleration changes the planet's direction.

A planet orbiting the Sun is always accelerating toward it. But rather than changing the planet’s speed, the acceleration changes the planet’s direction.

With planets the same rules apply.  A planet moving around the Sun in a circular orbit always has the Sun about 90° to the side of the direction they’re moving.  This means that the planet is always turning, but always moving at about the same speed.  The planets are moving so fast that by the time they’ve turned a little, they’ve moved far enough that the Sun is in a new position, still 90° to the side.

So that’s how a planet can accelerate toward the Sun forever without getting any closer.  The sideways motion of planets is due to the fact that if a planet were not moving sideways, it would find itself in the Sun in short order.  In fact, the Sun is nothing more than a massive collection of all the matter from the formation of the solar system that wasn’t moving sideways fast enough (which is nearly all of it).

Why things end up in circular orbits is a more subtle question.  The quickest explanation is that things in not-circular orbits run into trouble until either their orbit is sufficiently round or they’re destroyed.  It’s not that circular orbits are somehow better, it’s just that other orbits carry more risk of serious impacts or gravitational interactions (e.g., with Jupiter) that may lead to short, unfortunate orbits.

Assuming that an orbit is stable, then it will be an ellipse (there’s a post here on exactly why, but it’s a a whole thing.).  A circle is the simplest kind of ellipse, but ellipses can be extremely stretched out.  For example, comets have very elliptical orbits (like Sedna in the picture below).  In these orbits the comet is mostly moving toward and away from the Sun, so for them the Sun’s pull mostly changes their speed and changes their direction less.

The solar system.

The solar system.

There’s nothing special about the orbits the planets are in.  The eight (or nine or more) planets we have in the solar system aren’t the only planets that formed, they’re the only planets left.  When things are in highly elliptical orbits they tend to “drive all over the road” and smack into things.  When things smack into each other one of a few things happen; generally they break or they don’t.  When we look at our planetary neighbors we see craters indicating impacts right up to the limit of what that planet or moon could handle without shattering.  Presumably there should be impacts bigger than a planet can stand, but (not surprisingly) those impacts don’t leave craters for us to find.

Stickney Crater on Mars' moon Phobos.

Stickney Crater (left side) on Mars’ tiny moon Phobos or “Why Phobos Nearly Wasn’t”.

So objects with extremely elliptical orbits are more likely to get blown up.  But even when two objects hit each other and merge, the resulting trajectory is an average of both objects’ original trajectories, and that tends to be more circular.  This is a part of accretion, and Saturn’s rings provide a beautiful example of the nearly perfect circular orbits that result from it.

The grains of dust in orbit around Saturn bump into each other and slowly average out until their orbits are almost perfectly circular (meaning they bump into each other far less often).

The grains of dust in orbit around Saturn bump into each other and slowly average out until their orbits are almost perfectly circular (which means they bump into each other far less often).

Given a tremendous amount of time, a big blob of material in space tends to condense into a ball (with most of the matter) and a thin disk of left over material traveling in circular orbits around it.

Posted in -- By the Physicist, Astronomy, Evolution, Physics | 6 Comments