Everyone's AI
Machine learningAI Papers
Loading...

Learn

🏅My achievements

Chapter 01

Functions: The Basic Unit of AI That Connects Input and Output

A function is a rule that assigns one output to each input. The way AI turns input into output is directly connected to this function concept.

Math diagram by chapter

Select a chapter to see its diagram below. View the flow of basic math at a glance.

One input x gives exactly one output y. The diagram below shows the flow x → f → y.
012340246810xy(0, 1)
Example: x = 3 gives 7 for f(x) = 2x + 1

What is a function?

A function is a strict mapping between two sets. Every element of the domain (the set of inputs) must be connected to exactly one element of the codomain (the set of outputs). Just as a vending machine is broken if pressing a button gives no drink or two drinks at once, a function must have exactly one output for each input.
We write y = f(x). Here x is the independent variable (cause) and y is the dependent variable (result). From an AI perspective, x is the data we provide (pixels, text, sensor values), and y is the prediction the AI computes. The function f acts as a transformer that turns this data into answers.
An AI model itself is a huge composite function. Input data is transformed by the first function (layer), and that result is fed into the next function (layer); this repeats dozens of times. Just as we write y=f(g(h(x)))y = f(g(h(x)))y=f(g(h(x))) in math, deep learning stacks many functions in layers to read complex patterns from data.
Because we can model the real world. A vague relation like "more study leads to better grades" can be expressed as a linear function y=ax+by = ax + by=ax+b, so we can compute expected grades (yyy) from study time (xxx). AI approximates far more complex nonlinear relations (e.g., images to object names) as functions to solve problems.
Functions are the object of optimization. The goal of AI training is to minimize the error between the correct answer and the prediction. That error is computed by a loss function, and we use differentiation to find its minimum. Without functions, there would be no mathematical basis for training AI.
They are the language of change. We need to know how much the output changes when the input changes a little (the slope) so that AI can move step by step toward the correct answer. Functions make the cause–effect relationship between input and output explicit in math, so we can analyze why the AI made a given decision.
Every neuron in AI is a small function. It takes input signals (xxx), multiplies them by weights (www) and adds (wx+bwx+bwx+b), then passes the result through an activation function to the next neuron. Functions like ReLU and Sigmoid decide whether to pass the signal on; many such small functions together make complex decisions like the human brain.
Data transformation: A photo is just a pile of numbers (xxx) to the computer. AI passes them through functions to shrink or expand dimensions and keep only key features (yyy) like "ear shape" or "eye shape." That's mapping high-dimensional vectors to a lower-dimensional space.
Probability: The softmax function at the last step of classification turns raw scores into "probabilities that sum to 1." So the AI can say "this image is 90% a dog." Functions turn raw data into information we can interpret.
  • Functionf(x)=x+1f(x)=x+1f(x)=x+1
  • Example (input → output)3 → 4, 10 → 11
  • Functiong(x)=2xg(x)=2xg(x)=2x
  • Example (input → output)3 → 6, 10 → 20
  • Functionh(x)=x2h(x)=x^2h(x)=x2
  • Example (input → output)3 → 9, −2-2−2 → 4
FunctionExample (input → output)
f(x)=x+1f(x)=x+1f(x)=x+13 → 4, 10 → 11
g(x)=2xg(x)=2xg(x)=2x3 → 6, 10 → 20
h(x)=x2h(x)=x^2h(x)=x23 → 9, −2-2−2 → 4
In the visual below, f(x) = 2x + 1 gives 7 for x = 3 and 21 for x = 10. Fill in the blank in the problem.