Reference

Math Toolkit

Every tool the course uses, sharpened in five minutes or less.

Relativity needs less math than its reputation suggests: algebra, square roots, Pythagoras and a few friendly functions. This page has all of it.

How to use this page

This is a reference page, not a chapter. You don’t need to read it from top to bottom. Each section refreshes one piece of math, with one picture and four practice items.

  1. Jump in. A chapter’s “Need a refresher?” link opens the one section you need. You can also pick one from the list below.
  2. Read, then try. Read the refresher, look at the picture, then try the practice items. Answers can be fractions or roots: type 5/4 or sqrt(2).
  3. Head back. If you came from a chapter, use the “Back to …” link at the top of the page, or your browser’s Back button.

Each practice item shows how hard it is:

  • Back of the envelope: quick, in your head.
  • Pencil and paper: a few written steps.
  • Head-scratcher: harder, so take your time.

Pythagoras

In a right triangle, the squares on the two short sides (the legs) add up to the square on the long side (the hypotenuse). Legs 3 and 4: \(9 + 16 = 25\), so the long side is \(\sqrt{25} = 5\).

\[ \begin{aligned} a^2 + b^2 &= c^2, \\[4pt] c &= \sqrt{a^2 + b^2}, \\[4pt] b &= \sqrt{c^2 - a^2}. \end{aligned} \]

The same rule measures the straight-line distance between two points on a map: the east offset and the north offset are the legs.

Distance between two points Grid paper with points P at (1, 2) and Q at (4, 6). The east offset 3 and the north offset 4 form the legs of a right triangle; the straight line from P to Q is its long side, 5. P Q 3 east 4 north 5 distance = √(3² + 4²) = √25 = 5
Toolkit 1 The distance from P to Q is the long side of a right triangle whose legs are the east and north offsets.

Practice

A right triangle has legs 6 and 8. How long is the hypotenuse?

Hint

\(36 + 64 = 100\).

Solution

\(\sqrt{36 + 64} = \sqrt{100} = 10\). It’s the 3-4-5 triangle, doubled.

The hypotenuse is 25 and one leg is 7. How long is the other leg?

Hint

\(b^2 = 25^2 - 7^2 = 625 - 49\).

Solution

\(\sqrt{625 - 49} = \sqrt{576} = 24\): the 7-24-25 triangle.

How far is it from the point (1, 2) to the point (4, 6)?

Hint

The offsets are \(4 - 1 = 3\) and \(6 - 2 = 4\).

Solution

\(\sqrt{3^2 + 4^2} = 5\). Only the differences matter, not where you start.

How long is the diagonal of a square with sides of length 1? (Type sqrt(2) or a decimal.)

Hint

Both legs are 1, so \(c^2 = 1 + 1\).

Solution

\(\sqrt{1 + 1} = \sqrt{2} \approx 1.414\).

Sine, cosine and angles

In a right triangle, pick one of the two sharp angles and call it \(\theta\). The side that touches it (other than the hypotenuse) is the adjacent side; the side across from it is the opposite side. Their ratios to the hypotenuse depend only on the angle, not on how big the triangle is:

\[ \begin{aligned} \cos\theta &= \frac{\text{adjacent}}{\text{hypotenuse}}, \\[6pt] \sin\theta &= \frac{\text{opposite}}{\text{hypotenuse}}, \\[6pt] \tan\theta &= \frac{\text{opposite}}{\text{adjacent}}. \end{aligned} \]

Some people remember this as SOH-CAH-TOA. In the 3-4-5 triangle, the angle next to the side of length 4 has \(\cos\theta = 4/5 = 0.8\) and \(\sin\theta = 3/5 = 0.6\). That angle is about 36.87°. Because the two legs are \(\cos\theta\) and \(\sin\theta\) times the hypotenuse, Pythagoras gives \(\cos^2\theta + \sin^2\theta = 1\) for every angle.

