RecapsKayavak

Kayavak / Recaps / Arithmetic and Numbers

Recaps · Book 1

Arithmetic and Numbers

The revision sheet of every chapter, on one page: the key ideas, the numbers worth knowing, the pitfalls and the words. Use it before an interview, after a chapter, or to find which chapter to reread. Each title opens its chapter; below each sheet are its exercises, companion and TiffinBox stage, and the misconceptions the companion corrects.

Open the volume

01

Start Here: What Numbers Are

Key ideas

  • One-to-one correspondence (pairing) defines "same size"; counting is pairing with the counting words.
  • A number is a quantity; a numeral is a name for it. Numbers do cardinal, ordinal and nominal jobs; arithmetic applies to quantities.
  • Natural numbers 0, 1, 2, … never end: every number has a successor.
  • Addition combines; subtraction takes away, compares, or finds a missing part, and is the inverse of addition.
  • Multiplication is repeated addition, a rectangle, or scaling; division is sharing or grouping, and is the inverse of multiplication.
  • Commutative, associative, distributive and the identities follow from the stories; subtraction and division are neither commutative nor associative.
  • Division by zero is undefined; 0÷0 is undefined too.
  • Order of operations is a convention: brackets, powers, then × and ÷ left to right, then + and − left to right; power towers read top down.

Glossary

  • One-to-one correspondence: a pairing of two collections in which every item on each side has exactly one partner on the other.
  • Numeral: a symbol or string of symbols that names a number, such as 7, VII or सात.
  • Cardinal number: a number used to say how many.
  • Ordinal number: a number used to say which position in an order (first, second, third).
  • Nominal number: a numeral used only as a label, like a phone number or pincode, on which arithmetic is meaningless.
  • Natural numbers: 0, 1, 2, 3, …, each the successor of the one before (some books start at 1).
  • Successor: the next natural number, obtained by adding one.
  • Partitive division: division as sharing, where the number of groups is known and the size of each is wanted.
  • Quotitive division: division as grouping (or measuring), where the size of each group is known and the number of groups is wanted.
  • Commutative property: an operation is commutative when swapping its inputs doesn't change the result, as with a+b=b+a.
  • Associative property: an operation is associative when the grouping of a chain doesn't change the result, as with (a+b)+c=a+(b+c).
  • Distributive property: multiplication distributes over addition: a×(b+c) =a×b+a×c.
  • Identity element: a number that leaves others unchanged under an operation: 0 for addition, 1 for multiplication.
  • Inverse operation: an operation that undoes another: subtraction undoes addition, division undoes multiplication.
  • Order of operations: the agreed convention for evaluating an expression without brackets: brackets, powers, multiplication and division left to right, addition and subtraction left to right.

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"00 is undefined, like 0÷0." It's a matter of convention: algebra and every mainstream language take 00=1; analysis leaves it undefined.
"There's only one zero in a computer." IEEE 754 floats have +0 and −0; they compare equal, but 1 / -0 is -Infinity.
"Brackets in code are only for when you need them." Unneeded brackets are often worth keeping for readers; ast.unparse removes them, which shows exactly which ones the grammar needs.
"An ID made of digits is a number." It's a label; stored as a number it loses leading zeros and, in JavaScript, digits beyond 253.
"The average of daily averages is the average." Only when every day has the same count; otherwise compute from totals.

02

Place Value and Bases

Key ideas

  • Place value: each position is worth the base times the position to its right; a digit's value is digit × bposition.
  • Zero holds an empty place; without it positions slide and numerals become ambiguous.
  • Digits are smaller than the base: base b uses 0 to b−1; hex uses A–F for 10–15.
  • Counting is an odometer: a digit rolls over to 0 and carries one to the left.
  • k-digit numbers in base b run from bk−1 to bk−1; there are (b−1)bk−1 of them; n has ⌊logbn⌋+1 digits.
  • To decimal: expand, or read left to right with "× base, + digit" (Horner).
  • From decimal: repeated division; remainders are the digits, last first.
  • Binary ↔ octal/hex: group bits in threes or fours from the right.
  • Every number has exactly one numeral in base b (no leading zeros).
  • Grouping (millions or lakhs and crores) and separators are conventions, not part of the number.

