LevelUpWith

Explore / Math for AI: From Zero to Model Intuition / Lesson 2

Lesson 2: Functions: Inputs & Outputs

Learn that a function maps an input to an output, just like an AI model does.

Free to read, no account needed. Part of Math for AI: From Zero to Model Intuition.

By the end of this level you'll be able to

  • Identify the input and output of a given function.
  • Evaluate a simple function like f(x) = 2x + 1 for a given x.
  • Create a table of input-output pairs for a function.

Functions: Inputs & Outputs

Welcome back! In Level 1, we learned about variables — containers that hold values. Now we're going to see how variables can be connected in a powerful way: through functions. Think of a function as a machine that takes something in, does something to it, and gives something back.

What is a Function?

Imagine you have a vending machine. You put in a coin (the input), press a button, and out comes a snack (the output). The machine itself is like a function: it has a rule that says "if you give me a coin, I'll give you a snack." In math, a function is a rule that takes an input and produces exactly one output.

We write functions using a special notation. For example:

( f(x) = 2x + 1 )

Here, ( f ) is the name of the function (like "snack machine"), ( x ) is the input variable (like the coin), and ( 2x + 1 ) is the rule (like "give a snack worth twice the coin plus one"). The output is the result of applying the rule to the input.

Identifying Input and Output

Every function has an input and an output. Let's look at a few examples:

  • Example 1: ( g(t) = t - 3 )

    • Input: ( t ) (any number)
    • Output: ( t - 3 ) (the input minus 3)
  • Example 2: ( h(y) = y^2 )

    • Input: ( y )
    • Output: ( y^2 ) (the input multiplied by itself)
  • Example 3: ( f(x) = 5 )

    • Input: ( x ) (any number)
    • Output: always 5, no matter what the input is. This is a constant function.

Notice that the input is always the variable inside the parentheses, and the output is whatever the rule gives.

Evaluating a Function

To evaluate a function means to find the output for a specific input. We do this by replacing the input variable with the given number and then simplifying.

Example: Evaluate ( f(x) = 2x + 1 ) for ( x = 3 ).

  1. Replace ( x ) with 3: ( f(3) = 2(3) + 1 )
  2. Multiply: ( 2 \times 3 = 6 )
  3. Add: ( 6 + 1 = 7 )
  4. So ( f(3) = 7 ). The output is 7.

Let's try another: Evaluate ( g(t) = t - 3 ) for ( t = 10 ).

  1. Replace ( t ) with 10: ( g(10) = 10 - 3 )
  2. Subtract: ( 10 - 3 = 7 )
  3. So ( g(10) = 7 ).

One more: Evaluate ( h(y) = y^2 ) for ( y = 4 ).

  1. Replace ( y ) with 4: ( h(4) = 4^2 )
  2. Square: ( 4 \times 4 = 16 )
  3. So ( h(4) = 16 ).

Creating a Table of Input-Output Pairs

A table is a great way to see how a function behaves for different inputs. We list inputs in one column and the corresponding outputs in another.

Example: Make a table for ( f(x) = 2x + 1 ) for inputs ( x = 0, 1, 2, 3 ).

Input (x) Output (f(x) = 2x + 1)
0 2(0) + 1 = 1
1 2(1) + 1 = 3
2 2(2) + 1 = 5
3 2(3) + 1 = 7

So the pairs are: (0,1), (1,3), (2,5), (3,7).

Another example: Make a table for ( g(t) = t - 3 ) for inputs ( t = 0, 1, 2, 3 ).

Input (t) Output (g(t) = t - 3)
0 0 - 3 = -3
1 1 - 3 = -2
2 2 - 3 = -1
3 3 - 3 = 0

Pairs: (0,-3), (1,-2), (2,-1), (3,0).

Why This Matters for AI

AI models are like giant functions. They take input data (like an image or a sentence) and produce output (like a label or a translation). For example, a model that recognizes cats takes a picture (input) and gives a prediction like "cat" or "not cat" (output). The model's internal rules are much more complex than ( 2x + 1 ), but the idea is the same: input goes in, output comes out.

Key Takeaways

  • A function is a rule that maps each input to exactly one output.
  • The input is the variable inside the parentheses (like ( x ) in ( f(x) )).
  • To evaluate a function, replace the input variable with a number and simplify.
  • A table of input-output pairs helps us see the function's behavior.
  • AI models are essentially very complex functions that turn input data into output predictions.

A 10-question knowledge check follows this lesson in the app, free and without an account.

Keep going: levels 3 and 4 are free

Create a free account to open the next two levels, save your progress and pick up where you left off. No card needed.

Next: Level 3, Linear Functions & Slope.

Create a free account →See the whole course

More like this

  • Google Cloud Generative AI Leader Certification Exam Prep

    Master all four sections of the current Generative AI Leader exam guide at business level, with no coding, from first principles to confident scenario "best an…

    Exam prep · Google · AI & Agents · Expert · 42 levels · 4 free · Professionally curated by levelupwith.com

  • AI Coder: Claude Code & Coding Agents

    Master vibe coding and autonomous workflows using Claude Code, Cursor, MCP servers, and modern AI coding agent frameworks.

    Beyond the Obvious · AI & Agents · Capable · 18 levels · 4 free · Professionally curated by levelupwith.com

  • Introduction to Generative AI

    Learn who invented generative AI, how it works, where the technology stands today, and where it's headed — all in a quick, beginner-friendly course.

    Course · AI & Agents · AI & Agents · Curious · 7 levels · 4 free · Professionally curated by levelupwith.com

  • Architecting for Coding Agents: Prescribe vs Delegate

    Decide how much architecture to prescribe to a coding agent and how much to leave to it, working from a catalogue of named patterns and anti-patterns that each…

    Beyond the Obvious · AI & Agents · Expert · 38 levels · 4 free · Professionally curated by levelupwith.com

  • Agent-Ready Products: CLI, MCP Server or Skill

    Learn how to make an existing product or API something AI agents can find, call and recover with. You'll choose between a CLI, an MCP server and a Skill and de…

    Beyond the Docs · AI & Agents · Expert · 40 levels · 4 free · Professionally curated by levelupwith.com

  • AI Agents for Non-Developers: Understand, Try, Oversee

    Learn how AI agents differ from the chat assistants you already use, try research and browser agents safely without writing any code, and delegate tasks with c…

    Course · AI & Agents · AI & Agents · Capable · 18 levels · 4 free · Professionally curated by levelupwith.com