Skip to main content

Function

Function Definition

A function is something that takes in an input, and gives back an output. That seems pretty vague, so I'll provide an example.

f:RRx2x\begin{aligned} f:\,&\mathbb{R} \rightarrow \mathbb{R} \\ &x\mapsto 2x \end{aligned}

These functions all do the same thing: take in a number, double it, and spit out the doubled result.

As you can see by switching between the tabs, some examples are more strict at ensuring only numbers can be passed as their input, but they all share the same core logic.

Function Call

We've defined what a function is, but what's more important is what a function does. A function call is the term prescribed to actually using a function. A good way to remember: imagine you're calling the function over to do something with a specific value.

f(5)=10f(5) = 10