Cosine and sine in the 3-4-5 triangle A right triangle with an angle theta at the lower left. The adjacent side along the bottom is 4, the opposite side going up on the right is 3, and the hypotenuse is 5. Beside it: cos theta = 4/5 = 0.8, sin theta = 3/5 = 0.6, tan theta = 3/4 = 0.75, and theta is about 36.87 degrees. θ 4 adjacent 3 opposite 5 cos θ = 4/5 = 0.8 sin θ = 3/5 = 0.6 tan θ = 3/4 = 0.75 θ ≈ 36.87°
Toolkit 2 Cosine is adjacent over hypotenuse and sine is opposite over hypotenuse. The 3-4-5 triangle has \(\cos\theta = 0.8\) and \(\sin\theta = 0.6\).

Degrees, radians and your calculator

Angles come in two units. In degrees a full turn is 360°; in radians it is \(2\pi \approx 6.283\). This course uses degrees. If your calculator says \(\cos 60 = -0.952\) instead of 0.5, it is set to radians: switch it to degrees (look for a DRG or MODE key). Code uses radians too: see Code basics.

Going backwards: inverse cosine

If you know the ratio and want the angle, use the inverse cosine, \(\arccos\). Calculators label it \(\cos^{-1}\); it means "the angle whose cosine is", not \(1/\cos\). So \(\arccos 0.8 = 36.87°\) and \(\arccos 0.6 = 53.13°\). Inverse sine, \(\arcsin\), works the same way.

Practice

A right triangle has a hypotenuse of 10 and an angle of 30°. How long is the side opposite that angle? (\(\sin 30° = 0.5\).)

Hint

Opposite = hypotenuse × \(\sin\theta\).

Solution

\(10 \times \sin 30° = 10 \times 0.5 = 5\).

Set your calculator to degrees. What is \(\cos 60°\)?

Hint

An equilateral triangle cut in half has angles 30°, 60° and 90°, and its short side is half the hypotenuse.

Solution

\(\cos 60° = 0.5\): in the half equilateral triangle, the side next to the 60° angle is half the hypotenuse.

A surveyor walks 100 m in a straight line, heading 10° north of east. How far north of her starting point does she end up, in meters?

Hint

Her path is the hypotenuse. North is opposite the 10° angle, so use sine.

Solution

\(100 \times \sin 10° = 100 \times 0.1736 = 17.36\) m north (and \(100 \cos 10° = 98.48\) m east).

An angle has \(\cos\theta = 0.6\). What is the angle, in degrees?

Hint

Use the inverse cosine, \(\cos^{-1}\) on a calculator.

Solution

\(\arccos 0.6 = 53.13°\). It’s the other sharp angle of the 3-4-5 triangle: \(53.13° + 36.87° = 90°\).

Squares and square roots

Squaring a number multiplies it by itself: \(7^2 = 49\). The square root undoes that: \(\sqrt{49} = 7\). Picture a square made of unit tiles. Its area is the square; its side is the square root.

Two rules carry most of the course. Roots of products split: \(\sqrt{4 \times 9} = \sqrt{4}\,\sqrt{9} = 6\). Roots of sums don’t: \(\sqrt{9 + 16} = 5\), not \(3 + 4 = 7\). And a negative number has no square root among ordinary numbers, which is why \(\sqrt{1 - v^2}\) needs \(v\) between −1 and 1 (that is, \(v^2\) below 1).

Squares and their sides Five squares made of unit tiles, with sides 1, 2, 3, 4 and 5 and areas 1, 4, 9, 16 and 25. Under each, the square root of the area gives back the side. 1 √1 = 1 4 √4 = 2 9 √9 = 3 16 √16 = 4 25 √25 = 5 area = side² side = √area
Toolkit 3 The area of a square is the square of its side; the square root takes you back from area to side.

Practice

What is \(\sqrt{144}\)?

Hint

Which number times itself makes 144?

Solution

\(12 \times 12 = 144\), so \(\sqrt{144} = 12\).

What is \(\sqrt{0.36}\)?

Hint

\(0.36 = 36/100\), and you can take the root of the top and the bottom separately.

Solution

\(\sqrt{36/100} = 6/10 = 0.6\). You’ll meet it as \(\sqrt{1 - 0.8^2}\).

What is \(\sqrt{9 + 16}\)?

Hint

Add first: \(9 + 16 = 25\).

Solution

\(\sqrt{25} = 5\), not 7.

