Source codeVideos

Command Palette

Search for a command to run...

What is a Function?

Imagine you have a magic machine. This machine has a special task: every time you put something in (let's call it input), the machine will produce exactly one other item (let's call it output) according to a specific rule. Well, this magic machine is what we call a function in mathematics!

So, a function is a special rule that connects each member of one group (set) to exactly one member in another group. The key is the phrase "exactly one". Each input can only have one output.

Function Notation

Usually, a function is written in the form f(x)=yf(x) = y.

  • ff -> This is the name of the function (think of it as the name of the machine). You can also use other letters like gg or hh.

  • xx -> This is the input variable. Think of this as the item you put into the machine.

  • yy -> This is the output variable. This is the item that comes out of the machine after processing. The value of yy depends on the value of xx entered and the rule ff. So, yy is often written as f(x)f(x) (read: "f of x").

Analogy

To make it easier to imagine, look at this analogy:

Function Machine Analogy
Input a number into the machine, and the machine will output the result.
f(x)=2x+1f(x) = 2x + 1

Above is an example of an interactive function machine. Try changing the input value (xx) at the bottom, and observe how the output value (f(x)f(x)) changes according to the function rule f(x)=2x+1f(x) = 2x + 1.

Simple Example

Suppose we have the function f(x)=x+2f(x) = x + 2. This means the rule of the machine ff is "add 2" to every input xx.

  • If the input is x=3x=3, the output is f(3)=3+2=5f(3) = 3 + 2 = 5.
  • If the input is x=1x=-1, the output is f(1)=1+2=1f(-1) = -1 + 2 = 1.
  • If the input is x=0x=0, the output is f(0)=0+2=2f(0) = 0 + 2 = 2.

Each input (3, -1, 0) has exactly one output (5, 1, 2). This is the hallmark of a function!