Glossary

  • Place value: the value a digit contributes because of its position: the digit times the position's power of the base.
  • Face value: the value of a digit on its own, regardless of position.
  • Base (radix): the number of distinct digits in a positional system, and the factor between neighbouring positions.
  • Positional notation: a way of writing numbers in which a symbol's value depends on its position.
  • Expanded form: a number written as the sum of each digit times its place value.
  • Placeholder: a symbol, our zero, that marks an empty position so the other digits keep their places.
  • Carry: moving one unit to the next position left when a position reaches the base.
  • Binary: base two, with digits 0 and 1.
  • Bit: a binary digit; the smallest unit of information a computer stores.
  • Byte: eight bits, able to hold 256 different values.
  • Octal: base eight; each octal digit corresponds to exactly three bits.
  • Hexadecimal: base sixteen, with digits 0–9 and A–F; each hex digit corresponds to exactly four bits.
  • Sexagesimal: base sixty, used by the Babylonians and still in time and angle measurement.
  • Horner's method: evaluating a numeral (or polynomial) left to right by repeatedly multiplying by the base and adding the next digit.
  • Lakh and crore: Indian names for 105 (1,00,000) and 107 (1,00,00,000).

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"A leading zero never changes a number's value." In C, older JavaScript and the C library's inet_aton, a leading 0 means octal: 010 is 8.
"An IP address is four separate numbers." It's one 32-bit number written as four base-256 digits; 192.168.1.10 is 3,232,235,786.
"Negative binary numbers are a minus sign and the bits." Machines store a fixed-width two's complement pattern; 11111011 is −5 or 251 depending on how it's read.
"Sorting numbers stored as text works." Text sorts character by character: "10" comes before "9".
"parseFloat reads a number with commas." It stops at the first comma: parseFloat("1,000") is 1.

03

Adding and Subtracting, and Why the Methods Work

Key ideas

  • Column addition adds place by place (distributivity and regrouping), then carries: a column total of ten or more becomes one of the next place up.
  • Adding two numbers, carries are 0 or 1; adding n numbers, at most n−1.
  • In any base, carry when a column reaches the base; in binary 1+1=102.
  • Strategies: make ten, near doubles, number bonds, compensation (round, then correct in the right direction).
  • Decomposition: unbundle one from the next place when a column is short; the number doesn't change.
  • Equal addition: add ten to the top column and one to the next bottom column; uses same difference, (a+k)−(b+k)=a−b.
  • Counting up: the missing-part story; best when numbers are close or near round ones.
  • From a power of ten: each digit from 9, the last from 10; computers' complements use the same idea.
  • Check by the inverse, by estimating, by casting out nines (which misses swapped digits).
  • Floating-point addition rounds each step, so order matters.

Glossary

  • Addend: a number being added.
  • Sum: the result of an addition.
  • Minuend and subtrahend: in a−b, the number subtracted from (a) and the number subtracted (b).
  • Difference: the result of a subtraction.
  • Carry: in column addition, the part of a column total that moves to the next place to the left.
  • Decomposition: the subtraction method that regroups the top number, unbundling one of a higher place into ten of the place below ("borrowing").
  • Equal addition: the subtraction method that adds ten to a column of the top number and one to the next column of the bottom number.
  • Compensation: adjusting a number to a convenient one for calculating, then correcting the result.
  • Number bond: a pair of numbers with a convenient sum, such as 3 and 7 for ten.
  • Nines' complement: the number obtained by subtracting each digit from 9; 9999−n for a four-digit n.
  • Casting out nines: checking a calculation by comparing the remainders of its numbers on division by 9, found from digit sums.
  • Full adder: a circuit that adds two bits and an incoming carry, giving a sum bit and an outgoing carry.
  • Overflow: a result too large for the fixed number of digits or bits that store it.

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"An exact sum of floats gives the exact total." It gives the exact total of the stored approximations: ten float 0.1s sum to slightly more than 1.
"x | 0 just removes the fraction in JavaScript." It converts to a 32-bit integer and wraps: 4000000000 | 0 is −294,967,296.
"The number of days from the 3rd to the 10th is 7." 7 is the difference; counting both ends gives 8 days; a hotel charges 7 nights. Say which you mean.
"Comparing money totals with == works if you round first." Rounding hides it in one case and fails at the next boundary; store paise and compare integers.
"Borrowing just adds ten to the column." It moves ten from the next place; forgetting to take it away from there inflates the answer.

