🌱 Beginner β€’ Mathematics

Math Foundations for AI

Starting from zero? Perfect. This guide introduces the essential mathematical concepts you'll need before diving into calculus and linear algebra. No prior math background requiredβ€”just curiosity.

⏱ 15-20 minutes

🎯 What You'll Learn

  • What a function is and why it's the heart of AI
  • Variables, constants, and mathematical notation
  • How to read graphs and the coordinate plane
  • The intuition behind "rate of change" (preparation for calculus)
  • Basic algebra: solving equations and manipulating expressions
  • What vectors are in everyday terms

1 What is a Function?

A function is a rule that takes an input and produces an output. Think of it as a machine: you put something in, the machine does something to it, and you get something out.

        Input             Function             Output
          β”‚                  β”‚                   β”‚
          β–Ό                  β–Ό                   β–Ό
        β”Œβ”€β”€β”€β”           β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”           β”Œβ”€β”€β”€β”
        β”‚ 3 β”‚  ───────▢ β”‚ Γ— 2 + 1 β”‚  ───────▢ β”‚ 7 β”‚
        β””β”€β”€β”€β”˜           β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜           β””β”€β”€β”€β”˜
        
        f(x) = 2x + 1
        f(3) = 2(3) + 1 = 7
                    

A function transforms inputs into outputs following a specific rule

πŸ’‘ Key Insight

The same input always gives the same output. If you put 3 into f(x) = 2x + 1, you'll always get 7. This predictability is what makes functions useful.

Real-World Examples

  • Temperature conversion: F(C) = (9/5)C + 32 converts Celsius to Fahrenheit
  • Pricing: cost(items) = 5 Γ— items calculates total cost at $5 per item
  • Distance: distance(time) = speed Γ— time tells you how far you've traveled

πŸ€– Why Functions Matter for AI

A neural network IS a function! It takes inputs (like an image) and produces outputs (like "cat" or "dog"). The entire goal of training is to find the right function that maps inputs to correct outputs. Everything in AI is about learning, representing, or applying functions.

2 Variables & Constants

In math, we use letters to represent numbers. This makes it easy to write general rules that work for any value.

Variables

A variable is a symbol (usually a letter) that can take different values. Think of it as a container that can hold any number.

πŸ“ Variables in Action

x = 5 β†’ x is a variable holding the value 5 y = x + 3 β†’ y depends on x, so y = 8 x = 10 β†’ now x is 10 y = x + 3 β†’ and y = 13

Constants

A constant is a value that never changes. Famous constants include:

  • Ο€ (pi) β‰ˆ 3.14159 β€” the ratio of a circle's circumference to its diameter
  • e β‰ˆ 2.71828 β€” the base of natural logarithms (very important in AI!)

Common Notation

πŸ“ Symbols You'll See

x, y, z β€” common variables a, b, c β€” often constants or coefficients n, m, k β€” often counts or indices i, j β€” loop counters ΞΈ (theta) β€” often parameters in AI Ξ± (alpha) β€” often learning rate

πŸ“ Operations

+ addition βˆ’ subtraction Γ—, Β· multiplication (or just xy) Γ·, / division ^, ** exponent (2Β³ = 8) √ square root = equals β‰  not equal β‰ˆ approximately equal

3 Graphs & the Coordinate Plane

A graph is a visual representation of a function. It shows how the output changes as the input changes. Graphs are drawn on a coordinate plane.

        y (vertical axis)
        ↑
      4 ┼─────────────────‒
        β”‚               β•±
      3 ┼─────────────‒
        β”‚           β•±
      2 ┼─────────‒
        β”‚       β•±
      1 ┼─────‒
        β”‚   β•±
      0 ┼─‒─────────────────→ x (horizontal axis)
        0   1   2   3   4
        
        This is f(x) = x + 1
        When x = 0, y = 1
        When x = 3, y = 4
                    

Each point (x, y) shows an input-output pair

Reading a Graph

  • x-axis (horizontal): represents the input values
  • y-axis (vertical): represents the output values
  • Point (x, y): means "when input is x, output is y"
  • Origin (0, 0): where the axes cross

Common Graph Shapes

   Linear (straight)     Quadratic (curved)      Exponential (growth)
   
        y                      y                       y
        β”‚    β•±                 β”‚     β•±β•²                β”‚         β•±
        β”‚  β•±                   β”‚    β•±  β•²               β”‚        β•±
        β”‚β•±                     β”‚   β•±    β•²              β”‚      β•±
        ─────→ x               │──╱──────╲──→ x        │────╱────→ x
                               β”‚β•±          β•²           β”‚__β•±
        
     y = 2x              y = xΒ²                 y = 2Λ£
                    

πŸ€– Graphs in AI

AI uses graphs constantly: loss curves show how error decreases during training, activation functions are visualized as graphs, and decision boundaries separate classes in a coordinate space. Learning to read graphs is essential.

4 Rate of Change (Intuition)

