Lesson 1 of 2 · Exponents and Logarithms

Exponents and the exponential function

The laws of exponents, the exponential function \(e^x\) and its properties, and exponential growth and decay, leading to the Softmax function, which turns scores into probabilities.

Mathematical foundations Difficulty: Beginner Study time: 35 min
Lesson contents
  1. Introduction
  2. Why study this topic?
  3. Theoretical explanation
  4. Mathematical definitions
  5. The equations
  6. Worked example
  7. Application in AI
  8. Interactive lab
  9. Practice exercises
  10. Summary
  11. Short quiz
  12. Related lessons

1 Introduction

An exponent abbreviates repeated multiplication: \(a^n = a\cdot a\cdots a\). The exponential function \(e^x\), where \(e \approx 2.71828\), is unique in that its derivative equals itself.

Learning objectives

  • Applying the laws of exponents
  • Knowing the properties of the exponential function
  • Computing Softmax for a small vector
  • Understanding exponential growth and decay

2 Why study this topic?

Softmax in classifier outputs and in attention is built on \(e^{z}\). Exponentially decaying learning rates, the exponential moving averages in Adam and batch normalization, and the density of the normal distribution are all exponential functions.

3 Theoretical explanation

Laws of exponents

LawFormula
Product\(a^m a^n = a^{m+n}\)
Quotient\(a^m/a^n = a^{m-n}\)
Power\((a^m)^n = a^{mn}\)
Zero exponent\(a^0 = 1\)
Negative exponent\(a^{-n} = 1/a^n\)
Fractional exponent\(a^{1/n} = \sqrt[n]{a}\)

Exponential function

\(e^x\) is always positive and increasing, \(e^0 = 1\), \(e^{a+b} = e^a e^b\), and \(\frac{d}{dx}e^x = e^x\).

Growth and decay

\(N(t) = N_0e^{kt}\): growth if \(k \gt 0\) and decay if \(k \lt 0\). The discrete decay \(\eta_t = \eta_0\gamma^t\) with \(0 \lt \gamma \lt 1\) describes learning rate schedules.

Softmax

\[\operatorname{softmax}(\mathbf{z})_k = \frac{e^{z_k}}{\sum_{j} e^{z_j}}\]

The exponential makes every value positive, and the division makes them sum to 1. Subtracting the same constant from all the scores does not change the result: \(\operatorname{softmax}(\mathbf{z} - c) = \operatorname{softmax}(\mathbf{z})\), and this is the numerical stability trick.

Exponential growth eˣ and exponential decay e⁻ˣ

4 Mathematical definitions

Exponential function
The function \(e^x\), whose derivative equals itself and whose value at zero is 1.
\[e^x = \sum_{n=0}^{\infty}\frac{x^n}{n!}\]
Softmax
A function that turns a vector of scores into a probability distribution.
\[\operatorname{softmax}(\mathbf{z})_k = e^{z_k}/\sum_j e^{z_j}\]
Softmax function
A function that turns a vector of real scores into a probability distribution by exponentiating and then dividing by the sum.
\[\operatorname{softmax}(\mathbf{z})_k=\frac{e^{z_k}}{\sum_je^{z_j}}\]

5 The equations

\[a^m a^n = a^{m+n}\]
Multiplying powers
\[\operatorname{softmax}(\mathbf{z})_k = \frac{e^{z_k}}{\sum_j e^{z_j}}\]
Softmax
\[\operatorname{softmax}(\mathbf{z} - c\mathbf{1}) = \operatorname{softmax}(\mathbf{z})\]
Shift invariance

6 Step-by-step worked example

Computing Softmax

Problem: Compute Softmax for the scores \(\mathbf{z} = (2, 1, 0.1)\).

  1. The exponentials: \(e^2 \approx 7.3891\), \(e^1 \approx 2.7183\), \(e^{0.1} \approx 1.1052\).
  2. The sum is \(\approx 11.2125\).
  3. Divide by the sum.

Result: \(\approx (0.659, 0.242, 0.099)\), which sums to 1.

7 Practical application in AI

  • Softmax: Turning classifier logits and attention scores into probability weights.
  • Exponential moving average: In Adam and batch normalization the weights of old values decay exponentially.
  • Learning rate schedules: Exponential decay \(\eta_0\gamma^t\).

8 Interactive lab linked to the lesson

Plotting functions, computing the derivative numerically and drawing the tangent, partial derivatives and the gradient of a two-variable function, the chain rule step by step, and numerical integration with the trapezoidal and Simpson's rules.

Open the Calculus Lab

9 Practice exercises

Review questions for reflection

  • Why does subtracting a constant from all the scores not change the Softmax output?
  • What happens to Softmax if we multiply all the scores by 10?

Common mistakes

  • Writing \(a^m a^n = a^{mn}\).
  • Believing that \(a^{-n}\) is negative.
  • Computing Softmax directly for large values, which overflows; subtract the maximum first.

Practice 6 questions from the question bank for this lesson

10 Lesson summary

  • \(a^ma^n = a^{m+n}\) and \((a^m)^n = a^{mn}\).
  • \(e^x\) is positive and its derivative equals itself.
  • Softmax = exponentiate, then normalize.

11 Short quiz

5 questions · 10 minutes · pass mark 60% — passing it completes the lesson.