Estimate \(\sqrt{50}\) to two decimal places. (A calculator is fine, but try first: \(7^2 = 49\).)

Hint

50 is a little more than 49, so the root is a little more than 7. Try \(7.07^2\).

Solution

\(7.07^2 = 49.98\), very close to 50, so \(\sqrt{50} \approx 7.07\). (Exactly, \(\sqrt{50} = 5\sqrt{2} = 7.0710\ldots\))

Slopes and graphs

The slope of a straight line is how much it rises for each step it runs: rise ÷ run. A line through (0, 0) and (4, 2) rises 2 while it runs 4, so its slope is \(2/4 = 0.5\). A line written \(y = m x + b\) has slope \(m\) and crosses the vertical axis at \(b\).

In a physics class, distance–time graphs put time along the bottom. A spacetime diagram puts time \(t\) pointing up, and distance \(x\) pointing right. A point on the diagram is an event, a time and a place, and the course writes it with time first: \((t, x)\). The path an object traces on the diagram is its worldline.

Because time points up, a moving object’s speed is how far it goes sideways for each step up: \(v = \Delta x / \Delta t\). That is run ÷ rise, the flip of the usual slope. So a steep line is slow, a vertical line is standing still, and a 45° line is light, which goes one step sideways for each step up.

Slope on an ordinary graph and on a spacetime diagram Left: an ordinary graph with a line through (0, 0) and (4, 2); it runs 4 and rises 2, so its slope is 0.5. Right: a spacetime diagram with time up and distance right; a worldline through the events t = 0, x = 0 and t = 10, x = 6 moves 6 sideways for 10 up, so its speed is 0.6. A gold light line at 45 degrees is drawn for comparison. x y run 4 rise 2 slope = 2 ÷ 4 = 0.5 x t t = 10, x = 6 v = 6 ÷ 10 = 0.6 light, 45°
Toolkit 4 Left: slope is rise over run. Right: on a spacetime diagram, speed is sideways over up, and light runs at 45°.

Practice

What is the slope of the line through (0, 0) and (4, 2)?

Hint

Rise 2, run 4.

Solution

\(2 / 4 = 0.5\).

What is the slope of the line through (1, 1) and (4, 7)?

Hint

Rise \(7 - 1 = 6\), run \(4 - 1 = 3\).

Solution

\(6 / 3 = 2\).

On a spacetime diagram, a worldline passes the events \((t, x) = (0, 0)\) and \((10, 6)\). What is its speed \(v\)?

Hint

Speed is sideways ÷ up: \(x \div t\), not \(t \div x\).

Solution

\(v = 6 / 10 = 0.6\): 60% of light’s speed.

On the line \(t = 0.6\,x + 4\), what is \(t\) when \(x = 3\)?

Hint

Substitute: \(0.6 \times 3 + 4\).

Solution

\(1.8 + 4 = 5.8\).

Units as ratios

“60 minutes per hour” is a fraction equal to 1: \(\frac{60\ \text{min}}{1\ \text{h}} = 1\). Multiplying by 1 never changes a quantity, only its units. So to convert, multiply by fractions like that, arranged so the unit you don’t want cancels top against bottom. The top row of Toolkit 5 turns 3 hours into seconds this way.

Light’s speed is a conversion factor

The course’s most important conversion factor is light’s speed. Light covers exactly 299 792 458 meters every second. That lets the course measure time in meters. One meter of time is the time light takes to go one meter: 1 ÷ 299 792 458 of a second, about 3.3 nanoseconds (billionths of a second).

So 1 second and 299 792 458 meters of time are two names for the same amount of time, like 1 hour and 60 minutes. So this fraction equals 1, the same way \(\frac{60\ \text{min}}{1\ \text{h}}\) does:

\[ \frac{299\,792\,458\ \text{m of time}}{1\ \text{s}} = 1. \]

Multiplying by it turns seconds into meters of time without changing how much time you have.

In 1 meter of time, light goes 1 meter. So light’s speed is 1 m (of distance) ÷ 1 m (of time) = 1, with no units left over. Slower things get smaller numbers: a car covers only a tiny part of a meter in each meter of time.

