Shelves / Arithmetic and Numbers
AN·10
Powers, Roots, Scientific Notation and Logarithms
Repeated multiplication and its inverses: what powers are and why the exponent laws hold, why a⁰ = 1 and a⁻ⁿ = 1/aⁿ are forced, why −2² is −4, roots and fractional exponents, finding square roots by averaging, why areas scale by k² and volumes by k³, scientific notation for the very large and very small, compound growth in closed form, and logarithms: the exponent you need, why they turn multiplication into addition, how they count digits, and why every digit-counting formula in code eventually fails in floating point.
Start here
What this chapter answers
Why is , and why is anything to the power 0 equal to 1? What does mean, and ? Is equal to 4 or ? How can you find to fifty digits with a pencil? Why does a map twice the size need four times the paper? How do scientists write the mass of an electron, and how many years does money take to double at 8 %? What is a logarithm, and why does it count digits?
Powers in one picture
Fold a sheet of paper in half: 2 layers. Again: 4. Again: 8. After folds there are layers, with twos. Ten folds make 1,024 layers. That's a power: repeated multiplication, written with the number of repeats raised. Asking "how many folds give a million layers?" runs it backwards, and the answer, about 20, is a logarithm. This chapter is about going forwards (powers), sideways (roots) and backwards (logarithms).
Powers
Repeated multiplication
For a whole number , means multiplied by itself times: . The number is the base and the exponent (or power, or index). is " squared" (the area of a square of side ), " cubed" (a cube's volume). Powers grow fast: , is just over a million, is 18,446,744,073,709,551,616.
The exponent laws
Counting factors gives every rule:
So , , . What the laws don't say matters as much: has no simpler form (, not ), and is , not .
Zero and negative exponents
What should and mean? As with chapter 9's sign rules, ask what the laws force. If is to hold when , then (for ). And if it's to hold when , then . So , , and the pattern halves at every step down, across zero, without a break. A negative exponent means "divide", not "negative": is positive.
is the one awkward case: the pattern says 1, while says 0. Most mathematics and most programming languages define (Python's 0 ** 0 is 1), because that's what makes formulas for counting and for polynomials work; in calculus it's treated as undefined when it arises as a limit.
−2² and the order of operations
In , the power is done before the opposite: . To square , write . This is a convention, chosen so that means "the opposite of " in algebra, and it's the one Python, most programming languages and mathematics use. Not every tool agrees: in many spreadsheets, =-2^2 gives 4, because the minus sign is applied first. When it matters, use brackets.
A negative base raised to a whole power has the sign rule of chapter 9: an even number of negative factors gives a positive result, an odd number a negative one: , .
Powers of 10 and of 2
Place value (chapter 2) is built on powers of ten: , and decimals continue with negative powers, . The metric prefixes are named powers of ten: kilo , mega , giga , milli , micro , nano . Computers count in powers of two, and is close to , which caused a lasting ambiguity: a "kilobyte" has meant both 1,000 and 1,024 bytes. Since 1998 the standard names are kB () and KiB, "kibibyte" (); a disk sold as 1 TB holds about 0.91 TiB, a difference of 9 % that is pure notation.
Squares, cubes and scaling
Chapter 8 noted that a map at scale shrinks areas by . Powers explain why: if every length is multiplied by , an area (a length times a length) is multiplied by , and a volume by . Double the side of a square and it needs four times the paint; double a cube's side and it holds eight times as much. A pizza of 30 cm diameter has times the area of a 20 cm one, so at less than 2.25 times the price it's the better buy. This square–cube law is why an animal scaled up to twice the length needs much thicker legs: its weight grows with its volume (), the strength of its bones with their cross-section ().
Roots
Undoing a power
The square root is the non-negative number whose square is : , . Both 7 and square to 49 (chapter 9), so "the" square root is defined as the non-negative one; the equation has two solutions, . Negative numbers have no square root among the numbers of this book (squares are never negative); numbers that do (the complex numbers) lie beyond this book. Similarly the cube root is the number whose cube is : , and , since cubes keep the sign.
Roots of products split: for non-negative , so . Roots of sums don't: , not .
Fractional exponents
What should mean? The law forces it: , so is a number whose square is 9: . In general and : , . (For negative bases this breaks down: could be , but would then have to equal , which doesn't exist here. Most software returns a complex number or an error, as the lab shows.)
Finding a square root by averaging
Most square roots aren't fractions: isn't, as chapter 12 proves. So how is computed? A method known in Babylon and written down by Heron of Alexandria (first century CE): if is a guess for , then and lie on opposite sides of (their product is ), so their average is a better guess. From for : , then , then The number of correct digits roughly doubles at every step, which the lab measures. It's the same method calculators and computer libraries use, as Newton's method (beyond this book).
Scientific notation
Writing the very large and the very small
Scientific notation writes a number as with : the speed of light is about m/s, a year about seconds, the mass of an electron kg. The exponent says where the decimal point goes (the size); the mantissa carries the digits. Calculators and programs write as 9.11e-31.
To multiply, multiply the mantissas and add the exponents, then tidy: metres in a light-year. To divide, divide and subtract: . To add, first match the exponents: . Floating-point numbers (chapter 7) are scientific notation in base 2: a mantissa with 53 binary digits and an exponent, which is why a float can hold and but only about 16 significant decimal digits of either.
Orders of magnitude
The exponent alone, the order of magnitude, is often all an estimate needs (chapter 11). India's population is about ; a city of is a hundredth of it, two orders of magnitude smaller. Comparing exponents is how scientists check that a calculation is in the right range before trusting its digits.
Growth, in closed form
Chapter 7 found that a 6 % rise every year for 5 years multiplies by . In general, an amount growing by a rate each period becomes, after periods,
This is compound growth, in closed form: one formula instead of steps. ₹1,00,000 at 8 % a year is multiplied by , becoming about ₹2,15,892 in 10 years, and about ₹10 lakh in 30. A fall works the same way with a negative rate: a price that loses 15 % a year keeps of its value. And the question "how long until it doubles?" asks for the with , an exponent we don't know: that's what logarithms are for.
Logarithms
The exponent you need
The logarithm to base of is the power you must raise to, to get :
So , , , . It's defined for positive and positive bases other than 1. Logarithms grow very slowly: of a billion is only 9, and of a billion about 30. Common bases have short names: (often written ), (in computing), and , the natural logarithm, to base , the base that makes the formulas of calculus simplest (beyond this book).
The logarithm laws
Every exponent law has a logarithm law, because logarithms are exponents.
The first law is the one that changed history: to multiply two long numbers, look up their logarithms, add, and look up the number with that logarithm. Navigators and astronomers did this for three and a half centuries, and the slide rule does it mechanically, by adding lengths on two logarithmic scales.
Logarithms count digits
Chapter 2 showed that the numbers with digits are those from up to . Taking , a number has digits exactly when , so:
(, the floor, is the largest whole number not above .) has digits, found without computing it. The base- version is the formula chapter 2's plot drew: a bigger base needs fewer digits, in proportion to . In code, though, floor(log10(n)) + 1 is computed in floating point, and the lab shows it giving the wrong answer for numbers as small as .
Solving for an exponent
Now "how long until it doubles?" has an answer. means . At 8 %: years. Because is close to for small rates, : the old rule of 72 (Luca Pacioli mentions it in 1494), which the lab tests. The same method finds how many halvings binary search needs (), how many years until a price falls by half, or how many bits are needed to count to .
Logarithmic scales
Quantities that range over many powers of ten are measured on logarithmic scales, where each step multiplies. Sound level in decibels is of a power ratio, so +10 dB is ten times the sound power and +3 dB about double. Acidity's pH is of the hydrogen ion concentration, so pH 3 is ten times as acidic as pH 4. Each step of earthquake magnitude is about 32 times the energy. Charts of growth (prices over decades, epidemics, computer speeds) use a logarithmic axis so that steady percentage growth appears as a straight line.
Lab: powers and logarithms in code
Experiment 1: exact powers, and digits by logarithm
import math
print(2 ** 10, 2 ** 64, len(str(2 ** 1000)), "digits in 2^1000")
print(2 ** -3, 10 ** 0, (-2) ** 2, -2 ** 2, (-8) ** (1 / 3))
# Counting digits with logarithms, and where floating point breaks the formula
for n in (999, 1000, 10**15 - 1, 10**15, 10**16 - 1, 10**23):
by_log = math.floor(math.log10(n)) + 1
print(f"{n:>24} len(str) {len(str(n)):>2} floor(log10)+1 {by_log:>2} {'ok' if by_log == len(str(n)) else 'WRONG'}")
1024 18446744073709551616 302 digits in 2^1000
0.125 1 4 -4 (1.0000000000000002+1.7320508075688772j)
999 len(str) 3 floor(log10)+1 3 ok
1000 len(str) 4 floor(log10)+1 4 ok
999999999999999 len(str) 15 floor(log10)+1 16 WRONG
1000000000000000 len(str) 16 floor(log10)+1 16 ok
9999999999999999 len(str) 16 floor(log10)+1 17 WRONG
100000000000000000000000 len(str) 24 floor(log10)+1 24 ok
Python's integers are exact at any size: in full, and with its 302 digits, as the theorem predicted. 2 ** -3 is 0.125, 10 ** 0 is 1, and the order of operations shows: (-2) ** 2 is 4, -2 ** 2 is . (-8) ** (1/3) doesn't give : isn't exactly representable, and Python returns a complex cube root rather than guessing. The digit-counting formula floor(log10(n)) + 1 is right for small numbers and wrong for and : the float log10 of 999,999,999,999,999 rounds to exactly 15.0. For exact integers, count digits with len(str(n)), or with integer comparisons against powers of ten.
Experiment 2: square roots by averaging
from fractions import Fraction as F
from decimal import Decimal, getcontext
getcontext().prec = 50
true = Decimal(2).sqrt() # 50 digits, for checking
g = F(1)
for step in range(1, 7):
g = (g + 2 / g) / 2 # average the guess and 2 / guess
err = abs(Decimal(g.numerator) / Decimal(g.denominator) - true)
shown = str(g) if len(str(g)) < 28 else f"({len(str(g.numerator))}-digit fraction)"
print(f"step {step}: {shown:>27} error below 10^{err.adjusted() + 1}")
step 1: 3/2 error below 10^-1
step 2: 17/12 error below 10^-2
step 3: 577/408 error below 10^-5
step 4: 665857/470832 error below 10^-11
step 5: 886731088897/627013566048 error below 10^-24
step 6: (25-digit fraction) error below 10^-48
Heron's averaging, done with exact fractions, gives , , , … The error falls from about to , , , and : each step roughly squares the error, doubling the number of correct digits. That's quadratic convergence, and it's why six steps from a crude guess of 1 reach 48 decimal places. The fractions themselves grow fast (25 digits by step 6), chapter 6's price of exactness again.
Experiment 3: doubling times and the rule of 72
import math
for rate in (2, 4, 6, 8, 12, 18, 24):
exact = math.log(2) / math.log(1 + rate / 100) # years to double: (1 + r)^n = 2
print(f"{rate:>2}% a year: doubles in {exact:5.2f} years; rule of 72 says {72 / rate:5.2f}")
print("₹1,00,000 at 8% for 10, 20, 30 years:", [round(100_000 * 1.08 ** n) for n in (10, 20, 30)])
2% a year: doubles in 35.00 years; rule of 72 says 36.00
4% a year: doubles in 17.67 years; rule of 72 says 18.00
6% a year: doubles in 11.90 years; rule of 72 says 12.00
8% a year: doubles in 9.01 years; rule of 72 says 9.00
12% a year: doubles in 6.12 years; rule of 72 says 6.00
18% a year: doubles in 4.19 years; rule of 72 says 4.00
24% a year: doubles in 3.22 years; rule of 72 says 3.00
₹1,00,000 at 8% for 10, 20, 30 years: [215892, 466096, 1006266]
The exact doubling time is . The rule of 72 is within a few months for rates from about 4 % to 12 %, and drifts at the ends: too long for small rates, too short for large ones (because 72 is a bit larger than , a deliberate choice that compensates for being smaller than near 8 %). ₹1 lakh at 8 % roughly doubles each 9 years: ₹2.16 lakh at 10 years, ₹4.66 lakh at 20, ₹10.06 lakh at 30.
Experiment 4: multiplying by adding, and counting halvings
import math
# Multiplying by adding logarithms, as a slide rule does
a, b = 37.5, 2.48
print("log10:", round(math.log10(a), 5), "+", round(math.log10(b), 5), "=", round(math.log10(a) + math.log10(b), 5),
"-> 10^that =", round(10 ** (math.log10(a) + math.log10(b)), 6), "| a * b =", a * b)
# How many halvings to find one item among n: binary search needs about log2(n) steps
for n in (1_000, 1_000_000, 1_000_000_000, 8_000_000_000):
print(f"{n:>13,} items: {math.ceil(math.log2(n))} halvings")
log10: 1.57403 + 0.39445 = 1.96848 -> 10^that = 93.0 | a * b = 93.0
1,000 items: 10 halvings
1,000,000 items: 20 halvings
1,000,000,000 items: 30 halvings
8,000,000,000 items: 33 halvings
Adding the logarithms of 37.5 and 2.48 and raising 10 to the sum gives their product, 93: a slide rule in five lines. The second part counts how many times a list can be halved before one item is left, : 10 halvings for a thousand items, 30 for a billion, 33 for eight billion. That's why binary search, and any "divide in half" strategy, stays fast however large the data grows.
Worked examples
Using the exponent laws
Scientific notation
Logarithms and growth
Exercises
Practice
- Evaluate: (a) ; (b) ; (c) and ; (d) ; (e) .
- Simplify: (a) ; (b) ; (c) in scientific notation.
- Write in scientific notation: (a) 7,350,000; (b) 0.000 006 02; (c) .
- Calculate and .
- Find: (a) ; (b) ; (c) ; (d) .
- Use the logarithm laws to write as one logarithm: . Evaluate it.
- A photo on a phone is 4,000 × 3,000 pixels. If both sides are halved, by what factor do the number of pixels and the file size (roughly) fall?
Answers
- (a) 125; (b) ; (c) 81 and ; (d) ; (e) .
- (a) ; (b) ; (c) .
- (a) ; (b) ; (c) .
- ; .
- (a) 5; (b) ; (c) 1; (d) , since .
- .
- Lengths × , so pixels × : from 12 million to 3 million, and the file roughly a quarter of the size.
Harder
- Explain why using the pattern , and why the argument fails for .
- Prove that for non-negative . Then find values showing in general. When are they equal?
- Show that . Use it to find from .
- A bacterium divides every 20 minutes. Starting from one, how many are there after 6 hours? About how long until there are a billion ()?
- A price falls 20 % every year. After how many whole years is it below half its starting value? Below a tenth?
Answers
- Each step down the pattern divides by : , , so the next is . For , the step "divide by " is division by zero, so the pattern gives no value for ; it's defined as 1 by convention where needed.
- , and , so it's the non-negative square root of . For sums: . Squaring gives , so they're equal only when : when or is 0.
- With change of base, and ; their product is 1. , so (indeed ).
- 6 hours is 18 divisions: . A billion is about : 30 divisions, 10 hours.
- : , so after 4 years (, ). : , so after 11 years.
Challenge
- Show that the averaging method for satisfies . Explain why this means the number of correct digits roughly doubles each step once is close, and why every guess after the first is at least .
Discussion
. Subtract : . The new error is the old error squared, divided by (about once is close). If the error is about , the next is about divided by a constant: twice as many correct digits. And since a square is never negative and , : every new guess is at least , approaching from above (the lab's guesses are all just above ).
In real life
Misconceptions and limits
The model to keep
Common misconceptions
| Misconception | What's actually true | Where it's shown |
|---|---|---|
| "" or "". | Same base: exponents add when multiplying: . Sums of powers don't combine. | The exponent laws |
| " is negative." | It's : a negative exponent means divide. | Zero and negative exponents |
| "." | for , forced by . | Zero and negative exponents |
| "." | ; . Some spreadsheets disagree. | −2² and the order of operations |
| " ." | Roots split over products, not sums: . | Undoing a power |
| "Doubling the size doubles the area." | Area scales by : four times. Volume by : eight times. | Squares, cubes and scaling |
| " ." | It's ; logarithms of sums don't split. | The logarithm laws |
"floor(log10(n)) + 1 always counts digits." |
In floating point it fails, from up. | Experiment 1 |
Limits and trade-offs
- Real exponents need real numbers. and aren't fractions; defining them properly needs the real numbers of chapter 12 and limits (beyond this book).
- Negative bases and fractional exponents don't mix. is by one reading and undefined (or complex) by another; software usually refuses or returns a complex number.
- Logarithms in code are approximate. Every formula built on a floating-point logarithm (digit counts, bit lengths, doubling times) can be off by one at the boundaries; use exact integer methods when an exact answer is needed (
len(str(n)),n.bit_length(),math.isqrt). - Exponential growth doesn't last. describes steady percentage growth; real populations, epidemics and markets slow down as they meet limits, and extrapolating a power far ahead is a common forecasting error.
Revision sheet
Key ideas
- ( factors). Laws: , , , .
- Forced by the laws: , , , .
- , ; even powers of negatives are positive, odd negative.
- Scaling: lengths × → areas × , volumes × .
- Roots: is the non-negative root; ; . Heron: average and ; digits double each step.
- Scientific notation , : multiply mantissas, add exponents; match exponents to add.
- Compound growth: ; doubling time .
- Logarithm: . Laws: products → sums, quotients → differences, powers → multiples; change of base .
- Digits: (base : ); halvings to one item: .
Glossary
- Power (exponentiation): repeated multiplication, .
- Base: the number being raised to a power, in ; also the base of a logarithm.
- Exponent (index): the number of factors, in ; extended to zero, negative and fractional values.
- Square root: the non-negative number whose square is a given number.
- Cube root / nth root: the number whose cube (th power) is a given number.
- Scientific notation: writing a number as with .
- Mantissa: the digits part of a number in scientific notation.
- Order of magnitude: the power of ten of a number's size.
- Compound growth: growth by the same percentage each period, .
- Logarithm: the exponent to which a base must be raised to give a number, .
- Natural logarithm: the logarithm to base , written .
- Logarithmic scale: a scale on which equal steps are equal multiplications.
- Doubling time: how long a steadily growing quantity takes to double, .
- Square–cube law: when lengths scale by , areas scale by and volumes by .