Skip to content

6.5 Problem set: functions, logarithms, trigonometry, series, polynomials, and inequalities

The sections that follow this one turn the mathematics under a language-model system into code: logarithms that measure information, rotations that encode position, ladders of frequencies, and polynomial evaluation that kernels run, and after them calculus, linear algebra, probability, and optimization. Each of them assumes you can manipulate the expressions fluently by hand: invert a function, combine logarithms, use an angle-addition formula, sum a geometric series, factor a polynomial, and solve an inequality. A bug in a derivation becomes a bug in code that tests catch late and explain poorly, so this set practises the hand skills first.

Concepts from other sections (28)

This section uses these ideas. Each has a short definition and a link to the section that explains it in full. Tap a dotted term in the text to preview it.

The set has sixty problems in six parts. Four of the parts are the pen-and-paper side of the four sections of this chapter, and if a problem in one of them stops you, the section that teaches it is named at the start of the part. The other two parts, on functions and inverses and on inequalities, have no section of their own, because none of that material becomes code; this section teaches it below, before the problems. Derivatives and finite differences and Injective, surjective, bijective build on it directly.

Every problem has a worked answer folded under Answer, with the derivation and the most common wrong answer and why it is wrong. Attempt each problem on paper before opening its answer. The set is self-contained; nothing here needs code.

Learning objectives

  • Find the domain, range, composition, and inverse of a function, and use monotonicity to decide whether an inverse exists.
  • Solve linear, polynomial, rational, absolute-value, exponential, and logarithmic inequalities, keeping track of when the direction flips and which endpoints belong.
  • Manipulate logarithms, convert between nats and bits, and compute bits per byte by hand.
  • Use angle addition, rotations, and Euler’s formula, and sum geometric series including EMA weights and ALiBi slopes.
  • Evaluate polynomials with Horner’s rule, factor them, apply Vieta’s formulas, and recognise when the quadratic formula cancels.

Functions, domains, ranges, and composition

Section titled “Functions, domains, ranges, and composition”

The symbols used in the teaching part are collected here first:

SymbolMeaningType / shape
f:A→Bf: A \to Ba function from the set AA (its domain) to the set BB
f(x)f(x)the output of ff at the input xx
dom⁡f\operatorname{dom} fthe domain: the inputs where ff is defineda set or interval
ran⁡f\operatorname{ran} fthe range: the outputs ff actually takesa set or interval
f∘gf \circ gcomposition, (f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x))
f−1f^{-1}the inverse function: f−1(y)=xf^{-1}(y) = x exactly when f(x)=yf(x) = y
(a,b)(a, b), [a,b][a, b]the open interval a<x<ba < x < b and the closed interval a≤x≤ba \le x \le b
∪\cupunion of sets, written U in answers
σ(z)\sigma(z)the sigmoid 1/(1+e−z)1/(1 + e^{-z})
∣x∣\lvert x\rvertabsolute value: xx if x≥0x \ge 0, −x-x otherwise

A function ff assigns to each input xx in its domain exactly one output f(x)f(x). A formula alone leaves the domain implicit: it is every real xx where the formula makes sense. ln⁡(4−x2)\ln(4 - x^2) needs 4−x2>04 - x^2 > 0, so its domain is (−2,2)(-2, 2); 1/(x−3)1/(x - 3) needs x≠3x \ne 3. The range is the set of outputs that actually occur. The sigmoid σ(z)=1/(1+e−z)\sigma(z) = 1/(1 + e^{-z}) takes every value strictly between 0 and 1 and never reaches either, so its range is (0,1)(0, 1).

Composition chains functions: (f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x)) applies gg first. Order matters. With f(x)=x2f(x) = x^2 and g(x)=x+1g(x) = x + 1, f(g(x))=(x+1)2f(g(x)) = (x + 1)^2 but g(f(x))=x2+1g(f(x)) = x^2 + 1.

A function ff is one-to-one when different inputs give different outputs. Then every output yy in the range comes from exactly one xx, and the inverse f−1(y)=xf^{-1}(y) = x undoes ff: f−1(f(x))=xf^{-1}(f(x)) = x and f(f−1(y))=yf(f^{-1}(y)) = y. To find it, write y=f(x)y = f(x) and solve for xx. The graph of f−1f^{-1} is the graph of ff reflected across the line y=xy = x.

How do you know a function is one-to-one? A function is strictly increasing when x1<x2x_1 < x_2 implies f(x1)<f(x2)f(x_1) < f(x_2), and strictly decreasing when it implies f(x1)>f(x2)f(x_1) > f(x_2). Either kind, called strictly monotonic, is one-to-one, because different inputs are ordered and so are their outputs. exe^x, ln⁡x\ln x, x3+xx^3 + x, σ\sigma, and softplus ln⁡(1+ex)\ln(1 + e^x) are strictly increasing, which is why all of them can be inverted. x2x^2 is not monotonic on all of R\mathbb{R}, since (−2)2=22(-2)^2 = 2^2, so it has an inverse only on a half-line, where  \sqrt{\ } is it. Derivatives and finite differences gives the practical test: a function whose derivative is positive everywhere is strictly increasing.

An inequality is solved the way an equation is, with one extra rule: multiplying or dividing both sides by a negative number reverses the direction (−2x<6-2x < 6 means x>−3x > -3), and so does applying a strictly decreasing function. Applying a strictly increasing function (exe^x, ln⁡\ln,  \sqrt{\ } on non-negative numbers) keeps the direction, which is how ex≤2e^x \le 2 becomes x≤ln⁡2x \le \ln 2.

For a polynomial or a quotient of polynomials, find where it is zero or undefined, cut the line there, and test the sign on each piece. x2−5x+6=(x−2)(x−3)x^2 - 5x + 6 = (x - 2)(x - 3) is zero at 2 and 3, positive outside and negative between, so x2−5x+6>0x^2 - 5x + 6 > 0 on (−∞,2)∪(3,∞)(-\infty, 2) \cup (3, \infty). An endpoint where the expression is zero belongs to the answer for ≥\ge and ≤\le; an endpoint where it is undefined never does. An absolute value is a distance: ∣x−3∣<2|x - 3| < 2 means “within 2 of 3”, the interval (1,5)(1, 5).