Measure time in meters and every speed becomes a plain number, the fraction of light’s speed. The course calls it \(v\). Here is the move in both directions:

  • \(v = 0.6\) means 0.6 × 299 792 458, about 180 000 000 meters per second.
  • A car at 30 m/s has \(v\) = 30 ÷ 299 792 458, about 0.000 000 1. The bottom row of Toolkit 5 shows every unit cancelling.
Two conversion chains Top: 3 hours times 60 minutes per 1 hour times 60 seconds per 1 minute equals 10 800 seconds. Hours cancel against hours and minutes against minutes. Bottom: a car’s 30 meters per 1 second times 1 second per 299 792 458 meters is about 0.000 000 1. Meters cancel against meters and seconds against seconds, so no unit is left: the answer is the car’s speed as a fraction of light’s speed. hours to seconds 3 h × 60 min 1 h × 60 s 1 min = 10 800 s light’s speed as the fraction: a car at 30 m/s 30 m 1 s × 1 s 299 792 458 m ≈ 0.000 000 1 no units left: a fraction of light’s speed
Toolkit 5 Each fraction equals 1, so multiplying by it changes only the units. The units you don’t want cancel (red slashes). In the bottom row every unit cancels, and what is left is the car’s \(v\).

Practice

How many seconds are there in 3 hours?

Hint

\(3 \times 60 \times 60\).

Solution

\(3\ \text{h} \times 60\ \tfrac{\text{min}}{\text{h}} \times 60\ \tfrac{\text{s}}{\text{min}} = 10\,800\ \text{s}\).

Convert 72 km/h into meters per second.

Hint

Multiply by \(\frac{1000\ \text{m}}{1\ \text{km}}\) and by \(\frac{1\ \text{h}}{3600\ \text{s}}\).

Solution

\(72 \times 1000 / 3600 = 20\) m/s.

How many meters of time is one nanosecond (\(10^{-9}\) s)?

Hint

One second is 299 792 458 m of time. Multiply by \(10^{-9}\).

Solution

\(299\,792\,458 \times 10^{-9} \approx\) 0.2998 m: roughly a foot. A nanosecond is “a foot of light”.

A rocket moves at \(v = 0.8\). What is that in meters per second? (Type big numbers without spaces, or like 3e8 for \(3 \times 10^8\).)

Hint

\(v = 0.8\) means 0.8 of light’s speed, and light’s speed is 299 792 458 m/s.

Solution

\(0.8 \times 299\,792\,458 \approx 240\,000\,000\) m/s, or \(2.4 \times 10^{8}\) m/s. In meters of time the rocket’s story is simpler: it goes 0.8 m for every meter of time.

Rearranging equations

An equation is a balance. Do the same thing to both sides and it stays balanced. To get a letter alone, undo whatever was done to it, in reverse order: if it was multiplied by 2 and then had 1 added, subtract 1 first, then divide by 2.

The course’s favorite rearrangement involves \(\gamma\) (gamma), the stretch factor: the number that says how big relativity’s effects are at a speed \(v\) (\(\gamma = 1\) means no effect at all). Its formula, \(\gamma = 1/\sqrt{1 - v^2}\), run backward gives the speed, \(v = \sqrt{1 - 1/\gamma^2}\). Each step is something you already know: flip both sides, square both sides, move a term across, take a root.

Show me the four steps

Suppose \(\gamma = 5/3\), so \(1/\sqrt{1 - v^2} = 5/3\). Find \(v\).

  1. Flip both sides: \(\sqrt{1 - v^2} = 3/5\).
  2. Square both sides: \(1 - v^2 = 9/25\).
  3. Move a term across: \(v^2 = 1 - 9/25 = 16/25\).
  4. Take a root: \(v = 4/5 = 0.8\).

Check: \(1 - 0.8^2 = 0.36\), \(\sqrt{0.36} = 0.6\), and \(1 \div 0.6 = 5/3\). The ★ item below uses the same four steps.

An equation as a balance Two balance scales, one above the other, each with a pan on top of each end of a level beam. The first holds 2x + 1 on the left pan and 5 on the right. Taking 1 from both sides gives the second balance: 2x on the left and 4 on the right, still level. Halving both sides gives x = 2. 2x + 1 5 take 1 from both 2x 4 halve both x = 2
Toolkit 6 Whatever you do to one side, do to the other, and the balance stays level.