Rate of change tells you how fast something is changing. This is the core idea behind derivatives (which you'll learn in calculus), but let's start with intuition.

πŸ’‘ Real-World Examples

Speed is a rate of change: how fast your position changes over time.
Interest rate is how fast your money grows.
Learning rate in AI is how fast the model updates its knowledge.

Calculating Rate of Change

To calculate rate of change, pick two points on a graph and measure how much the output (y) changes compared to the input (x):

        Rate of change = (change in output) / (change in input)
        
             y
             β”‚          β€’ B (4, 8)     ← Point B: x=4, y=8
             β”‚        β•±
             β”‚      β•±
             β”‚    β•±  ↑ rise = 8 - 2 = 6  (B's y minus A's y)
             β”‚  β€’ A (1, 2)            ← Point A: x=1, y=2
             β”‚  └────→
             β”‚    run = 4 - 1 = 3    (B's x minus A's x)
             └─────────────→ x
             
        Rate of change = rise / run = 6 / 3 = 2
        
        This means: for every 1 unit x increases, y increases by 2
                    

We measure from point A to point B to find the rate

What Different Rates Mean

  • Positive rate: output increases as input increases (uphill)
  • Negative rate: output decreases as input increases (downhill)
  • Zero rate: output stays the same (flat)
  • Larger rate: steeper change (fast)
  • Smaller rate: gentler change (slow)

πŸ€– Why This Matters for AI

Training a neural network means finding out: "If I change this weight, how does the error change?" That's a rate of change! The whole field of deep learning is built on computing these rates (called gradients) and using them to improve the model.

5 Basic Algebra

Algebra is about working with equationsβ€”finding unknown values and manipulating expressions. Here are the essential skills you'll need.

Solving Simple Equations

The goal: get the variable by itself on one side. Whatever you do to one side, do to the other.

πŸ“ Example: Solve for x

2x + 5 = 13 Step 1: Subtract 5 from both sides 2x + 5 - 5 = 13 - 5 2x = 8 Step 2: Divide both sides by 2 2x / 2 = 8 / 2 x = 4 Check: 2(4) + 5 = 8 + 5 = 13 βœ“

Manipulating Expressions

πŸ“ Distribution

a(b + c) = ab + ac Example: 3(x + 2) = 3x + 6

πŸ“ Combining Like Terms

3x + 2x = 5x 4y - y = 3y Example: 2x + 3 + 5x - 1 = 7x + 2

Order of Operations (PEMDAS)

  1. Parentheses first
  2. Exponents (powers)
  3. Multiplication and Division (left to right)
  4. Addition and Subtraction (left to right)

πŸ“ Order of Operations Example

2 + 3 Γ— 4Β² = ? Step 1: Exponent first β†’ 4Β² = 16 Step 2: Multiplication β†’ 3 Γ— 16 = 48 Step 3: Addition β†’ 2 + 48 = 50

6 What is a Vector?

A vector is a quantity that has both magnitude (size) and direction. Think of it as an arrow pointing somewhere with a certain length.

        SCALAR (just a number)      VECTOR (number + direction)
        
              "5"                        5 units north
                                              ↑
                                              β”‚
              A scalar tells              β”€β”€β”€β”€β”˜
              you HOW MUCH
                                         A vector tells you
                                         HOW MUCH and WHERE
                    

Real-World Vectors

  • Velocity: not just "60 mph" but "60 mph heading north"
  • Force: not just "10 newtons" but "10 newtons pushing right"
  • Displacement: not just "5 km" but "5 km east"

Vectors as Lists of Numbers

In math and AI, we represent vectors as lists of numbers. Each number represents a component in a different dimension.

        2D Vector: [3, 4]          3D Vector: [1, 2, 3]
        
             y                          y
             ↑                          ↑   
           4 ┼───────‒                  β”‚ β€’ (1, 2, 3)
             β”‚     β•±                    β”‚β•±
             β”‚   β•±                      └───────→ x
             β”‚ β•±                       β•±
             ┼───────→ x              z
                   3
             
        "Go 3 units right,         "Go 1 right, 2 up,
         then 4 units up"           3 forward"
                    

πŸ’‘ Magnitude (Length)

For a 2D vector [x, y], the length is √(x² + y²).
Example: [3, 4] has length √(9 + 16) = √25 = 5

Why this formula? It's the Pythagorean theorem! The vector forms a right triangle, and the length is the hypotenuse: aΒ² + bΒ² = cΒ².

πŸ€– Vectors in AI

AI represents almost everything as vectors! A word becomes a 300-dimensional vector. An image becomes a vector of pixel values. Model parameters are stored in vectors. You'll work with vectors constantly in AI, so getting comfortable with them is essential.

🎯 Key Takeaways

  • Functions are input-output machinesβ€”neural networks ARE functions
  • Variables hold values that can change; constants stay the same
  • Graphs visualize how outputs change with inputs
  • Rate of change measures how fast something changesβ€”the foundation of gradients
  • Algebra helps us manipulate equations and solve for unknowns
  • Vectors are lists of numbers representing magnitude and direction

What's Next?

Now that you have the foundations, continue building your math toolkit: