TExcelTAD
Home › Pre-Calculus, Geometry & Trigonometry › Pre-Calculus Exercises

Pre-Calculus Exercises

Time to practise across the whole course: triangles, radians, the unit circle, trig equations, functions and inverses, sequences and series, the binomial expansion, polar and complex form, and limits. Each exercise has a starter program that runs but does not do the job yet. Replace the TODO parts, press ▶ Run, and compare your result with the expected output. The output block under each starter shows what the unfinished starter prints.

Tip: Sketch first. A quick drawing of the triangle, the angle on the unit circle or the first few terms of a series usually tells you the answer's size and sign before any code runs.

# Exercise Practises
1 The third side laws of sines and cosines
2 How far does the wheel roll? angles and radians
3 Exact values the unit circle
4 Every solution trig equations, inverse trig
5 Undo a function composition and inverses
6 Two series arithmetic and geometric progressions
7 How many terms? infinite series
8 Binomial coefficients the binomial expansion
9 Polar form polar coordinates, complex numbers
10 A hole in the graph introduction to limits

Exercise 1: The third side

A triangle has sides a=7a = 7 and b=9b = 9 with the angle C=60∘C = 60^\circ between them. Use the law of cosines c2=a2+b2−2abcos⁡Cc^2 = a^2 + b^2 - 2ab\cos C to find cc, then find angle AA with the law of sines.

python · try it yourself
import math

a, b, C = 7, 9, math.radians(60)
c = 0.0            # TODO: law of cosines
A = 0.0            # TODO: asin(a * sin(C) / c), in degrees
print(f"c = {c:.4f}, A = {A:.2f} deg")
c = 0.0000, A = 0.00 deg

Expected output when solved:

text
c = 8.1854, A = 47.78 deg

Hint: cos⁡60∘=1/2\cos 60^\circ = 1/2, so c2=49+81−63=67c^2 = 49 + 81 - 63 = 67.

Show solution
python · try it yourself
import math

a, b, C = 7, 9, math.radians(60)
c = math.sqrt(a**2 + b**2 - 2 * a * b * math.cos(C))
A = math.degrees(math.asin(a * math.sin(C) / c))
print(f"c = {c:.4f}, A = {A:.2f} deg")
c = 8.1854, A = 47.78 deg

c=67c = \sqrt{67}. Using the law of sines for AA is safe here because a<ca < c, so AA is not the largest angle and cannot be obtuse.

Exercise 2: How far does the wheel roll?

A robot wheel of radius 0.35 m turns through 150°. How far does the robot roll? Arc length is s=rθs = r\theta with θ\theta in radians.

python · try it yourself
import math

r, degrees = 0.35, 150
theta = 0.0        # TODO: convert to radians
s = r * theta
print(f"theta = {theta:.4f} rad, distance = {s:.4f} m")
theta = 0.0000 rad, distance = 0.0000 m

Expected output when solved:

text
theta = 2.6180 rad, distance = 0.9163 m

Hint: 150∘=150⋅π/180=5π/6150^\circ = 150 \cdot \pi/180 = 5\pi/6.

Show solution
python · try it yourself
import math

r, degrees = 0.35, 150
theta = math.radians(degrees)
s = r * theta
print(f"theta = {theta:.4f} rad, distance = {s:.4f} m")
theta = 2.6180 rad, distance = 0.9163 m

Exercise 3: Exact values

Fill in the exact values of sin⁡\sin and cos⁡\cos at 5π/65\pi/6 and 7π/47\pi/4 as SymPy expressions, then let the program compare them with SymPy's own values.

python · try it yourself
import sympy as sp

angles = [5 * sp.pi / 6, 7 * sp.pi / 4]
by_hand = {                     # TODO: replace the zeros, e.g. sp.sqrt(3) / 2
    "sin(5pi/6)": 0, "cos(5pi/6)": 0,
    "sin(7pi/4)": 0, "cos(7pi/4)": 0,
}
true = [sp.sin(angles[0]), sp.cos(angles[0]), sp.sin(angles[1]), sp.cos(angles[1])]
for (name, mine), exact in zip(by_hand.items(), true):
    print(f"{name}: {exact}  {'ok' if sp.simplify(mine - exact) == 0 else 'wrong'}")
sin(5pi/6): 1/2  wrong
cos(5pi/6): -sqrt(3)/2  wrong
sin(7pi/4): -sqrt(2)/2  wrong
cos(7pi/4): sqrt(2)/2  wrong

Expected output when solved: every line ends in ok.