Practice

Distance = speed × time: \(d = v\,t\). If \(d = 12\) and \(v = 0.6\), what is \(t\)?

Hint

Divide both sides by \(v\): \(t = d / v\).

Solution

\(t = 12 / 0.6 = 20\).

Solve \(2x + 1 = 5\) for \(x\).

Hint

Subtract 1 from both sides first.

Solution

\(2x = 4\), so \(x = 2\).

If \(y^2 = 25 - 9\) and \(y\) is positive, what is \(y\)?

Hint

\(y^2 = 16\).

Solution

\(y = \sqrt{16} = 4\).

If \(\dfrac{1}{\sqrt{1 - v^2}} = 1.25\), what is \(v\) (positive)?

Hint

Flip both sides: \(\sqrt{1 - v^2} = 1/1.25 = 0.8\).

Hint

Square both sides: \(1 - v^2 = 0.64\).

Solution

\(\sqrt{1 - v^2} = 0.8\), so \(1 - v^2 = 0.64\), so \(v^2 = 0.36\) and \(v = 0.6\). That’s the friendliest speed in the course: \(\gamma = 5/4\) at \(v = 3/5\).

Fractions

The course’s friendliest speeds are fractions: 3/5, 4/5, 5/13, 12/13. Working with them exactly keeps the answers clean. Three moves cover almost everything. To add, use a common bottom: \(\tfrac{3}{5} + \tfrac{4}{5} = \tfrac{7}{5}\). To divide by a fraction, multiply by its flip: \(1 \div \tfrac{4}{5} = \tfrac{5}{4}\). To square, square the top and the bottom: \(\left(\tfrac{3}{5}\right)^2 = \tfrac{9}{25}\).

Three fifths, squared A square divided into a 5 by 5 grid of 25 cells. A 3 by 3 corner of 9 cells is shaded: that is three fifths squared, 9 over 25. The 16 unshaded cells are what is left, 1 minus 9 over 25, which is 16 over 25, the same as four fifths squared. 9 16 3/5 3/5 (3/5)² = 9/25 1 − 9/25 = 16/25 16/25 = (4/5)²
Toolkit 7 Squaring 3/5 marks 9 of 25 cells (hatched); the 16 left over are (4/5)². This is the arithmetic behind \(\gamma = 5/4\).

Practice

\(\tfrac{3}{5} + \tfrac{4}{5} = \;?\) (A fraction like 7/5 is fine.)

Hint

Same bottom, so add the tops.

Solution

\(\tfrac{7}{5} = 1.4\).

\(1 \div \tfrac{4}{5} = \;?\)

Hint

Multiply by the flip, \(\tfrac{5}{4}\).

Solution

\(\tfrac{5}{4} = 1.25\).

\(\left(\tfrac{3}{5}\right)^2 = \;?\)

Hint

\(3^2 = 9\) and \(5^2 = 25\).

Solution

\(\tfrac{9}{25} = 0.36\).

\(1 - \left(\tfrac{3}{5}\right)^2 = \;?\)

Hint

Write 1 as \(\tfrac{25}{25}\).

Solution

\(\tfrac{25}{25} - \tfrac{9}{25} = \tfrac{16}{25}\), which is \(\left(\tfrac{4}{5}\right)^2\). Its square root is \(\tfrac45\), and one over that is \(\tfrac54\).

Exponentials and logarithms

The number \(e \approx 2.718\) is the natural base for growth and decay. \(e^x\) means \(e\) multiplied by itself \(x\) times (and it makes sense for any \(x\), not only whole numbers). The natural logarithm \(\ln\) undoes it: \(\ln(e^x) = x\), and \(e^{\ln y} = y\).

The rule that makes logarithms useful: they turn multiplying into adding, \(\ln(a\,b) = \ln a + \ln b\). Decay uses \(e\) too: for muons sitting still in a lab, the fraction still alive after a time \(t\) is \(e^{-t/\tau}\), where \(\tau\) is the average lifetime, 2.2 μs. For fast muons, the key question is: whose clock measures \(t\)? A later chapter answers it.

