Lensa ML
Lensa ML

How Logs & Exponentials Work

Step 1 of 6

Exponential Growth

The function that grows as fast as itself

x value1.00
x(1.0, 2.72)
x
1.0
exp(x)
2.72
SLOPE
2.72

Positive x: exponential growth kicks in. Notice the slope (yellow dashed) equals the value — exp is the only function where the rate of change equals the function itself.

Step 1 of 6: Exponential Growth

The function that grows as fast as itself

x value1.00
x(1.0, 2.72)
x
1.0
exp(x)
2.72
SLOPE
2.72

Positive x: exponential growth kicks in. Notice the slope (yellow dashed) equals the value — exp is the only function where the rate of change equals the function itself.

Step 2 of 6: The Natural Logarithm

The inverse of exp — turning multiplication into addition

x value2.72
y = xln(x)
x
2.72
ln(x)
1.001
exp(ln(x))
2.72

ln(2.7) = 1.00 — notice how ln grows slowly. The two curves are mirror images across y = x, confirming that ln is the inverse of exp.

Step 3 of 6: Multiplication → Addition

Why logarithms turn products into sums

a3.00
b4.00
LINEAR3.0a4.0b12.0a × bLOG SCALE01.10log(a)1.39log(b)2.48log(a)+log(b)
a × b
12.0
log(a)
1.099
log(b)
1.386
log(a)+log(b)
2.485

log(3.0) + log(4.0) = 2.48 = log(12.0). Logarithms convert multiplication to addition. This is why ML optimizers work with log-likelihoods — sums are numerically stable and easy to differentiate.

Step 4 of 6: Logs in Cross-Entropy

Why wrong confident predictions are punished severely

Predicted probability p0.70
p−log(p)0.250.50.751danger zone−log(0.70) = 0.36
p
0.70
−log(p)
0.357
PENALTY
LOW

At p = 0.70, the loss is 0.36. The model is uncertain — the penalty grows, pushing it to commit to the right answer.

Step 5 of 6: Exponentials in Softmax

From raw logits to calibrated probabilities

Logit A2.00
Logit B1.00
Logit C-0.50
Temperature T1.00
RAW LOGITSA2.0B1.0C-0.5↓ softmax(z / T) ↓PROBABILITIESA69.0%B25.4%C5.7%
TEMP
1.0
MAX PROB
69.0%
ENTROPY
1.106

Standard temperature range. Softmax converts logit differences into probability ratios: exp(z) amplifies gaps between logits, then normalization ensures probabilities sum to 1.

Step 6 of 6: Why We Take Logs

Log-likelihood keeps numbers stable as data grows

Observations N8
Parameter p (heads probability)0.60
DATA (coin flips)HTHHHHHHLOG-LIKELIHOODS (each observation)SUM = LOG-LIKELIHOOD-4.492PRODUCT (likelihood)0.60H × ... × 0.60H × 0.40T × ... × 0.40T = 0.607 × 0.401 = 0.011197SUM (log-likelihood)log(0.60) + ... + log(0.60) + log(0.40) + ... + log(0.40)= 7×(-0.511) + 1×(-0.916) = -4.492
LIKELIHOOD
0.0112
LOG-LIKELIHOOD
-4.492
N
8

With 8 observations, the likelihood is already 0.011197 — a tiny number! But the log-likelihood -4.49 is perfectly manageable. This is why ML always maximizes log-likelihood, not likelihood.