04

Multiplying and Dividing

Key ideas

  • Times tables shrink to a short list via commutativity, identities, doubling, ×5 = half of ×10, ×9 = ×10 − ×1.
  • Long multiplication = distributivity over place value: one row per digit, shifted by its place, then column addition. Works in any base; binary is shift-and-add.
  • Multiplying by one digit, carries are at most 8.
  • An m-digit × n-digit product has m+n−1 or m+n digits.
  • Mental strategies: double and halve, ×5, ×9, ×11, (a−1)(a+1)=a2−1.
  • Division algorithm: a=qb+r, 0≤r<b, exactly one solution.
  • Short and long division share the biggest place first and bring down (unbundle the leftover into the next place).
  • Each quotient digit is an estimate: remainder ≥ divisor means the digit was too small.
  • Never skip a 0 in the quotient.
  • Check a division by q×b+r=a and r<b; a product by length, estimate, casting out nines.
  • Languages disagree on negative remainders.

Glossary

  • Product: the result of a multiplication; the numbers multiplied are its factors.
  • Partial product: one row of a long multiplication, the product of the first number with one digit of the second, shifted to its place.
  • Long multiplication: the column method that adds shifted partial products.
  • Box (grid) method: multiplication by splitting both numbers by place value and writing every pairwise product in a grid.
  • Lattice method: multiplication in a grid of cells split by diagonals, adding along the diagonals.
  • Dividend and divisor: in a÷b, the number divided (a) and the number divided by (b).
  • Quotient: the whole number of times the divisor fits into the dividend.
  • Remainder: what is left after taking away the quotient's worth of divisors; always less than the divisor.
  • Division algorithm: the theorem that a=qb+r with 0≤r<b has exactly one solution in whole numbers for b≥1.
  • Short division: division by a one-digit number with the intermediate steps done mentally.
  • Long division: division written out step by step, bringing down one digit at a time.
  • Karatsuba multiplication: a method that multiplies n-digit numbers using three half-size products instead of four, taking about n1.585 steps.

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"Printing a number is free." Converting to decimal is repeated division; naive conversion of huge numbers is slow enough that Python limits it to 4,300 digits by default.
"math.ceil(n / k) rounds up correctly." Only while n / k is exact in floating point; use (n + k - 1) // k for integers.
"Rounding each share to the paisa keeps the total." It can lose or invent paise; give the remainder to some shares explicitly.
"Multiplying by 1,000,000 just adds zeros, even in JavaScript." Above 253, floats are spaced apart: nanosecond timestamps lose their last digits.
"10k has to be computed by multiplying tens." 10k=5k×2k, and multiplying by 2k is a shift: Python builds powers of ten that way.

05

Factors, Multiples and Primes

Key ideas

  • b∣a means a=bc; remainder 0. Factors come in pairs; search up to a. Odd number of factors ⇔ perfect square.
  • If d divides a and b, it divides a±b and any multiple of a.
  • Tests: last digit (2, 5, 10), last two (4, 25), last three (8); digit sum (3, 9); alternating sum (11). In base b: b−1 and b+1.
  • Remainders add and multiply like the numbers: a≡b(modm). Casting out nines works because a number and its digit sum are congruent mod 9, and misses multiples of 9.
  • A prime has exactly two factors; 1 is not prime. Sieve up to n; test by primes up to n.
  • Infinitely many primes (Euclid); about x/lnx of them up to x.
  • Fundamental theorem: one factorisation into primes. A prime dividing a product divides a factor.
  • From n=∏pa: number of factors =∏(a+1); square ⇔ all exponents even.
  • gcd: smaller exponents; lcm: larger; gcd×lcm =ab. Coprime: gcd 1.
  • Euclid's algorithm: gcd(a,b) =gcd(b,amodb).