e to the x and ln x The curves y = e to the x and y = ln x are mirror images across the dashed line y = x. e to the x passes through (0, 1); ln x passes through (1, 0). y = eˣ y = ln x y = x (0, 1) (1, 0)
Toolkit 8 \(e^x\) and \(\ln x\) undo each other, so their graphs are mirror images across the line \(y = x\).

Practice

What is \(\ln\!\left(e^3\right)\)?

Hint

\(\ln\) undoes \(e^{(\ )}\).

Solution

3: the logarithm hands back the power.

What is \(e^0\)?

Hint

Look at where the blue curve crosses \(x = 0\).

Solution

\(e^0 = 1\).

\(\ln 2 + \ln 3 = \ln N\). What is \(N\)?

Hint

\(\ln a + \ln b = \ln(a\,b)\).

Solution

\(\ln(2 \times 3) = \ln 6\), so \(N = 6\).

A batch of muons sits still in a lab for two average lifetimes. What fraction is still alive? (It’s \(e^{-2}\); give a decimal.)

Hint

\(e^{-2} = 1/e^2 \approx 1/7.39\).

Solution

\(e^{-2} \approx 0.135\): about 13.5%, roughly one in seven.

Approximations for small numbers

When a number is tiny, some awkward formulas shrink to arithmetic you can do in your head. Take \(x\) = 0.01. Then 1 − \(x\) = 0.99, and 1 ÷ 0.99 = 1.0101…, very nearly 1 + \(x\) = 1.01. And 1 ÷ √0.99 = 1.00504…, very nearly 1 + \(x\)/2 = 1.005. The pattern holds for any tiny number \(x\):

\[ \begin{aligned} \frac{1}{1 - x} &\approx 1 + x, \\[8pt] \frac{1}{\sqrt{1 - x}} &\approx 1 + \frac{x}{2}. \end{aligned} \]

Two cousins work the same way. Flip the sign: \(1/(1 + x) \approx 1 - x\) (1 ÷ 1.01 = 0.990…). Square: \((1 + x)^2 \approx 1 + 2x\) (1.01² = 1.0201).

Why do they work?

Tiny times tiny is tinier still. 0.99 × 1.01 = 0.9999, which misses 1 by only 0.01². Ignore it, and 1.01 is the flip of 0.99. Likewise, 1.005² = 1.010 025, which is 1.01 once you ignore the tiny 0.000 025. So 1.005 is very nearly 1 ÷ √0.99.

The shortcut and the real thing For x from 0 to 0.9, the curve 1 over the square root of 1 minus x, and the straight line 1 plus x over 2. Near x = 0 they are almost the same; past about x = 0.3 the curve pulls away upward. almost the same for small x 1 1.5 2 2.5 0.4 0.8 x 1/√(1 − x) 1 + x/2
Toolkit 9 The shortcut \(1 + x/2\) (dashed) hugs the true curve near zero and drifts away only when \(x\) is large.

What it means for speeds

The stretch factor \(\gamma\) (the Greek letter gamma) is the number that says how big relativity’s effects are at a speed \(v\) (\(\gamma = 1\) means no effect at all). Its formula is \(\gamma = 1/\sqrt{1 - v^2}\), and Chapter 5 builds it from a clock made of light. Put \(x = v^2\) into the second shortcut and you get the course’s most useful one:

\[ \gamma \approx 1 + \tfrac12 v^2. \]

Watch the units

Here \(v\) is not in meters per second. It is the speed as a fraction of light’s speed, so light has \(v = 1\) (see Units as ratios). A car at 30 m/s has \(v\) = 30 ÷ 299 792 458, about 0.000 000 1. Half of its square is about 0.000 000 000 000 005. Put in 30 for \(v\) and you get ½ × 30² = 450, which means nothing here.

So the car’s \(\gamma\) is 1.000 000 000 000 005, and a 10-digit calculator shows 1. A jet airliner at 250 m/s has \(v\) of about 0.000 000 83, and half its square is about 0.000 000 000 000 35. That is why relativity hides at the speed of a car or a plane: it is there, 13 or more places after the decimal point. The shortcut works only for small \(v\): at \(v = 0.995\) it gives 1.5, but the true \(\gamma\) is 10.