Hint: 5π/65\pi/6 is 150°, in quadrant II with reference angle 30°; 7π/47\pi/4 is 315°, in quadrant IV with reference angle 45°.

Show solution
python · try it yourself
import sympy as sp

angles = [5 * sp.pi / 6, 7 * sp.pi / 4]
by_hand = {
    "sin(5pi/6)": sp.Rational(1, 2), "cos(5pi/6)": -sp.sqrt(3) / 2,
    "sin(7pi/4)": -sp.sqrt(2) / 2, "cos(7pi/4)": sp.sqrt(2) / 2,
}
true = [sp.sin(angles[0]), sp.cos(angles[0]), sp.sin(angles[1]), sp.cos(angles[1])]
for (name, mine), exact in zip(by_hand.items(), true):
    print(f"{name}: {exact}  {'ok' if sp.simplify(mine - exact) == 0 else 'wrong'}")
sin(5pi/6): 1/2  ok
cos(5pi/6): -sqrt(3)/2  ok
sin(7pi/4): -sqrt(2)/2  ok
cos(7pi/4): sqrt(2)/2  ok

In quadrant II sine is positive and cosine negative; in quadrant IV it is the other way round.

Exercise 4: Every solution

Solve 2sin⁡x−1=02\sin x - 1 = 0 for 0≤x<2π0 \le x < 2\pi. math.asin returns only one angle; add the second one that has the same sine.

python · try it yourself
import math

base = math.asin(1 / 2)
solutions = [base]          # TODO: add the other solution in [0, 2π)
print([round(x, 4) for x in solutions])
print([round(2 * math.sin(x) - 1, 12) for x in solutions])
[0.5236]
[0.0]

Expected output when solved:

text
[0.5236, 2.618]
[0.0, 0.0]

Hint: sin⁡(π−x)=sin⁡x\sin(\pi - x) = \sin x.

Show solution
python · try it yourself
import math

base = math.asin(1 / 2)
solutions = [base, math.pi - base]
print([round(x, 4) for x in solutions])
print([round(2 * math.sin(x) - 1, 12) for x in solutions])
[0.5236, 2.618]
[0.0, 0.0]

The solutions are π/6\pi/6 and 5π/65\pi/6 (30° and 150°). Adding 2πk2\pi k to either gives all solutions on the whole real line.

Exercise 5: Undo a function

For f(x)=3x−2f(x) = 3x - 2 and g(x)=x2g(x) = x^2, compute f(g(2))f(g(2)) and g(f(2))g(f(2)), then write the inverse f−1f^{-1} and check that f−1(f(x))=xf^{-1}(f(x)) = x for a few xx.

python · try it yourself
f = lambda x: 3 * x - 2
g = lambda x: x ** 2
f_inv = lambda y: y          # TODO: the inverse of f
print("f(g(2)) =", f(g(2)), " g(f(2)) =", g(f(2)))
print([f_inv(f(x)) for x in [-1, 0, 2.5, 10]])
f(g(2)) = 10  g(f(2)) = 16
[-5, -2, 5.5, 28]

Expected output when solved:

text
f(g(2)) = 10  g(f(2)) = 16
[-1.0, 0.0, 2.5, 10.0]

Hint: Solve y=3x−2y = 3x - 2 for xx.

Show solution
python · try it yourself
f = lambda x: 3 * x - 2
g = lambda x: x ** 2
f_inv = lambda y: (y + 2) / 3
print("f(g(2)) =", f(g(2)), " g(f(2)) =", g(f(2)))
print([f_inv(f(x)) for x in [-1, 0, 2.5, 10]])
f(g(2)) = 10  g(f(2)) = 16
[-1.0, 0.0, 2.5, 10.0]

f(g(2))=3⋅4−2=10f(g(2)) = 3 \cdot 4 - 2 = 10 but g(f(2))=42=16g(f(2)) = 4^2 = 16: composition is not commutative. The inverse undoes ff in reverse order: add 2, then divide by 3.

Exercise 6: Two series

Use the closed-form formulas, not loops, for (a) 5+8+11+…5 + 8 + 11 + \ldots up to 30 terms and (b) 3+6+12+…3 + 6 + 12 + \ldots up to 10 terms. The program checks them against sum.

python · try it yourself
n = 30
arith = 0          # TODO: n/2 · (2a + (n − 1)d) with a = 5, d = 3
m = 10
geom = 0           # TODO: a(rᵐ − 1)/(r − 1) with a = 3, r = 2
print(arith, sum(5 + 3 * k for k in range(n)))
print(geom, sum(3 * 2**k for k in range(m)))
0 1455
0 3069

