Function
A function is a mathematical device that converts one value to another in a known way. We can think of it as a machine. You feed the machine an input, it does some calculations on it, and then gives you back another value  the result of the calculations.
 The set of allowable inputs to a given function is called the
domain of the function.
 The set of possible outputs is called the range of the function.
First create a function
The first step is to create a function. We give it a name and describe how it works inside. We write a function like this:
 The function's name is f. We can name it anything but single letters are common
 The input* value is called x. Again we could use anything but x
is common.
 On the right of the equals sign we see what the function does with the input.
Here, the function takes the input x, multiplies it by three, then gives that out as the output.
The function could do almost any calculation you like, but we have chosen a simple one for clarity.
* The input to a function is often called its 'argument', or 'parameter'.
Using the function
We can now use this function in any expression. For example
This would use the function with an input of 3. Since this function multiplies its input by three, the variable j is given the value 9.
Below is a table showing the output of f(x) for a few sample values in its domain (input).
Because the definition of f(x) says so, every output is three times the input.
Input 
Function value (output) 
3 
9 
12 
36 
2.2 
6.6 
Using a function many times
A function can be used multiple times. Using our example function again:
In this equation, the function f is used twice.
The first time with an input of 2, then again with an input of 5.
The result is that k will be given the value of 21.
In fact, this is a primary value of functions: you can 'package' a calculation as a function and the use it many times later.
Inverse functions
For some (but not all) functions, there can be another function  the 'inverse function'  that operates in reverse.
That is, given the output, it tells us what the input would have been.
For the example function above, the inverse function could be
It outputs the input divided by three.
How we say it
This 
is spoken as 

"f of x is defined as 3x" 

"j equals f of 3" 
Graphing a function
A graph of a function is a picture that shows how the input and output are related. See the example on the right for the function
It shows how the output changes as you gradually change the input.
For more on this see Graphs.
Functions in computer programming
Functions are widely used in computer programming languages and spreadsheets. They are a fundamental tool used to structure the programs and are either userwritten, or come built into the languages and spreadsheets themselves.
See Functions in computer programming.
While you are here..
... I have a small favor to ask. Over the years we have used advertising to support the site so it can remain free for everyone.
However, advertising revenue is falling and I have always hated the ads. So, would you go to Patreon and become a patron of the site?
When we reach the goal I will remove all advertising from the site.
It only takes a minute and any amount would be greatly appreciated.
Thank you for considering it! – John Page
Become a patron of the site at patreon.com/mathopenref
Other functions topics
(C) 2011 Copyright Math Open Reference. All rights reserved