Practice

Use the shortcut to estimate \(\dfrac{1}{1 - 0.01}\).

Hint

\(1/(1 - x) \approx 1 + x\) with \(x = 0.01\).

Solution

\(1 + 0.01 = 1.01\). The exact value is 1.0101…, so the shortcut is off by about one part in ten thousand.

Use the shortcut to estimate \(\dfrac{1}{\sqrt{1 - 0.02}}\).

Hint

\(1/\sqrt{1 - x} \approx 1 + x/2\) with \(x = 0.02\).

Solution

\(1 + 0.01 = 1.01\) (exact: 1.01015…).

Estimate the stretch factor \(\gamma\) at \(v = 0.1\) using \(\gamma \approx 1 + \tfrac12 v^2\).

Hint

\(v^2 = 0.01\), and half of that is 0.005.

Solution

\(1 + 0.005 = 1.005\). The exact value is \(1/\sqrt{0.99} = 1.00504\ldots\)

A satellite moves at 3 km/s. As a fraction of light’s speed, that is about \(v = 10^{-5}\) (0.000 01). By how much does \(\gamma\) exceed 1? Give \(\gamma - 1\). (Type tiny numbers like 2e-9 for \(2 \times 10^{-9}\).)

Hint

\(\gamma - 1 \approx \tfrac12 v^2\), and \(v^2 = 10^{-10}\).

Solution

\(\tfrac12 \times 10^{-10} = 5 \times 10^{-11}\), or 0.000 000 000 05. Most calculators can’t even show \(\gamma\) itself to that many digits; the shortcut gets the tiny difference directly.

cosh, sinh and tanh

Chapter 13 builds these functions and uses them for speeds. If no chapter has sent you here yet, it is fine to skip this section for now.

These three functions sound exotic, but they are built from \(e^x\) with plain arithmetic:

\[ \begin{aligned} \cosh\theta &= \frac{e^{\theta} + e^{-\theta}}{2}, \\[6pt] \sinh\theta &= \frac{e^{\theta} - e^{-\theta}}{2}, \\[6pt] \tanh\theta &= \frac{\sinh\theta}{\cosh\theta}. \end{aligned} \]

Try \(\theta = \ln 2\), so \(e^{\theta} = 2\) and \(e^{-\theta} = \tfrac12\). Then \(\cosh\theta = (2 + 0.5)/2 = 1.25\), \(\sinh\theta = (2 - 0.5)/2 = 0.75\), and \(\tanh\theta = 0.75/1.25 = 0.6\). All three belong to the speed \(v = 0.6\) (3/5): 0.6 is \(v\) itself, 1.25 is its stretch factor \(\gamma\), and 0.75 is \(\gamma v\), a number a later chapter puts to work.

Now check: \(1.25^2 - 0.75^2 = 1.5625 - 0.5625 = 1\). That is no coincidence: \(\cosh^2\theta - \sinh^2\theta = 1\) for every \(\theta\). So the point \((\cosh\theta, \sinh\theta)\) always lies on the hyperbola \(x^2 - y^2 = 1\), the same way \((\cos\phi, \sin\phi)\) always lies on the circle \(x^2 + y^2 = 1\).

Why is cosh² − sinh² always 1?

Write \(p = e^{\theta}\) and \(q = e^{-\theta}\). Their product is \(e^{0} = 1\). Also \(\cosh\theta = (p + q)/2\) and \(\sinh\theta = (p - q)/2\). So:

\[ \begin{aligned} &\cosh^2\theta - \sinh^2\theta \\[4pt] &\quad = \frac{(p + q)^2 - (p - q)^2}{4} \\[6pt] &\quad = \frac{4pq}{4} = 1. \end{aligned} \]

Expand both squares to see the middle step: everything cancels except \(4pq\).