Expected output when solved:

text
1455 1455
3069 3069

Hint: Use integer division // in the arithmetic formula so the result stays an int.

Show solution
python · try it yourself
n = 30
arith = n * (2 * 5 + (n - 1) * 3) // 2
m = 10
geom = 3 * (2**m - 1) // (2 - 1)
print(arith, sum(5 + 3 * k for k in range(n)))
print(geom, sum(3 * 2**k for k in range(m)))
1455 1455
3069 3069

(a) 30/2⋅(10+87)=15⋅97=145530/2 \cdot (10 + 87) = 15 \cdot 97 = 1455. (b) 3⋅(1024−1)=30693 \cdot (1024 - 1) = 3069.

Exercise 7: How many terms?

The geometric series 1+2/3+(2/3)2+…1 + 2/3 + (2/3)^2 + \ldots converges to 1/(1−2/3)=31/(1 - 2/3) = 3. Find the first nn for which the partial sum SnS_n (nn terms) is within 0.001 of 3, by a loop and by a formula.

python · try it yourself
import math

limit, total, n = 3, 0.0, 0
# TODO: add terms (2/3)**n until limit - total < 0.001, counting n
n_formula = 0      # TODO: smallest n with 3·(2/3)**n < 0.001
print("loop:", n, f"S = {total:.5f}", " formula:", n_formula)
loop: 0 S = 0.00000  formula: 0

Expected output when solved:

text
loop: 20 S = 2.99910  formula: 20

Hint: The remainder after nn terms is 3−Sn=3⋅(2/3)n3 - S_n = 3 \cdot (2/3)^n. Solve 3⋅(2/3)n<0.0013 \cdot (2/3)^n < 0.001 with logarithms (and remember that ln⁡(2/3)<0\ln(2/3) < 0 flips the inequality).

Show solution
python · try it yourself
import math

limit, total, n = 3, 0.0, 0
while limit - total >= 0.001:
    total += (2 / 3) ** n
    n += 1
n_formula = math.floor(math.log(0.001 / 3) / math.log(2 / 3)) + 1
print("loop:", n, f"S = {total:.5f}", " formula:", n_formula)
loop: 20 S = 2.99910  formula: 20

n>ln⁡(1/3000)/ln⁡(2/3)≈19.75n > \ln(1/3000)/\ln(2/3) \approx 19.75, so n=20n = 20. Convergence tests for series that are not geometric come later in tests for convergence.

Exercise 8: Binomial coefficients

Build the coefficients of (2x−1)5(2x - 1)^5 from the binomial theorem: the term with xkx^k is C(5,k)⋅2k⋅(−1)5−kC(5, k) \cdot 2^k \cdot (-1)^{5-k}. Compare with SymPy.

python · try it yourself
import math
import sympy as sp

coeffs = [0] * 6    # TODO: coeffs[k] = comb(5, k) * 2**k * (-1)**(5 - k)
print("mine :", coeffs)
x = sp.symbols("x")
print("SymPy:", sp.Poly(sp.expand((2 * x - 1) ** 5), x).all_coeffs()[::-1])
mine : [0, 0, 0, 0, 0, 0]
SymPy: [-1, 10, -40, 80, -80, 32]

Expected output when solved: both lines show [-1, 10, -40, 80, -80, 32] (from the constant term up to x5x^5).

Hint: math.comb(5, k) gives 1, 5, 10, 10, 5, 1.

Show solution
python · try it yourself
import math
import sympy as sp

coeffs = [math.comb(5, k) * 2**k * (-1) ** (5 - k) for k in range(6)]
print("mine :", coeffs)
x = sp.symbols("x")
print("SymPy:", sp.Poly(sp.expand((2 * x - 1) ** 5), x).all_coeffs()[::-1])
mine : [-1, 10, -40, 80, -80, 32]
SymPy: [-1, 10, -40, 80, -80, 32]

So (2x−1)5=32x5−80x4+80x3−40x2+10x−1(2x - 1)^5 = 32x^5 - 80x^4 + 80x^3 - 40x^2 + 10x - 1. The coefficients add up to 1, which is (2⋅1−1)5(2 \cdot 1 - 1)^5.

Exercise 9: Polar form

Convert the point (−1,3)(-1, \sqrt{3}) to polar form (r,θ)(r, \theta), then multiply the complex numbers 2∠30∘2\angle 30^\circ and 3∠45∘3\angle 45^\circ. Multiplying in polar form means: multiply the lengths, add the angles.

