# Functions

### Function Calculator

$f(x)=$

$x=$

### What is a Function?

Think of functions like a vending machine. When you enter in a code, you get a soda. Same with a function, when you enter in an input number, you get an output number. Try it out!

big red

A1

incakola

A2

yakult

A3

kuat

A4

sprite

A5

big red

B1

incakola

B2

yakult

B3

kuat

B4

sprite

B5

big red

C1

incakola

C2

yakult

C3

kuat

C4

sprite

C5

big red

D1

incakola

D2

yakult

D3

kuat

D4

sprite

D5

###### Invalid Input

1

1

4

2

9

3

16

4

25

5

1

-1

4

-2

9

-3

16

-4

25

-5

36

6

49

7

64

8

81

9

100

10

36

-6

49

-7

64

-8

81

-9

100

-10

###### Invalid Input

Just like a vending machine maps inputs to outputs, a function is a mapping between a set of inputs and a set of outputs.

### Function Rules

Notice a couple things:

- A function (or vending machine) take in an input and returns an output.
- Every input has only ONE output - when you input A1, you only get Big Red, nothing else. And when you input 3, you only get 9, nothing else.
- Multiple inputs can have the same output. To get Inca Kola, you can put in A2, B2, or C2. And to get 9, you can input 3 or -3.
- Every possible input on our keypad has an output. There are some numbers/codes that aren't on our keypads, like E1 or -15, but that's okay. We define a set of inputs, like our keypad, and we just need to make sure every input is covered.

### Function Examples

In non-vending machine language, we write functions as something like

$f(input)=output based on input$We represent our input with a variable, like $x$, and our output is a calculation that uses our input, or variable. So, something like this:

$f(x)=x_{2}+3x+1$So, when we input 2, all our $x$'s are replaced with 2, and our output comes out to be 11:

$f(x)f(2)f(2)f(2) =x_{2}+3x+1=2_{2}+3(2)+1=4+6+1=11 $Just like our vending machines!