The unit circle and the unit hyperbola The unit circle x squared plus y squared equals 1, and the right branch of the unit hyperbola x squared minus y squared equals 1, which touches the circle at (1, 0). Gold 45 degree lines, y = x and y = −x, are light lines: the hyperbola approaches them but never touches. The point (1.25, 0.75), which is (cosh ln 2, sinh ln 2), is marked on the hyperbola. (1.25, 0.75) cosh sinh x² − y² = 1 y = x y = −x x² + y² = 1
Toolkit 10 The circle is where \(\cos\) and \(\sin\) live; the teal hyperbola is where \(\cosh\) and \(\sinh\) live. The marked point is \(\theta = \ln 2\). The hyperbola gets ever closer to the gold diagonals but never touches them.

Practice

What is \(\cosh 0\)?

Hint

\(e^0 = 1\).

Solution

\((1 + 1)/2 = 1\): the point where the hyperbola touches the circle.

With \(e^{\theta} = 2\), what is \(\cosh\theta\)?

Hint

\(e^{-\theta} = 1/2\).

Solution

\((2 + 0.5)/2 = 1.25\).

With \(e^{\theta} = 2\), what is \(\sinh\theta\)?

Hint

Subtract instead of adding: \((2 - 0.5)/2\).

Solution

\(1.5/2 = 0.75\).

With \(e^{\theta} = 2\), what is \(\tanh\theta\)?

Hint

\(\tanh = \sinh / \cosh = 0.75 / 1.25\).

Solution

\(0.6\), the speed 3/5. A later chapter calls this \(\theta\) the rapidity of that speed.

Code basics

Every “Build it” section asks for one small JavaScript function. Here is everything the first one needs, for reference. Later chapters add a little more, and each addition is explained right where it’s first used.

  • A function has a name, inputs in brackets (parameters), and a body in braces. return sends back the answer.
  • Arithmetic: + - * /. Powers: 3 ** 2 is 9. Brackets work as in algebra: (1 + 2) * 3 is 9.
  • Square roots: Math.sqrt(49) is 7. Pythagoras in one call: Math.hypot(3, 4) is 5.
  • Scientific notation: 3e8 is \(3 \times 10^8\) and 2.2e-6 is \(2.2 \times 10^{-6}\).
  • Angles: Math.cos and Math.sin use radians, not degrees, so convert first: Math.cos(60 * Math.PI / 180) gives 0.5 (to 15 decimal places). Going backwards, Math.acos(0.8) gives radians (0.6435); multiply by 180 / Math.PI to get degrees (36.87).
  • The test table lists each test’s name (what it checks), the Input it tried, the Expected answer, what your function returned (Got) and the Result. Fix the first failing row first. For that row, compare Got with Expected for the same Input.

Here is a made-up table for double(x), written by mistake as return x + 2;.

Example test table for double
TestInputExpectedGotResult
doubles 2double(2)44pass
doubles 21double(21)4223fail

The first row passes by luck: 2 + 2 and 2 × 2 are both 4. The second row fails. For the input 21, Expected says 42 but Got says 23, which is 21 + 2. So the function adds 2 where it should multiply by 2.

The parts of a function Three lines of code: function double, open bracket x close bracket, open brace; return 2 times x semicolon; close brace. Labels point to the keyword function, the name double, the parameter x, the keyword return and the answer 2 times x. function double(x) { return 2 * x; } keyword name input (parameter) sends the answer back the answer it computes
Toolkit 11 Anatomy of a function: double(21) runs the body with x = 21 and returns 42.

Practice

What is 3 ** 2?

  • 6
  • 9
  • 32
Hint

** raises to a power.

Solution

\(3^2 = 9\).

Given function triple(x) { return 3 * x + 1; }, what does triple(4) return?

Hint

Put 4 in place of x.

Solution

\(3 \times 4 + 1 = 13\).

Which line correctly returns the long side of a right triangle with legs a and b?

  • return Math.sqrt(a + b);
  • return Math.sqrt(a * a + b * b);
  • return a ** 2 + b ** 2;
Hint

Try each with \(a = 3, b = 4\). Which gives 5?

Solution

Math.sqrt(a * a + b * b) gives \(\sqrt{25} = 5\).

In the test table, which column shows what your function actually returned?

  • Input
  • Expected
  • Got
Hint

Which column would change if you changed your code?

Solution

Got. When it differs from Expected, that row fails.

Ready to use it? The prologue’s Build it section has a one-line warm-up and your first function.