python · try it yourself
import cmath, math

x, y = -1, math.sqrt(3)
r, theta = 0.0, 0.0                 # TODO: r = hypot, theta = atan2 in degrees
print(f"r = {r:.4f}, theta = {theta:.2f} deg")

z1 = cmath.rect(2, math.radians(30))
z2 = cmath.rect(3, math.radians(45))
length, angle = 0.0, 0.0            # TODO: polar form of z1 * z2 (use cmath.polar)
print(f"product: {length:.4f} at {angle:.2f} deg")
r = 0.0000, theta = 0.00 deg
product: 0.0000 at 0.00 deg

Expected output when solved:

text
r = 2.0000, theta = 120.00 deg
product: 6.0000 at 75.00 deg

Hint: cmath.polar(z) returns (r,θ)(r, \theta) with θ\theta in radians.

Show solution
python · try it yourself
import cmath, math

x, y = -1, math.sqrt(3)
r, theta = math.hypot(x, y), math.degrees(math.atan2(y, x))
print(f"r = {r:.4f}, theta = {theta:.2f} deg")

z1 = cmath.rect(2, math.radians(30))
z2 = cmath.rect(3, math.radians(45))
length, angle = cmath.polar(z1 * z2)
angle = math.degrees(angle)
print(f"product: {length:.4f} at {angle:.2f} deg")
r = 2.0000, theta = 120.00 deg
product: 6.0000 at 75.00 deg

r=1+3=2r = \sqrt{1 + 3} = 2; the point is in quadrant II with tan⁡θ=−3\tan\theta = -\sqrt{3}, so θ=120∘\theta = 120^\circ. The product has length 2⋅3=62 \cdot 3 = 6 and angle 30∘+45∘=75∘30^\circ + 45^\circ = 75^\circ.

Exercise 10: A hole in the graph

f(x)=(x2−9)/(x−3)f(x) = (x^2 - 9)/(x - 3) is undefined at x=3x = 3. Estimate lim⁡f(x)\lim f(x) as x→3x \to 3 from both sides with a table, then get the exact limit from SymPy.

python · try it yourself
import sympy as sp

f = lambda x: (x * x - 9) / (x - 3)
for h in [0.1, 0.01, 0.001]:
    left, right = 0.0, 0.0           # TODO: f(3 - h) and f(3 + h)
    print(f"h = {h:<6} left {left:.4f}  right {right:.4f}")
x = sp.symbols("x")
print("SymPy limit:", None)          # TODO: sp.limit(...)
h = 0.1    left 0.0000  right 0.0000
h = 0.01   left 0.0000  right 0.0000
h = 0.001  left 0.0000  right 0.0000
SymPy limit: None

Expected output when solved:

text
h = 0.1    left 5.9000  right 6.1000
h = 0.01   left 5.9900  right 6.0100
h = 0.001  left 5.9990  right 6.0010
SymPy limit: 6

Hint: x2−9=(x−3)(x+3)x^2 - 9 = (x - 3)(x + 3), so for x≠3x \ne 3 the function equals x+3x + 3.

Show solution
python · try it yourself
import sympy as sp

f = lambda x: (x * x - 9) / (x - 3)
for h in [0.1, 0.01, 0.001]:
    left, right = f(3 - h), f(3 + h)
    print(f"h = {h:<6} left {left:.4f}  right {right:.4f}")
x = sp.symbols("x")
print("SymPy limit:", sp.limit((x**2 - 9) / (x - 3), x, 3))
h = 0.1    left 5.9000  right 6.1000
h = 0.01   left 5.9900  right 6.0100
h = 0.001  left 5.9990  right 6.0010
SymPy limit: 6

Both sides approach 6, the value of x+3x + 3 at x=3x = 3. The graph is the line y=x+3y = x + 3 with a single point missing. More on this in limits and continuity, and the full theory in limits.

Test yourself

math.asin(0.5) returns π/6\pi/6. Which other angle in [0,2π)[0, 2\pi) has sine 0.5?

  1. −π/6-\pi/6
  2. 5π/65\pi/6
  3. 7π/67\pi/6
  4. 11π/611\pi/6

What is the sum of the infinite geometric series 4+2+1+1/2+…4 + 2 + 1 + 1/2 + \ldots?

  1. 8
  2. 7.5
  3. It diverges
  4. 6

Multiplying two complex numbers in polar form…

  1. adds the lengths and multiplies the angles
  2. multiplies both the lengths and the angles
  3. multiplies the lengths and adds the angles
  4. adds both