Glossary

  • Factor (divisor): a whole number that divides another with remainder 0.
  • Multiple: the result of multiplying a number by a whole number.
  • Divides (b∣a): a is a multiple of b.
  • Prime number: a whole number greater than 1 whose only factors are 1 and itself.
  • Composite number: a whole number greater than 1 that is not prime.
  • Prime factorisation: a number written as a product of primes, unique apart from order.
  • Sieve of Eratosthenes: a method of listing primes by crossing out the multiples of each prime in turn.
  • Greatest common divisor (gcd): the largest number dividing each of two (or more) numbers.
  • Least common multiple (lcm): the smallest positive number that is a multiple of each of two (or more) numbers.
  • Coprime: having greatest common divisor 1.
  • Euclid's algorithm: finding the gcd by replacing the pair (a,b) with (b,amodb) until the remainder is 0.
  • Congruent modulo m: leaving the same remainder on division by m, written a≡b(modm).
  • Modular arithmetic: arithmetic with remainders, in which numbers wrap around after m, like the hours on a clock.
  • Prime number theorem: the number of primes up to x is approximately x/lnx, in the sense that the ratio tends to 1.

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"The gcd of 0 and 0 is undefined, so code can ignore it." By convention it's 0, and dividing by it fails; handle zero explicitly.
"range(2, int(sqrt(n))) tries every divisor up to the square root." It stops one short: 4, 9, 25 and 143 are reported prime.
"int(math.sqrt(n)) is the integer square root." Only while n is small enough for floats; use math.isqrt.
"a ** b % m is fine for modular powers." The power can be huge or rounded; reduce as you go with pow(a, b, m).
"Euclid's algorithm is only for gcds." Its quotients are the continued fraction of a/b, which finds the best simple fractions near any number (22/7, 355/113 for π).

06

Fractions

Key ideas

  • ab = a÷b: the number that times b gives a. Part, division, point, scale factor.
  • Mixed ↔ improper is the division algorithm: 114 =234.
  • Equivalent: ab =kakb; ab =cd⟺ad =bc. Lowest terms: divide by the gcd; unique.
  • Compare by common denominator or cross-multiplying; benchmarks 12 and 1.
  • Add/subtract: common denominator (lcm best): ab+cd =ad+bcbd. Never add the bottoms.
  • Mediant a+cb+d combines records; lies between the two.
  • Multiply: tops × tops, bottoms × bottoms (area). "Of" means ×. Cancel common factors first.
  • Divide: multiply by the reciprocal. Dividing by a fraction below 1 enlarges.
  • Fractions are dense: always another between two.

Glossary

  • Fraction: a number ab (b≠0), the number that multiplied by b gives a.
  • Numerator: the top number of a fraction; how many pieces.
  • Denominator: the bottom number; what size of piece (into how many equal parts the whole is split).
  • Unit fraction: a fraction with numerator 1.
  • Proper fraction: numerator less than denominator; less than 1.
  • Improper fraction: numerator at least the denominator; 1 or more.
  • Mixed number: a whole number and a proper fraction written together, such as 234.
  • Equivalent fractions: fractions that name the same number, like 34 and 68.
  • Lowest terms: a fraction whose numerator and denominator are coprime.
  • Common denominator: a denominator shared by two or more fractions after rewriting; the lcm of their denominators is the least.
  • Reciprocal: the number that multiplies a given non-zero number to give 1; for cd it is dc.
  • Mediant: a+cb+d for fractions ab and cd; it lies between them.
  • Egyptian fraction: a sum of different unit fractions.

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"Fraction(0.1) is one tenth." It's the float's exact value, a fraction with denominator 255; use Fraction("0.1").
"Converting to decimals is a safe way to compare fractions." Floats can't separate fractions closer than about 10−16 relative; cross-multiply instead.
"Cross-multiplying always compares fractions correctly." Only when both denominators are positive; normalise the sign first.
"divmod turns any fraction into a mixed number." For negative fractions it gives a floored whole part; format the sign separately.
"Fractions with integer parts are exact in every language." Only with arbitrary-size integers; JavaScript numbers lose exactness past 253.
"The average of the daily rates is the overall rate." Records combine as the mediant: total successes over total tries.

07

Decimals and Percentages