Two inequalities appear again in optimization and information theory. The first is x+1/x≥2x + 1/x \ge 2 for x>0x > 0, with equality at x=1x = 1; multiply by xx and get (x−1)2≥0(x - 1)^2 \ge 0. The second is ln⁡x≤x−1\ln x \le x - 1, with equality only at x=1x = 1, the inequality behind Gibbs’ inequality in Entropy, cross-entropy, and KL.

The four middle parts each correspond to one section of this chapter:

PartProblemsTaught in
Exponents, logarithms, units11 to 22Exponents, logarithms, and units of information
Trigonometry, complex numbers, Euler23 to 34Trigonometry, rotations, complex numbers, and Euler’s formula
Sequences and geometric series35 to 44Sequences, geometric series, and frequency ladders
Polynomials45 to 52Polynomials, Horner’s rule, and stable quadratic roots

Before the set itself, here are two worked problems that are siblings of problems in it, showing the level of care the answers expect.

The first is a sibling of problems 5 and 6: find the inverse and range of f(x)=2/(1+e−x)f(x) = 2/(1 + e^{-x}). Start with the range. e−xe^{-x} takes every value in (0,∞)(0, \infty), so 1+e−x1 + e^{-x} takes every value in (1,∞)(1, \infty) and 2/(1+e−x)2/(1 + e^{-x}) every value in (0,2)(0, 2), approaching 2 as x→∞x \to \infty and 0 as x→−∞x \to -\infty without reaching either. The range is (0, 2). Next, check that ff is invertible: as xx grows, e−xe^{-x} shrinks, the denominator shrinks, and f(x)f(x) grows, so ff is strictly increasing and hence one-to-one on R\mathbb{R}. Now solve y=f(x)y = f(x) for xx, for 0<y<20 < y < 2:

y(1+e−x)=2  ⇒  e−x=2y−1=2−yy  ⇒  −x=ln⁡2−yy  ⇒  x=ln⁡y2−y.y(1 + e^{-x}) = 2 \;\Rightarrow\; e^{-x} = \frac{2}{y} - 1 = \frac{2 - y}{y} \;\Rightarrow\; -x = \ln\frac{2 - y}{y} \;\Rightarrow\; x = \ln\frac{y}{2 - y}.

Check it: f(0)=2/(1+1)=1f(0) = 2/(1 + 1) = 1, and f−1(1)=ln⁡(1/1)=0f^{-1}(1) = \ln(1/1) = 0. So the answer, in the variable of the question, is f−1(y)=ln⁡y2−yf^{-1}(y) = \ln\dfrac{y}{2 - y}. Equivalent forms such as ln⁡y−ln⁡(2−y)\ln y - \ln(2 - y) or −ln⁡(2/y−1)-\ln(2/y - 1) are the same function; what matters is equality, not spelling, and a quick test at a couple of points, as in the check, is how to confirm two forms agree.

The second is a sibling of problem 56: solve x+1x−4≤0\dfrac{x + 1}{x - 4} \le 0. The numerator is zero at −1-1 and the denominator at 44. For x<−1x < -1 both factors are negative and the quotient is positive; for −1<x<4-1 < x < 4 the numerator is positive and the denominator negative, so the quotient is negative; for x>4x > 4 it is positive. Zero at x=−1x = -1 is allowed by ≤\le, while x=4x = 4 divides by zero. The answer is [-1, 4).

The tag after each question is the kind of answer expected: an expression in the named variables, a number, an interval, a set, a vector, or true/false. Exact values are expected where they exist; a decimal is given alongside only as a check.

The first ten problems practise domains, ranges, composition, and inverses, including the inverses of the sigmoid and softplus that recur throughout the books.

1. f(x)=3x−7f(x) = 3x - 7. Give f−1(x)f^{-1}(x). [expr in x]

Answer

f−1(x)=x+73f^{-1}(x) = \dfrac{x + 7}{3}. ff multiplies by 3, then subtracts 7, so the inverse undoes those steps in reverse order: add 7, then divide by 3. Formally, y=3x−7⇒x=(y+7)/3y = 3x - 7 \Rightarrow x = (y + 7)/3, then rename yy to xx. Check: f−1(f(2))=f−1(−1)=6/3=2f^{-1}(f(2)) = f^{-1}(-1) = 6/3 = 2. A common mistake is (x−7)/3(x - 7)/3, which undoes the steps in the original order.

2. f(x)=e2x+1f(x) = e^{2x + 1}. Give f−1(x)f^{-1}(x) for x>0x > 0. [expr in x]

Answer

f−1(x)=ln⁡x−12f^{-1}(x) = \dfrac{\ln x - 1}{2}. From y=e2x+1y = e^{2x + 1}, take ln⁡\ln (defined because y>0y > 0): ln⁡y=2x+1\ln y = 2x + 1, so x=(ln⁡y−1)/2x = (\ln y - 1)/2. A common mistake is ln⁡(x)/2−1\ln(x)/2 - 1, which halves before subtracting: the last step of ff (exponentiate) is undone first, then “plus 1”, then “times 2”.

3. g(x)=2x+1x−3g(x) = \dfrac{2x + 1}{x - 3} for x≠3x \ne 3. Give g−1(x)g^{-1}(x). [expr in x]

Answer

g−1(x)=3x+1x−2g^{-1}(x) = \dfrac{3x + 1}{x - 2}. Solve y=(2x+1)/(x−3)y = (2x + 1)/(x - 3): y(x−3)=2x+1⇒yx−2x=3y+1⇒x(y−2)=3y+1⇒x=(3y+1)/(y−2)y(x - 3) = 2x + 1 \Rightarrow yx - 2x = 3y + 1 \Rightarrow x(y - 2) = 3y + 1 \Rightarrow x = (3y + 1)/(y - 2). Check: g(4)=9g(4) = 9, and (27+1)/(9−2)=4(27 + 1)/(9 - 2) = 4. A common mistake is the reciprocal (x−3)/(2x+1)(x - 3)/(2x + 1): 1/g1/g is not g−1g^{-1}.

4. f(x)=x2f(x) = x^2 and g(x)=x+1g(x) = x + 1. Give (f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x)). [expr in x]

