Math for AILoading progress…

Powers and exponentials

Evaluate functions, compare growth rates and read a loss curve without confusing inputs and outputs.

Three ways to grow

Linear growth adds the same amount each step: 50·n goes 50, 100, 150. Polynomial growth uses a fixed power of n: n² goes 1, 4, 9, 16. Exponential growth multiplies by the same factor each step: 2ⁿ goes 1, 2, 4, 8, 16. The difference between a power and an exponential is where n sits. In n² the variable is the base, with a fixed exponent. In 2ⁿ the variable is the exponent, with a fixed base.

n12345681020
50·n501001502002503004005001000
n²14916253664100400
2ⁿ24816326425610241048576

Early on, the exponential looks harmless: at n = 5 it is 32, less than 50·n = 250. By n = 20 it is 1048576, thousands of times bigger than the line.

The race, and the exact moment of overtaking

Change the shapes and watch who leads. The dotted vertical lines mark the moment the exponential gets ahead for good: after that point it never loses the lead again. Then try the log-scale box. On a log axis, each step up is a multiplication by 10, so a curve that multiplies by the same factor each step becomes a straight line, while a polynomial bends flat.

246810121416182005001000vertical axis: ordinary scale
line 50·n   polynomial 1·n^2   exponential 2^n
exponential is ahead of the line for good from n = 9
exponential is ahead of the polynomial for good from n = 5
at n = 10linepolynomialexponential
value5001001024
next step multiplies by1.11.212

Leader at n = 10: exponential. Dotted vertical lines mark the moment the exponential gets ahead for good.

Blue line, orange polynomial, green exponential. Turn on the log scale, then compare how the three curves bend.

Predict first. For 2ⁿ against n², the exponential ties at n = 4 (both are 16). Is it ahead for good from n = 5?

Why this matters, and the common mistake

Exponentials are how the number of possibilities explodes: 30 yes/no choices make 1073741824 combinations, and 300 make a number with 21 digits. This is why brute-force search over everything is hopeless, and why a model with a tiny extra factor per layer can blow up.

For a small exponential factor the win just comes later: 1.2ⁿ is still below n² at n = 20 (38.3376 against 400) but overtakes for good at n = 41.

The line 250·n is overtaken at n = 12; the polynomial 100·n⁵ only at n = 32.

Chapter context

A function maps an input to an output under a stated rule. Graphs let us see the same rule at many inputs; formulas let us calculate a particular output exactly. Both views should describe the same quantity and units.

Chapter reference: math, worked example & code

This section belongs to the whole chapter, so it is the same on every lesson in it and may cover a different lesson's topic. The code for the experiment you just ran is inside the experiment itself.

Math and notation

f:X→Y,y=f(x),log⁡b(bx)=x.f:X\to Y,\quad y=f(x),\quad \log_b(b^x)=x.

For the illustrative loss:

L(θ)=(θ−1.2)2≥0.L(\theta)=(\theta-1.2)^2\ge0.

Theta is a tunable scalar, 1.2 is the target, and L is a nonnegative output. An exponent and its logarithm undo each other only on their valid domains.

Worked example

Evaluate L(0)=1.44, L(2)=0.64 and L(1.2)=0. The parameter 2 gives a larger input than 0 but a smaller loss. Squaring makes positive and negative distances contribute the same penalty. This is a synthetic landscape, not a claim that real models have one simple valley.

Reference code

The following example uses the Python standard library and does not call a remote service.

from math import isclose, log2
loss = lambda theta: (theta - 1.2) ** 2
assert isclose(loss(0), 1.44)
assert isclose(loss(2), 0.64)
assert loss(1.2) == 0
assert log2(8) == 3
assert sum(i*i for i in range(1, 4)) == 14

Python examples are provided for study and local execution; this page does not execute Python.

Common mistakes

The output of a loss function is not its input parameter. Larger inputs do not always produce larger outputs. Logarithms require an explicit base when comparing information quantities.