Key ideas

  • Decimal places: tenths, hundredths, thousandths; each a tenth of the place to its left. 25.307=253071000.
  • × 10 shifts every digit one place left (the point appears to move right); ÷ 10 shifts right.
  • Trailing zeros after the point don't change the value; zeros between digits hold places.
  • Compare by lining up points; longer isn't bigger.
  • Add/subtract: line up the points. Multiply: ignore points, then count decimal places. Divide: scale both numbers to make the divisor whole.
  • Terminates ⇔ lowest-terms denominator has only primes 2 and 5 (in base b: only primes of b). 0.1 never ends in binary.
  • Otherwise it repeats, with period at most b−1 (remainders repeat).
  • Repeating → fraction: multiply by 10k, subtract. 0.27― =311; 0.9―=1.
  • Percent = per hundred; part = percent × whole; reverse by dividing.
  • Percentage change is of the starting value; changes multiply (compounding); percentage points ≠ percent.

Glossary

  • Decimal point: the mark separating the ones place from the tenths place (a comma in many countries).
  • Decimal place: a position to the right of the point; "to 2 decimal places" means to the hundredths.
  • Terminating decimal: a decimal with finitely many non-zero digits after the point.
  • Repeating (recurring) decimal: a decimal in which a block of digits repeats forever, such as 0.142857―.
  • Period: the length of the repeating block.
  • Percent (%): hundredths; p% means p100.
  • Percentage change: the change as a percentage of the starting value.
  • Reverse percentage: finding the original amount from an amount after a percentage change, by dividing by the multiplier.
  • Percentage point: the unit for the difference between two percentages.
  • Multiplier: the number a percentage change multiplies by, such as 1.18 for an 18 % increase or 0.8 for a 20 % decrease.
  • Compounding: applying a percentage change repeatedly, each time to the new amount.
  • Banker's rounding: rounding exact halves to the nearest even digit (2.5 → 2, 3.5 → 4).

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"Short decimals like 0.1 or 0.35 are exact in a computer." Only fractions with power-of-two denominators are; of 0.01 to 0.99, only 0.25, 0.50 and 0.75.
"Rounding 2.5 gives 3 everywhere." Python gives 2 (ties to even); JavaScript's Math.round(-2.5) gives −2; name the rule you want.
"The average yearly change is the average of the yearly percentages." Changes multiply; use the geometric mean.
"int(price * 100) converts rupees to paise." It truncates a float that's often just below the true value: 19.99 becomes 1998.
"parseFloat reads any number a person wrote." It stops at the first character it doesn't expect: "1,234.50" becomes 1.
"GST is 18 % of the bill." For a bill that includes GST, it's 18118 of it.
"Rounded percentages add up to 100." Rounding each can give 99.99 or 101; allocate the rounding.

08

Ratio, Proportion and Rates

Key ideas

  • Ratio a:b: "for every a, b"; part to part. Part to whole: aa+b.
  • Equivalent ratios: multiply or divide all parts by the same number; simplest form: divide by the gcd.
  • Sharing in a ratio: total parts → one part → multiply. Check the shares add up.
  • Proportion: ab =cd⟺ad =bc; rule of three; unit method via the unit rate.
  • Scale 1 : n: lengths × n; areas × n2.
  • Direct: y=kx, constant ratio, straight line through the origin. Inverse: xy=k, constant product.
  • Rate: a ratio of different kinds (₹/kg, km/h); units divide and multiply like numbers.
  • Unit price: the same unit for every option; or cross-multiply.
  • Average speed = total distance ÷ total time; equal distances → harmonic mean.
  • Combine rates by totals (the mediant), not by averaging; Simpson's paradox: group comparisons can reverse when combined.

