Velamuvi AIAcademy

Lesson 1 of 12 · Numbers and Algebra

Why AI Needs Maths

See why maths sits at the heart of AI, which areas of maths matter most, and why you do not need to be a maths genius. Includes a tiny machine learning model in Python.

  • 6 min read
  • Beginner
  • Reviewed
In this lesson you will learn
  • Why every AI model is, underneath, a maths function
  • How data becomes numbers a computer can learn from
  • The four areas of maths that AI uses most
  • How much maths you really need, and how this course helps

AI is maths that learns

When a phone recognises your face, or a chatbot writes an answer, it can feel like magic. Underneath, it is something much more ordinary: numbers going in, calculations happening, and numbers coming out.

A tiny model you can run

Here is a complete, very small "AI model" for house prices. It has just two parameters: a price per square metre and a base price.

Try it yourselfPython
price_per_m2 = 50000      # parameter 1, in rupees
base_price = 200000       # parameter 2, in rupees


def predict_price(size_m2):
    return price_per_m2 * size_m2 + base_price


for size in [40, 75, 120]:
    print(f"{size} m² -> Rs {predict_price(size):,}")

That is the whole model: one line of maths, price = 50000 × size + 200000. Real models have millions or billions of parameters, but the idea is exactly the same. Training means letting the computer adjust the parameters until the predictions match real prices as closely as possible.

Everything becomes numbers

A model can only do maths on numbers. So before any learning happens, everything is turned into numbers:

Real thingAs numbers
A house[75, 3, 2]: size, bedrooms, bathrooms
A colour photoa grid of pixels, each with red, green and blue values from 0 to 255
A worda list of numbers, called an embedding, that captures its meaning
A songthousands of sound-wave heights per second
Try it yourselfPython
# One small greyscale image: 0 is black, 255 is white
image = [
    [0, 255, 0],
    [255, 255, 255],
    [0, 255, 0],
]

total = 0
for row in image:
    total += sum(row)

print("Pixels:", len(image) * len(image[0]))
print("Average brightness:", round(total / 9, 1))

Once data is numbers, maths can find patterns in it.

The four areas of maths in AI

AreaWhat it does in AIExample
Linear algebrastores and transforms lots of numbers at oncean image is a grid of numbers, called a matrix
Calculustells a model which way to change its parameters to improvegradient descent, the engine of training
Probabilitymeasures uncertainty"90% sure this email is spam"
Statisticsdescribes data and tests whether results are realaverages, spread and whether a model really improved

This course builds the foundations that all four rest on: numbers, equations, exponents, logarithms, functions, graphs and the notation used in AI papers.

How much maths do you really need?

Less than you might fear. The computer does all the heavy arithmetic. What you need is to understand what the maths means, so you can:

  • choose the right method and settings
  • read documentation and research papers
  • understand why a model is not learning, and fix it

Every idea in this course is explained in plain words first, then shown with a picture or a graph, and then turned into Python code you can run.

Common mistakes

Practice exercise

Write and use your own tiny prediction model.

Your solutionPython
# A tiny model that predicts a student's exam score from hours of study:
#   score = 6 * hours + 40
# 1. Write a function predict_score(hours) that returns the score.
# 2. Print the prediction for 2, 5 and 8 hours, in this format: 2 hours -> 52

# Output must be exactly:
# 2 hours -> 52
# 5 hours -> 70
# 8 hours -> 88
Knowledge check

What does training a model mean?

Summary

  • A model is a maths function with parameters. Its outputs are predictions.
  • Training adjusts the parameters until the predictions match real data.
  • All data, from photos to words, is turned into numbers first.
  • AI uses linear algebra, calculus, probability and statistics, all built on the foundations in this course.
  • You need to understand what the maths means. The computer does the arithmetic.

Next: a friendly refresher on numbers and the operations you can do with them.

Finished reading? Tick it off to track your progress.