Answer

(x+1)2(x + 1)^2. gg runs first and gives x+1x + 1; ff squares that. A common mistake is x2+1x^2 + 1, which is g(f(x))g(f(x)): composition is applied right to left.

5. The sigmoid is σ(z)=1/(1+e−z)\sigma(z) = 1 / (1 + e^{-z}). Give its inverse, the logit σ−1(p)\sigma^{-1}(p), for 0<p<10 < p < 1. [expr in p]

Answer

σ−1(p)=ln⁡p1−p\sigma^{-1}(p) = \ln\dfrac{p}{1 - p}. As in the worked example with 2 replaced by 1: p(1+e−z)=1⇒e−z=(1−p)/p⇒z=ln⁡(p/(1−p))p(1 + e^{-z}) = 1 \Rightarrow e^{-z} = (1 - p)/p \Rightarrow z = \ln(p/(1 - p)). This is the logit a classifier head outputs (see Fine-tuning heads in AI Engineering). Check: σ(0)=1/2\sigma(0) = 1/2 and ln⁡(1)=0\ln(1) = 0. A common mistake is ln⁡((1−p)/p)\ln((1 - p)/p), which forgets the sign from −z-z.

6. Give the range of σ\sigma (the set of values it takes over all real zz). [interval]

Answer

(0,1)(0, 1). 1+e−z1 + e^{-z} takes every value in (1,∞)(1, \infty), so its reciprocal takes every value in (0,1)(0, 1), approaching but never reaching either end. A common mistake is [0,1][0, 1]: the sigmoid never outputs exactly 0 or 1, which is why ln⁡σ\ln \sigma is always finite.

7. Give the domain of h(x)=ln⁡(4−x2)h(x) = \ln(4 - x^2) (the real xx where it is defined). [interval]

Answer

(−2,2)(-2, 2). ln⁡\ln needs a positive argument: 4−x2>0  ⟺  x2<4  ⟺  −2<x<24 - x^2 > 0 \iff x^2 < 4 \iff -2 < x < 2. A common mistake is [−2,2][-2, 2]: at x=±2x = \pm 2 the argument is 0 and ln⁡0\ln 0 is undefined.

8. Is f(x)=x3+xf(x) = x^3 + x one-to-one on all of R\mathbb{R}? (Hint: is it monotonic?) [bool]

Answer

True. Both x3x^3 and xx are strictly increasing, and a sum of strictly increasing functions is strictly increasing, so x1<x2x_1 < x_2 gives f(x1)<f(x2)f(x_1) < f(x_2) and no two inputs share an output. (With the derivative from Derivatives and finite differences: f′(x)=3x2+1>0f'(x) = 3x^2 + 1 > 0 everywhere.)

9. f(x)=2xf(x) = 2^x and g(x)=log⁡2xg(x) = \log_2 x. Compute f(g(16))+g(f(3))f(g(16)) + g(f(3)). [number]

Answer

1919. ff and gg are inverses, so f(g(16))=16f(g(16)) = 16 and g(f(3))=3g(f(3)) = 3. Step by step: g(16)=4g(16) = 4, f(4)=16f(4) = 16; f(3)=8f(3) = 8, g(8)=3g(8) = 3. A common mistake is 11, from computing f(3)+g(8)=8+3f(3) + g(8) = 8 + 3, which composes the wrong way round in the first term.

10. Softplus is s(x)=ln⁡(1+ex)s(x) = \ln(1 + e^x). Give s−1(y)s^{-1}(y) for y>0y > 0. [expr in y]

Answer

s−1(y)=ln⁡(ey−1)s^{-1}(y) = \ln(e^y - 1). y=ln⁡(1+ex)⇒ey=1+ex⇒ex=ey−1⇒x=ln⁡(ey−1)y = \ln(1 + e^x) \Rightarrow e^y = 1 + e^x \Rightarrow e^x = e^y - 1 \Rightarrow x = \ln(e^y - 1), defined exactly when ey>1e^y > 1, that is y>0y > 0, which is the range of softplus. A common mistake is ln⁡(ey+1)\ln(e^y + 1), which applies softplus again.

Problems on exponents, logarithms, and units

Section titled “Problems on exponents, logarithms, and units”

Problems 11 to 22 are the pen-and-paper side of Exponents, logarithms, and units of information: the laws of logarithms, change of base, nats and bits, and bits per byte.

11. log⁡28+log⁡24\log_2 8 + \log_2 4. [number]

Answer

55. log⁡28=3\log_2 8 = 3 and log⁡24=2\log_2 4 = 2; equivalently log⁡2(8⋅4)=log⁡232=5\log_2(8 \cdot 4) = \log_2 32 = 5. A common mistake is 6, multiplying the logs (3×23 \times 2): the rule log⁡(uv)=log⁡u+log⁡v\log(uv) = \log u + \log v turns a product inside the log into a sum outside, and log⁡2(8+4)\log_2(8 + 4) is a different number again (about 3.58).

12. log⁡832\log_8 32. [number]

Answer

5/35/3. Change of base: log⁡832=log⁡232/log⁡28=5/3\log_8 32 = \log_2 32 / \log_2 8 = 5/3. Check: 85/3=(23)5/3=25=328^{5/3} = (2^3)^{5/3} = 2^5 = 32. A common mistake is 3/53/5, the change of base inverted.

13. Simplify e3ln⁡xe^{3 \ln x} for x>0x > 0. [expr in x]

Answer

x3x^3. 3ln⁡x=ln⁡x33 \ln x = \ln x^3, and eln⁡u=ue^{\ln u} = u. A common mistake is 3x3x: the 3 is an exponent of xx once it leaves the logarithm.

14. Solve 2x=10002^x = 1000 for xx. [number], decimal ok

Answer

x=log⁡21000=ln⁡1000ln⁡2≈9.966x = \log_2 1000 = \dfrac{\ln 1000}{\ln 2} \approx 9.966. Take ln⁡\ln of both sides: xln⁡2=ln⁡1000x \ln 2 = \ln 1000. A common mistake is ln⁡2/ln⁡1000\ln 2 / \ln 1000, the ratio inverted; a sanity check is 210=10242^{10} = 1024, so xx is just under 10.

15. How many bits is one nat? [number], decimal ok

Answer

1/ln⁡2≈1.44271/\ln 2 \approx 1.4427 bits. An amount of information II nats is I/ln⁡2I / \ln 2 bits, because log⁡2u=ln⁡u/ln⁡2\log_2 u = \ln u / \ln 2. A nat is larger than a bit (e>2e > 2), so the answer must exceed 1. A common mistake is ln⁡2≈0.693\ln 2 \approx 0.693, which is one bit expressed in nats.

16. A model’s mean negative log-likelihood is 2.02.0 nats per token on a text of 10001000 tokens and 40004000 bytes. Give its bits per byte. [number], decimal ok

Answer

12ln⁡2≈0.7213\dfrac{1}{2 \ln 2} \approx 0.7213 bits per byte. Total information: 2.0×1000=20002.0 \times 1000 = 2000 nats =2000/ln⁡2= 2000 / \ln 2 bits. Per byte: (2000/ln⁡2)/4000=1/(2ln⁡2)(2000/\ln 2)/4000 = 1/(2 \ln 2). Two common mistakes: 2/ln⁡2≈2.8852/\ln 2 \approx 2.885 is bits per token (divided by tokens, not bytes), and 1/21/2 is nats per byte (never converted). Bits per byte divides by bytes so that models with different tokenizers can be compared (see Exponents, logarithms, and units of information and Perplexity and bits per byte).

17. A model’s perplexity is emean NLL in nats=8e^{\text{mean NLL in nats}} = 8 per token. Give its mean NLL in bits per token. [number]

Answer

33. Mean NLL =ln⁡8= \ln 8 nats =ln⁡8/ln⁡2=log⁡28=3= \ln 8 / \ln 2 = \log_2 8 = 3 bits. Perplexity 8 means “as uncertain as a uniform choice among 8”, which takes 3 bits. A common mistake is ln⁡8≈2.079\ln 8 \approx 2.079, which is the answer in nats.

18. Write a=ln⁡2a = \ln 2 and b=ln⁡3b = \ln 3. Express ln⁡72\ln 72 in aa and bb. [expr in a, b]

Answer

3a+2b3a + 2b. 72=8⋅9=23⋅3272 = 8 \cdot 9 = 2^3 \cdot 3^2, and logs turn the product into a sum and the powers into factors: ln⁡72=3ln⁡2+2ln⁡3\ln 72 = 3 \ln 2 + 2 \ln 3. A common mistake is 2a+3b2a + 3b, with the exponents swapped.

19. Solve log⁡3x+log⁡3(x−8)=2\log_3 x + \log_3 (x - 8) = 2. [number]

Answer

x=9x = 9. Both logs need positive arguments, so x>8x > 8. Combine: log⁡3(x(x−8))=2⇒x2−8x=9⇒(x−9)(x+1)=0\log_3(x(x - 8)) = 2 \Rightarrow x^2 - 8x = 9 \Rightarrow (x - 9)(x + 1) = 0. Of the roots 9 and −1-1, only 9 is in the domain. Check: log⁡39+log⁡31=2+0\log_3 9 + \log_3 1 = 2 + 0. A common mistake is to keep −1-1, the root outside the domain x>8x > 8.

20. Solve 4x=84^x = 8. [number]

Answer

x=3/2x = 3/2. Write both as powers of 2: 22x=232^{2x} = 2^3, so 2x=32x = 3. A common mistake is 2, from 8/48/4: exponents are solved with logarithms or a common base, not by dividing.

21. A quantity decays as N(t)=N0e−ktN(t) = N_0 e^{-kt} with k>0k > 0. After what time is it half of N0N_0? [expr in k]

Answer

t=ln⁡2kt = \dfrac{\ln 2}{k}. e−kt=1/2⇒−kt=−ln⁡2e^{-kt} = 1/2 \Rightarrow -kt = -\ln 2. A common mistake is 1/(2k)1/(2k), which treats the exponential as linear.

22. How many decimal digits does 21002^{100} have? (Use log⁡102≈0.30103\log_{10} 2 \approx 0.30103.) [number]

Answer

3131. A positive integer NN has ⌊log⁡10N⌋+1\lfloor \log_{10} N \rfloor + 1 digits (a number with dd digits lies in [10d−1,10d)[10^{d-1}, 10^d)). log⁡102100=100×0.30103=30.103\log_{10} 2^{100} = 100 \times 0.30103 = 30.103, so ⌊30.103⌋+1=31\lfloor 30.103 \rfloor + 1 = 31. A common mistake is 30, forgetting the +1+ 1.

Problems on trigonometry, complex numbers, and Euler’s formula

Section titled “Problems on trigonometry, complex numbers, and Euler’s formula”

Problems 23 to 34 go with Trigonometry, rotations, complex numbers, and Euler’s formula: unit-circle values, angle addition, rotations as complex multiplication, and the relative-angle identity behind RoPE.

23. sin⁡(π/6)\sin(\pi/6). [number]

Answer

1/21/2. In the 30-60-90 triangle with hypotenuse 2, the side opposite the 30°30° angle is 1. A common mistake is 3/2\sqrt 3/2, which is cos⁡(π/6)\cos(\pi/6).

24. cos⁡(2π/3)\cos(2\pi/3). [number]

Answer

−1/2-1/2. 2π/3=120°2\pi/3 = 120° is in the second quadrant, where the xx coordinate of the unit circle is negative; its reference angle is π/3\pi/3, with cosine 1/21/2. A common mistake is +1/2+1/2, dropping the quadrant’s sign.

25. Write cos⁡acos⁡b−sin⁡asin⁡b\cos a \cos b - \sin a \sin b as one trigonometric function of aa and bb. [expr in a, b]

Answer

cos⁡(a+b)\cos(a + b), the angle-addition formula. One way to see it: the real part of eiaeib=(cos⁡a+isin⁡a)(cos⁡b+isin⁡b)e^{ia} e^{ib} = (\cos a + i \sin a)(\cos b + i \sin b) is cos⁡acos⁡b−sin⁡asin⁡b\cos a \cos b - \sin a \sin b, and eiaeib=ei(a+b)e^{ia} e^{ib} = e^{i(a + b)}. A common mistake is cos⁡(a−b)\cos(a - b), which has a plus sign between the products.

26. Rotate the point (1,0)(1, 0) counterclockwise by π/3\pi/3. Give the image. [vector]

Answer

[1/2,3/2][1/2, \sqrt 3/2]. Rotating (1,0)(1, 0) by θ\theta lands at (cos⁡θ,sin⁡θ)(\cos\theta, \sin\theta): the first column of R(θ)R(\theta) is where the first basis vector goes. A common mistake is [3/2,1/2][\sqrt 3/2, 1/2], a rotation by π/6\pi/6.

27. R(π/2) R(π/3)=R(θ)R(\pi/2)\,R(\pi/3) = R(\theta) with θ∈[0,2π)\theta \in [0, 2\pi), where R(θ)R(\theta) is the rotation by θ\theta. Give θ\theta. [number]

Answer

5π/65\pi/6. Composing rotations adds their angles: π/2+π/3=3π/6+2π/6\pi/2 + \pi/3 = 3\pi/6 + 2\pi/6. A common mistake is π/6\pi/6, from subtracting.

28. (1+i)8(1 + i)^8. [number]

Answer

1616. (1+i)2=1+2i+i2=2i(1 + i)^2 = 1 + 2i + i^2 = 2i, so (1+i)8=(2i)4=16i4=16(1 + i)^8 = (2i)^4 = 16 i^4 = 16. In polar form: 1+i=2 eiπ/41 + i = \sqrt 2\, e^{i\pi/4}, and the eighth power is (2)8ei2π=16(\sqrt 2)^8 e^{i 2\pi} = 16. A common mistake is −16-16, from i4=−1i^4 = -1; in fact i4=(i2)2=1i^4 = (i^2)^2 = 1.

29. ∣3+4i∣|3 + 4i|. [number]

Answer

55. ∣a+bi∣=a2+b2=9+16|a + bi| = \sqrt{a^2 + b^2} = \sqrt{9 + 16}. A common mistake is 7, adding the parts: the modulus is a length, by Pythagoras.

30. Rotate 3+4i3 + 4i by the angle tt with cos⁡t=3/5\cos t = 3/5 and sin⁡t=4/5\sin t = 4/5: compute (3+4i)(cos⁡t+isin⁡t)(3 + 4i)(\cos t + i \sin t). [number]

Answer

−75+245i-\dfrac75 + \dfrac{24}{5} i. Expand: (3+4i)(3/5+4i/5)=9/5+12i/5+12i/5+16i2/5=(9−16)/5+(24/5)i(3 + 4i)(3/5 + 4i/5) = 9/5 + 12i/5 + 12i/5 + 16i^2/5 = (9 - 16)/5 + (24/5) i. The modulus stays 5, as a rotation must: 49+576/5=25/5\sqrt{49 + 576}/5 = 25/5. Two common mistakes: 5, which is 3⋅35+4⋅453 \cdot \tfrac35 + 4 \cdot \tfrac45, a dot product rather than a complex multiplication; and −7/5−24i/5-7/5 - 24i/5, a sign slip in the imaginary part.

31. eiπ/2e^{i\pi/2}. [number]

Answer

ii. Euler’s formula: cos⁡(π/2)+isin⁡(π/2)=0+i\cos(\pi/2) + i \sin(\pi/2) = 0 + i. A quarter turn takes 1 to ii. A common mistake is 1, which is ei⋅0e^{i \cdot 0} (or e2πie^{2\pi i}).

32. Express cos⁡t\cos t using only exponentials eite^{it} and e−ite^{-it}. [expr in t]

Answer

cos⁡t=eit+e−it2\cos t = \dfrac{e^{it} + e^{-it}}{2}. Add eit=cos⁡t+isin⁡te^{it} = \cos t + i \sin t and e−it=cos⁡t−isin⁡te^{-it} = \cos t - i \sin t: the sines cancel and 2cos⁡t2 \cos t remains. A common mistake is the difference over 2, which is isin⁡ti \sin t.

33. For the unit complex numbers u=eiau = e^{ia} and v=eibv = e^{ib}, simplify Re⁡(u vˉ)\operatorname{Re}(u\,\bar{v}), where vˉ\bar{v} is the complex conjugate. [expr in a, b]

Answer

cos⁡(a−b)\cos(a - b). vˉ=e−ib\bar v = e^{-ib}, so uvˉ=ei(a−b)u \bar v = e^{i(a - b)} and its real part is cos⁡(a−b)\cos(a - b). This is why a RoPE attention score depends only on the difference of positions (see Why RoPE rotates pairs). A common mistake is cos⁡(a+b)\cos(a + b), from forgetting the conjugate.

34. A RoPE dimension pair rotates by ωp\omega p radians at position pp, with ω=0.01\omega = 0.01. After how many positions does the pattern repeat (the period)? [number]

Answer

200π≈628.3200\pi \approx 628.3 positions. The pattern repeats when the angle grows by 2π2\pi: ωλ=2π⇒λ=2π/0.01\omega \lambda = 2\pi \Rightarrow \lambda = 2\pi/0.01. A common mistake is 100π100\pi, using π\pi instead of 2π2\pi as the full turn.

Problems on sequences and geometric series

Section titled “Problems on sequences and geometric series”

Problems 35 to 44 go with Sequences, geometric series, and frequency ladders: geometric sums, the RoPE ratio, EMA weights, and ALiBi slopes.

35. 1+12+14+18+⋯1 + \tfrac12 + \tfrac14 + \tfrac18 + \cdots (forever). [number]

Answer

22. A geometric series with a=1a = 1 and ∣r∣=1/2<1|r| = 1/2 < 1 sums to a/(1−r)=1/(1/2)a/(1 - r) = 1/(1/2). A common mistake is 1, the sum of the terms after the first.

36. Give ∑j=0n−1rj\sum_{j=0}^{n-1} r^j in closed form for r≠1r \ne 1. [expr in r, n]

Answer

1−rn1−r\dfrac{1 - r^n}{1 - r}. With S=1+r+⋯+rn−1S = 1 + r + \cdots + r^{n-1}, S−rS=1−rnS - rS = 1 - r^n because every middle term cancels. The sum has nn terms, j=0j = 0 to n−1n - 1. A common mistake is (1−rn+1)/(1−r)(1 - r^{n+1})/(1 - r), which counts n+1n + 1 terms.

37. The sum of the first 10 terms of 3,6,12,24,…3, 6, 12, 24, \ldots [number]

Answer

30693069. a=3a = 3, r=2r = 2, n=10n = 10: 3(210−1)/(2−1)=3×10233 (2^{10} - 1)/(2 - 1) = 3 \times 1023. Common mistakes are 6141 (11 terms) and 1533 (9 terms): the exponent in rnr^n is the number of terms.

38. The RoPE ladder of a 128-dimensional head with base 1000010000 is ωi=10000−2i/128\omega_i = 10000^{-2i/128} for i=0,…,63i = 0, \ldots, 63. Give the ratio ωi+1/ωi\omega_{i+1}/\omega_i. [number]

Answer

10000−1/64≈0.866010000^{-1/64} \approx 0.8660. ωi+1/ωi=10000−2(i+1)/128+2i/128=10000−2/128\omega_{i+1}/\omega_i = 10000^{-2(i+1)/128 + 2i/128} = 10000^{-2/128}. A common mistake is 10000−1/12810000^{-1/128}, which forgets the factor 2 in 2i/d2i/d (pairs of dimensions share one frequency).

39. 1+2+⋯+1001 + 2 + \cdots + 100. [number]

Answer

50505050. Pair the first and last terms: 1+100=2+99=⋯=1011 + 100 = 2 + 99 = \cdots = 101, and there are 50 pairs; in general n(n+1)/2n(n + 1)/2. A common mistake is 5000, from 100×100/2100 \times 100/2.

40. An exponential moving average mt=βmt−1+(1−β)gtm_t = \beta m_{t-1} + (1 - \beta) g_t starts at m0=0m_0 = 0 with β=0.9\beta = 0.9 and sees gt=1g_t = 1 at every step. Give m3m_3. [number]

Answer

271/1000=0.271271/1000 = 0.271. Step by step: m1=0.1m_1 = 0.1, m2=0.9×0.1+0.1=0.19m_2 = 0.9 \times 0.1 + 0.1 = 0.19, m3=0.9×0.19+0.1=0.271m_3 = 0.9 \times 0.19 + 0.1 = 0.271. In closed form, mt=(1−β)(1+β+⋯+βt−1)=1−βtm_t = (1 - \beta)(1 + \beta + \cdots + \beta^{t-1}) = 1 - \beta^t, the geometric sum of problem 36. This is the bias toward 0 that Adam’s correction divides out (see Series and the EMA). A common mistake is 0.729=β30.729 = \beta^3, which is 1−m31 - m_3.

41. In problem 40, m3=(1−β)(g3+βg2+β2g1)m_3 = (1 - \beta)(g_3 + \beta g_2 + \beta^2 g_1). Give the weight on the oldest gradient g1g_1. [number]

Answer

81/1000=0.08181/1000 = 0.081. The weight is (1−β)β2=0.1×0.81(1 - \beta)\beta^2 = 0.1 \times 0.81. A common mistake is 1/101/10, the newest gradient’s weight (1−β)(1 - \beta).

42. lim⁡n→∞2n+1n+3\lim_{n \to \infty} \dfrac{2n + 1}{n + 3}. [number]

Answer

22. Divide numerator and denominator by nn: (2+1/n)/(1+3/n)→2/1(2 + 1/n)/(1 + 3/n) \to 2/1. A common mistake is 1/31/3, which is the value at n=0n = 0, not the limit.

43. Write 0.272727…0.272727\ldots (27 repeating) as a fraction. [number]

Answer

3/113/11. With x=0.2727…x = 0.2727\ldots, 100x=27.2727…100x = 27.2727\ldots, so 99x=2799x = 27 and x=27/99=3/11x = 27/99 = 3/11. Equivalently, the geometric series 27/100+27/1002+⋯=(27/100)/(1−1/100)27/100 + 27/100^2 + \cdots = (27/100)/(1 - 1/100). A common mistake is 27/10027/100, only the first term.

44. ALiBi with 4 heads uses the slopes 2−2,2−4,2−6,2−82^{-2}, 2^{-4}, 2^{-6}, 2^{-8}. Give their sum. [number]

Answer

85/25685/256. Over the common denominator 256: 64+16+4+1=8564 + 16 + 4 + 1 = 85. As a geometric sum with a=1/4a = 1/4, r=1/4r = 1/4, n=4n = 4: (1/4)(1−4−4)/(3/4)=(1−1/256)/3=85/256(1/4)(1 - 4^{-4})/(3/4) = (1 - 1/256)/3 = 85/256. A common mistake is 1/31/3, the infinite sum.

Problems 45 to 52 go with Polynomials, Horner’s rule, and stable quadratic roots: Horner’s rule, synthetic division, Vieta’s formulas, and the cancellation case.

45. Evaluate p(x)=2−3x+x2+4x3p(x) = 2 - 3x + x^2 + 4x^3 at x=2x = 2 (Horner’s rule makes it three multiply-adds). [number]

Answer

3232. Horner from the highest coefficient down, 4,1,−3,24, 1, -3, 2: 4→4⋅2+1=9→9⋅2−3=15→15⋅2+2=324 \to 4 \cdot 2 + 1 = 9 \to 9 \cdot 2 - 3 = 15 \to 15 \cdot 2 + 2 = 32. Directly: 2−6+4+322 - 6 + 4 + 32. A common mistake is 10, from running Horner with the coefficients in the order written (2,−3,1,42, -3, 1, 4), which evaluates the reversed polynomial.

46. Divide x3−6x2+11x−6x^3 - 6x^2 + 11x - 6 by x−1x - 1. Give the quotient. [expr in x]

Answer

x2−5x+6x^2 - 5x + 6. Synthetic division by the root 1 is Horner at x=1x = 1: 1→1−6=−5→−5+11=6→6−6=01 \to 1 - 6 = -5 \to -5 + 11 = 6 \to 6 - 6 = 0. The intermediate values are the quotient’s coefficients and the last is the remainder, 0, so x=1x = 1 is a root. A common mistake is x2−7x+18x^2 - 7x + 18, which divides by x+1x + 1 (Horner at −1-1).

47. Give all roots of x3−6x2+11x−6x^3 - 6x^2 + 11x - 6. [set]

Answer

{1,2,3}\{1, 2, 3\}. From problem 46, x3−6x2+11x−6=(x−1)(x2−5x+6)=(x−1)(x−2)(x−3)x^3 - 6x^2 + 11x - 6 = (x - 1)(x^2 - 5x + 6) = (x - 1)(x - 2)(x - 3). Vieta checks it: the roots sum to 6 and multiply to 6. A common mistake is {−1,−2,−3}\{-1, -2, -3\}, reading the roots off the factors’ constants without the sign.

48. Give the roots of 2x2+3x−22x^2 + 3x - 2. [set]

Answer

{1/2,−2}\{1/2, -2\}. Factor: 2x2+3x−2=(2x−1)(x+2)2x^2 + 3x - 2 = (2x - 1)(x + 2), or use x=(−3±9+16)/4=(−3±5)/4x = (-3 \pm \sqrt{9 + 16})/4 = (-3 \pm 5)/4. A common mistake is {−1/2,2}\{-1/2, 2\}, with both signs flipped.

49. Give the smaller root of x2−106x+1x^2 - 10^6 x + 1 exactly (radicals allowed) or to 15 significant digits. [number]

Answer

500000−249999999999≈1.00000000000100×10−6500000 - \sqrt{249999999999} \approx 1.00000000000100 \times 10^{-6}. The quadratic formula gives x=(106±1012−4)/2=500000±249999999999x = (10^6 \pm \sqrt{10^{12} - 4})/2 = 500000 \pm \sqrt{249999999999}. Evaluated naively in floating point, the minus sign subtracts two numbers that agree in about 12 digits and loses them. The stable route of Polynomials, Horner’s rule, and stable quadratic roots computes the large root x1=500000+249999999999x_1 = 500000 + \sqrt{249999999999} first and uses Vieta, x1x2=c/a=1x_1 x_2 = c/a = 1, so x2=1/x1=10−6+10−18+⋯x_2 = 1/x_1 = 10^{-6} + 10^{-18} + \cdots. A common mistake is 10−610^{-6} exactly (the approximation c/bc/b), which drops the 10−1810^{-18} correction that the 15th significant digit shows.

50. Without solving, give the product of the roots of 3x2−7x+23x^2 - 7x + 2. [number]

Answer

2/32/3. Vieta: for ax2+bx+cax^2 + bx + c, the product of the roots is c/ac/a. (The roots are 22 and 1/31/3.) A common mistake is 2, which is cc without dividing by aa.

51. How many real roots does x2+x+1x^2 + x + 1 have? [number]

Answer

00. The discriminant is b2−4ac=1−4=−3<0b^2 - 4ac = 1 - 4 = -3 < 0, so both roots are complex. Equivalently, x2+x+1=(x+1/2)2+3/4>0x^2 + x + 1 = (x + 1/2)^2 + 3/4 > 0. A common mistake is 2, from counting the roots of a quadratic without checking the discriminant.

52. The Taylor polynomial of exe^x of degree 3 around 0 is c0+c1x+c2x2+c3x3c_0 + c_1 x + c_2 x^2 + c_3 x^3. Give [c0,c1,c2,c3][c_0, c_1, c_2, c_3]. [vector]

Answer

[1,1,1/2,1/6][1, 1, 1/2, 1/6]. ck=f(k)(0)/k!c_k = f^{(k)}(0)/k!, and every derivative of exe^x is exe^x, equal to 1 at 0, so ck=1/k!c_k = 1/k!: 1/0!,1/1!,1/2!,1/3!1/0!, 1/1!, 1/2!, 1/3!. A common mistake is [1,1,1/2,1/3][1, 1, 1/2, 1/3], using 1/k1/k instead of 1/k!1/k!.

The last eight problems return to the inequalities taught at the start of this section, including two that reappear in optimization and information theory.

53. Solve ∣x−3∣<2|x - 3| < 2. [interval]

Answer

(1,5)(1, 5). “Within distance 2 of 3”: −2<x−3<2-2 < x - 3 < 2, so 1<x<51 < x < 5. The inequality is strict, so the endpoints are excluded. A common mistake is [1,5][1, 5].

54. Solve x2−5x+6>0x^2 - 5x + 6 > 0. [interval]

Answer

(−∞,2)∪(3,∞)(-\infty, 2) \cup (3, \infty). x2−5x+6=(x−2)(x−3)x^2 - 5x + 6 = (x - 2)(x - 3) is zero at 2 and 3; the parabola opens upward, so it is positive outside the roots. A common mistake is (2,3)(2, 3), which is where it is negative.

55. The smallest integer nn with 2n>10002^n > 1000 (the bits needed to number 1000 items). [number]

Answer

1010. 29=512<1000<1024=2102^9 = 512 < 1000 < 1024 = 2^{10}; equivalently n>log⁡21000≈9.97n > \log_2 1000 \approx 9.97 (problem 14), and the smallest such integer is 10. A common mistake is 9, rounding log⁡21000\log_2 1000 down.

56. Solve x−1x+2≥0\dfrac{x - 1}{x + 2} \ge 0. [interval]

Answer

(−∞,−2)∪[1,∞)(-\infty, -2) \cup [1, \infty). The numerator is zero at 1 and the denominator at −2-2. Signs: for x<−2x < -2 both are negative, quotient positive; for −2<x<1-2 < x < 1 the quotient is negative; for x>1x > 1 positive. x=1x = 1 gives 0, allowed by ≥\ge; x=−2x = -2 divides by zero. A common mistake is (−∞,−2]∪[1,∞)(-\infty, -2] \cup [1, \infty), which includes the point where the expression is undefined.

57. For which probabilities p∈(0,1)p \in (0, 1) is the surprisal −log⁡2p-\log_2 p greater than 3 bits? [interval]

Answer

(0,1/8)(0, 1/8). −log⁡2p>3  ⟺  log⁡2p<−3  ⟺  p<2−3-\log_2 p > 3 \iff \log_2 p < -3 \iff p < 2^{-3}: multiplying by −1-1 flips the inequality, and 2x2^x is increasing, so applying it keeps the direction. Rarer events are more surprising. A common mistake is (1/8,1)(1/8, 1), which forgets the flip.

58. Solve ex≤2e^x \le 2. [interval]

Answer

(−∞,ln⁡2](-\infty, \ln 2]. ln⁡\ln is strictly increasing, so applying it keeps the direction: x≤ln⁡2x \le \ln 2. Equality is allowed, so the endpoint is included. A common mistake is (−∞,ln⁡2)(-\infty, \ln 2), dropping the endpoint.

59. The smallest value of x+1/xx + 1/x over x>0x > 0. [number]

Answer

22, at x=1x = 1. Multiply x+1/x≥2x + 1/x \ge 2 by x>0x > 0 (direction kept): x2+1≥2x  ⟺  (x−1)2≥0x^2 + 1 \ge 2x \iff (x - 1)^2 \ge 0, which always holds, with equality only at x=1x = 1, where 1+1=21 + 1 = 2. A common mistake is 1, the minimizer instead of the minimum.

60. Solve ln⁡x<x−1\ln x < x - 1 over x>0x > 0. [interval]

Answer

(0,1)∪(1,∞)(0, 1) \cup (1, \infty). ln⁡x≤x−1\ln x \le x - 1 for every x>0x > 0, with equality only at x=1x = 1 (the line x−1x - 1 is tangent to ln⁡x\ln x there, and ln⁡\ln curves below its tangents). The strict inequality therefore holds everywhere except x=1x = 1. A common mistake is (0,∞)(0, \infty), which includes the point of equality.

The worked answers return again and again to a handful of mistakes, and each of them bites later in the books. Inverting the steps in the original order, as in f−1(x)=(x−7)/3f^{-1}(x) = (x - 7)/3 for f(x)=3x−7f(x) = 3x - 7, breaks every inverse in Categorical sampling, where inverse-CDF sampling depends on it; problems 1 and 3 address it. Composing in the wrong order, g(f(x))g(f(x)) instead of f(g(x))f(g(x)), breaks the chain rule in Jacobians and the chain rule and backpropagation in Tensor, broadcasting backward, and no_grad; see problems 4 and 9. A closed endpoint where the expression is undefined matters for the domain of ln⁡\ln in every loss (problems 7 and 56). The false rule log⁡(a+b)=log⁡a+log⁡b\log(a + b) = \log a + \log b wrecks the loss rewrites of Entropy, cross-entropy, and KL (problems 11 and 18). One term too many, or the wrong weight, in a geometric sum throws off Adam’s bias correction in Series and the EMA (problems 37, 40, and 41).

Warning: Do not give decimals where an exact value exists. A rounded value hides whether the derivation was right, and problem 49 shows a case where rounding is the whole bug. Every answer gives the exact form first and a decimal only as a check.

Each part feeds a section of this chapter: the logarithms and units of Exponents, logarithms, and units of information; the rotations, Euler’s formula, and the relative-angle identity of problem 33 in Trigonometry, rotations, complex numbers, and Euler’s formula; the geometric sums, the RoPE ratio of problem 38, the ALiBi slopes of problem 44, and the EMA weights of problems 40 and 41 in Sequences, geometric series, and frequency ladders; and Horner’s rule (problem 45), factoring, Vieta, and the cancellation case of problem 49 in Polynomials, Horner’s rule, and stable quadratic roots. Beyond this chapter, limits (problem 42) and monotonicity (problem 8) start calculus in Derivatives and finite differences; functions, inverses, and bijections return in discrete mathematics in Injective, surjective, bijective; and inverse functions become inverse-CDF sampling in Categorical sampling.

  • OpenStax, Precalculus 2e (free): chapter 1 on functions, chapters 2 and 3 on linear and polynomial functions and inequalities, chapter 6 on exponentials and logarithms, chapters 5 to 8 on trigonometry and complex numbers, and chapter 11 on sequences and series.
  • Function: a rule assigning exactly one output to each input in its domain.
  • Domain and range: the inputs where a function is defined, and the outputs it actually takes.
  • Composition: (f∘g)(x)=f(g(x))(f \circ g)(x) = f(g(x)), applying gg first.
  • One-to-one: different inputs always give different outputs; exactly the functions with an inverse.
  • Inverse function: f−1f^{-1} with f−1(f(x))=xf^{-1}(f(x)) = x and f(f−1(y))=yf(f^{-1}(y)) = y.
  • Strictly monotonic: always increasing or always decreasing, and therefore one-to-one.
  • A function assigns exactly one output to each input in its domain; its inverse exists exactly when no two inputs share an output, and undoes it: f−1(f(x))=xf^{-1}(f(x)) = x.
  • A strictly monotonic function is one-to-one, so it has an inverse; that is why exp⁡\exp, ln⁡\ln, the sigmoid, and softplus can all be inverted.
  • Solving an inequality is solving the matching equation and testing the sign between its solutions; multiplying or dividing by a negative number, or applying a decreasing function, flips the direction.
  • The middle four parts are the pen-and-paper side of this chapter’s four sections; if a problem stops you, read the section it names.
  1. Why does a strictly monotonic function always have an inverse on its range?
    AnswerIf $x_1 \ne x_2$, one is smaller, say $x_1 < x_2$, and strict monotonicity gives $f(x_1) < f(x_2)$ or $f(x_1) > f(x_2)$; either way $f(x_1) \ne f(x_2)$. So $f$ is one-to-one, every output in the range comes from exactly one input, and $f^{-1}$ is well defined.
  2. When solving an inequality by cutting the line at the zeros and poles of an expression, which cut points can belong to the answer?
    AnswerA zero of the expression belongs to the answer for $\ge$ or $\le$ and not for strict inequalities. A point where the expression is undefined, such as a zero of a denominator, never belongs.
  3. Why does applying ln⁡\ln to both sides of ex≤2e^x \le 2 keep the direction, while multiplying log⁡2p<−3\log_2 p < -3 by −1-1 flips it?
    Answer$\ln$ is strictly increasing, so it preserves order; multiplying by a negative number is a strictly decreasing map, so it reverses order.