Glossary

  • Ratio: a comparison of quantities by how many times, written a:b ("for every a, b").
  • Simplest form: a ratio whose parts are whole numbers with no common factor above 1.
  • Proportion: a statement that two ratios are equal.
  • Rule of three: finding the fourth number of a proportion from the other three (multiply the diagonal pair, divide by the third).
  • Unit rate: the amount of one quantity for one unit of another (₹65 per kg).
  • Scale factor: the number every length is multiplied by in a scaled copy.
  • Direct proportion: two quantities whose ratio is constant, y=kx.
  • Inverse proportion: two quantities whose product is constant, xy=k.
  • Constant of proportionality: the fixed k in direct or inverse proportion.
  • Rate: a ratio between quantities of different kinds, such as km per hour.
  • Unit price: price per unit of quantity, used to compare pack sizes.
  • Harmonic mean: the average of rates over equal amounts, n1r1+⋯+1rn.
  • Simpson's paradox: a comparison that holds in every group but reverses when the groups are combined.

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"A table with equal ratios will pass len(set(y / x)) == 1." Float rounding can split equal ratios; use exact fractions or a tolerance.
"Resizing keeps the aspect ratio." Rounding to whole pixels makes it drift, except at exact multiples.
"Any summary of a rate can be combined across groups." Totals combine; percentiles and medians don't.
"Compute the scale factor first, in integers." new_w // w is 0 when shrinking; multiply first, then divide.
"The rule of three always multiplies by the new amount." For inverse proportion it divides: more workers, fewer days.
"Converting decimals to integers with int(x * 100) is safe." Floats just below the value truncate down: 0.29 m becomes 28 cm.
"A rate rounded to two places is good enough." Its error is multiplied by every amount converted, and inverting it rounds again.

09

Negative Numbers

Key ideas

  • Opposite: a+(−a)=0; unique; −(−a)=a. Integers: whole numbers and their opposites.
  • Order: left to right on the line; −10<−2. Absolute value |a|: distance from 0. Distance between a and b: |a−b|.
  • Add: move right for positive, left for negative. Subtract = add the opposite: a−(−b)=a+b.
  • Signs: 0×b=0; (−a)b=−(ab); (−a)(−b)=ab, forced by distributivity. Same for division.
  • Distributivity with subtraction: a(b−c)=ab−ac; (a−b)(a+b)=a2−b2.
  • Inequalities: multiplying or dividing by a negative reverses them.
  • Remainders with negatives: floored (Python), truncated (C, Java, JS), Euclidean (r≥0); all satisfy a=qb+r.
  • Two's complement (n bits): x stored as xmod2n; −x as 2n−x = flip the bits and add 1. Range −2n−1 to 2n−1−1.
  • Overflow wraps; −2n−1 has no opposite in n bits.

Glossary

  • Opposite (additive inverse): the number that adds to a given number to make zero; −a.
  • Integer: a whole number or the opposite of one: …,−2,−1,0,1,2,…
  • Absolute value: a number's distance from zero, |a|.
  • Signed number: a number with a direction (positive or negative) as well as a size.
  • Sign rule: same signs multiply or divide to a positive result, different signs to a negative one.
  • Floored division: division whose quotient is rounded down, so the remainder has the divisor's sign.
  • Truncated division: division whose quotient is rounded towards zero, so the remainder has the dividend's sign.
  • Euclidean division: division whose remainder is never negative.
  • Sign and magnitude: storing a sign bit and the size separately.
  • Ones' complement: storing −x as x with every bit flipped.
  • Two's complement: storing −x in n bits as 2n−x; flip the bits and add 1.
  • Sign extension: widening a two's complement number by copying its sign bit into the new high bits.
  • Integer overflow: a result outside a fixed-width type's range, which wraps around.

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"There's only one zero." Floats have +0.0 and −0.0: equal, but distinguishable.
"Subtracting a bigger number from a smaller gives a negative result." Not in unsigned types: it wraps to a large positive number.
"Mixing signed and unsigned is harmless." It can convert to float (losing precision) or reinterpret −1 as a huge number.
"Every decimal library rounds division the same way as integers." Python's Decimal truncates, so Decimal(-17) % 5 is −2 while -17 % 5 is 3.
"A remainder is a valid array index." A truncated remainder can be negative; JavaScript returns undefined for it.
"Math.abs makes a hash code safe to use as a bucket." Math.abs(Integer.MIN_VALUE) is still negative.
"sort() sorts numbers." JavaScript's default sort compares text, so −1 comes before −10 and 10 before 2.
"Integer division of a timestamp by 86,400 gives the day." For times before 1970, truncation gives the next day; floor.

10

Powers, Roots, Scientific Notation and Logarithms

Key ideas

  • an =a×⋯×a (n factors). Laws: aman=am+n, am/an=am−n, (am)n=amn, (ab)n=anbn.
  • Forced by the laws: a0=1, a−n=1/an, a1/n=an, am/n=(an)m.
  • −22=−4, (−2)2=4; even powers of negatives are positive, odd negative.
  • Scaling: lengths × k → areas × k2, volumes × k3.
  • Roots: a is the non-negative root; ab=ab; a+b≠a+b. Heron: average g and a/g; digits double each step.
  • Scientific notation m×10k, 1≤m<10: multiply mantissas, add exponents; match exponents to add.
  • Compound growth: A=P(1+r)n; doubling time ln2ln(1+r)≈72r%.
  • Logarithm: logbx=y⟺by=x. Laws: products → sums, quotients → differences, powers → multiples; change of base logbx =logxlogb.
  • Digits: ⌊log10n⌋+1 (base b: ⌊logbn⌋+1); halvings to one item: ⌈log2n⌉.

Glossary

  • Power (exponentiation): repeated multiplication, an.
  • Base: the number being raised to a power, a in an; also the base of a logarithm.
  • Exponent (index): the number of factors, n in an; 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 (nth power) is a given number.
  • Scientific notation: writing a number as m×10k with 1≤m<10.
  • Mantissa: the digits part m 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, P(1+r)n.
  • Logarithm: the exponent to which a base must be raised to give a number, logbx.
  • Natural logarithm: the logarithm to base e≈2.718, written ln.
  • Logarithmic scale: a scale on which equal steps are equal multiplications.
  • Doubling time: how long a steadily growing quantity takes to double, ln2ln(1+r).
  • Square–cube law: when lengths scale by k, areas scale by k2 and volumes by k3.

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"Floats obey the exponent laws exactly." They round after each step; (1.13)2≠1.16 in the last digit, and 10.0309 overflows.
"(1+r)n is always safe to compute." For tiny r, 1+r rounds to 1; use log1p and exp.
"Adding 1 to a number always changes it." Not above 253 in a double.
"Fractional powers of fractions stay exact." Fraction(4, 9) ** Fraction(1, 2) is a float; roots are usually irrational.
"Variance is the mean of squares minus the square of the mean, so compute it that way." In floats that subtracts two huge, nearly equal numbers and can even go negative.
"^ means power." In Python, JavaScript, C and Java it's bitwise XOR: 2 ^ 10 is 8.
"3 ** 40 in JavaScript is exact." Numbers above 253 are rounded; use BigInt.
"Taking logs of data is always safe." log0=−∞ poisons averages; decide how to handle zeros.

11

Estimation, Rounding, Error and Units

Key ideas

  • Estimate first: one or two significant figures; compatible numbers; low and high bounds. Fermi estimates: multiply rough factors; errors partly cancel.
  • Decimal places (after the point) vs significant figures (from the first non-zero digit). Trailing zeros after the point are information.
  • Halfway rules: half up (away from zero), half even (no bias; Python, IEEE), down/truncate, up, floor, ceiling. Round once, at the end; double rounding can change the answer.
  • Absolute error |m−t| (measured minus true); relative error |m−t|/|t|.
  • Errors combine: sums/differences add absolute errors; products/quotients add relative errors (approximately). Cancellation: close differences lose relative accuracy.
  • Units are factors: convert by multiplying by one (1000 m1 km); km/h ÷ 3.6 = m/s.
  • Areas and volumes: square and cube the length factor: 1 m2 =104 cm2, 1 m3=1000 L.
  • Mixed units: carry 60 (time), 12 (inches), 1000 (grams); safest to convert to the smallest unit, compute, and convert back with ÷ and remainder.
  • Dimensional analysis checks formulas: both sides must have the same units.

Glossary

  • Estimate: a calculation with deliberately rounded inputs, to find the size of an answer quickly.
  • Fermi estimate: an estimate of an unknown quantity built from rough guesses of its factors.
  • Significant figures: the digits of a number from its first non-zero digit, used to express relative precision.
  • Half up (round half away from zero): rounding exact halves away from zero.
  • Half even (banker's rounding): rounding exact halves to the neighbour with an even last digit.
  • Floor / ceiling: rounding down / up to a whole number.
  • Double rounding: rounding in two stages, which can differ from rounding once.
  • Absolute error: the size of the difference between an approximate value and the true value.
  • Relative error: absolute error divided by the size of the true value.
  • Cancellation: loss of relative accuracy when subtracting nearly equal quantities.
  • Unit: a standard amount of a quantity, part of every measurement.
  • Conversion factor: a fraction equal to one that changes units, such as 1000 m / 1 km.
  • Dimensional analysis: checking or deriving formulas by tracking units through them.
  • SI: the International System of Units, built on seven base units.

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"The total of 100 measurements is uncertain by 100 times each one's error." That's the worst case; independent errors typically grow like the square root of the count.
"A month is 30 days." Months have 28 to 31 days; adding months needs a rule for the last day.
"math.ceil(n / k) counts the groups needed." Only while n fits a float exactly; use integer division.
"Negative durations print with a minus sign on every part." timedelta(minutes=-90) is "−1 day, 22:30:00": floored carries.
"A tiny error per step doesn't matter." It accumulates: 0.1 s stored with 10−7 error drifts 0.34 s in 100 hours.
"Multiply by 3.6 to get m/s." Divide; write the factors and check that the units cancel.
"Python's round rounds money like a cash register." It rounds halves to even: 2.5 becomes 2.
"7 % can be stored as 7." A rate must say whether it's a percent or a fraction, or interest is off by 100 times.

12

The Real Number Line

Key ideas

  • Rational: pq with whole p,q, q≠0. Irrational: a real number that isn't rational.
  • 2 is irrational: p2=2q2 forces both p and q even, against lowest terms.
  • n is a whole number or irrational (unique factorisation: exponents must be even).
  • Rational + irrational, and non-zero rational × irrational, are irrational; irrational × irrational can be rational.
  • π (Lambert 1761) and e (Euler 1737) are irrational; both are transcendental (Lindemann 1882, Hermite 1873).
  • Decimals: rational ⇔ ends or repeats; irrational ⇔ neither.
  • Reals = all points of the line = all infinite decimals (with 0.4999… = 0.5). Completeness: nested shrinking intervals close on exactly one real.
  • Between any two reals: a rational and an irrational.
  • N⊂Z⊂Q⊂R: each fills a gap (opposites, reciprocals, limits).
  • Countable: can be listed (whole numbers, integers, fractions). Uncountable: the reals (Cantor's diagonal).
  • Floats: a finite set of fractions m/2k; spacing grows with size; equality needs tolerance.

Glossary

  • Rational number: a number that can be written as a fraction of whole numbers.
  • Irrational number: a real number that can't be written as a fraction of whole numbers, such as 2.
  • Real number: any point of the number line; any infinite decimal.
  • Transcendental number: a number that isn't the solution of any polynomial equation with whole-number coefficients, such as π and e.
  • Algebraic number: a number that is a solution of such an equation, such as 2.
  • Dense: having another member between any two.
  • Completeness: the property of the real numbers that shrinking nested intervals always contain exactly one number; no gaps.
  • Bisection: finding a number by repeatedly halving an interval known to contain it.
  • Pell's equation: p2−nq2=±1, whose solutions give the best fractions near n.
  • Countable: able to be listed, paired one to one with the whole numbers.
  • Uncountable: too many to list, like the real numbers.
  • Cantor's diagonal argument: building a number that differs from the kth listed number in its kth digit, to show no list contains every real.

Practise: Exercises · Companion · Household Numbers stage

Misconceptions (from the companion)

Misconception What's actually true
"If the digits look random, the number is irrational." Rational numbers can delay repetition for thousands of digits; only a proof decides.
"Floats are spread evenly along the line." Half of the positive doubles are below 1; spacing is proportional to size.
"Bisection can reach any tolerance." Not below the gap between neighbouring floats.
"A fraction and a float with the same printed value are equal." Fraction(1, 10) == 0.1 is False: Python compares the float's exact value.
"Bisection returns a root whenever it returns." Without a sign change it returns an endpoint with no root nearby.
"max ignores missing values." A NaN can make the result depend on the order of the list.
"Number.EPSILON is the right tolerance." It's the spacing near 1: too strict for big numbers, too loose for tiny ones.
"Decimal(19.99) is 19.99." It's the float's exact value, 19.9899999…; build decimals from strings.