Functions – What is a Function?

algebra-precalculusfunctionsnotation

I have been quite confused by the definition of functions and their uses..
First of all can one define functions in a clear understandable way, with a clear explanation of their uses, how they work and what they do?

Also I have some specific questions regarding functions
Let me give you a examples:

  1. $y = f(x) \rightarrow$ This is one of the main reasons I have difficulties understanding functions…
    What does the above statement tell me, and if $y$ is a function why do we use $y=$ at all for a formula like $y = mx + b$ would it be the same as writing $f(x) = mx + b$?
  2. Something like $y = x^2$ is apparently a function……
    but where is the function name? Which is the input and which is the output?
  3. Lastly another example : Let me suppose $f =$ distance
    $f(t) = t^2$
    $f(2) = 4 \rightarrow$ Does this mean distance is $4$.. which is the input which is the output?

Mainly what I'm looking for in an answer is a clear and 'easy' explanation with examples to help me understand this new topic

Best Answer

I see there are already a few answers to this question but I'm going to try my hand at answering it the way I see it.

A function $f$ is a mathematical object that relates elements of two sets, one called the domain $A$ and one called the codomain $B$. The notation $f : A \to B$ denotes the fact that $f$ is a function with domain $A$ and codomain $B$.

What it means to be a function $f : A \to B$ is this: $f$ assigns to each element of $A$ exactly one element of $B$. If $a \in A$, the notation $f(a)$ denotes the element of $B$ to which $a$ is assigned by $f$.

Those elements of $B$ which can be written in the form $f(a)$, for some $a \in A$, are called values of $f$. The set of all values of $f$ is the image of $f$, which is a subset of $B$ (and not necessarily all of $B$).


There are various ways of specifying functions. For example:

  • If $A$ is finite, you can simply list the values of $f$. For example we can define a function $f : \{ 1,2,3 \} \to \{ \text{red}, \text{green}, \text{blue} \}$ by $$f(1) = \text{green}, \quad f(2) = \text{blue}, \quad f(3) = \text{red}$$
  • Sometimes functions can be defined by an equation. An example of a function $f : \mathbb{R} \to \mathbb{R}$ is the one defined by the equation $$f(x) = x^2+3$$ This equation is not itself a function. What it means is, given an element $x \in \mathbb{R}$, the value of $\mathbb{R}$ associated by $f$ with $x$ is $x^2+3$. The expressions $f(x)$ and $x^2+3$ both denote exactly the same thing here: the real number associated with the number $x$. For example $f(2)$ denotes the same thing as $2^2+3$, which in turn denotes the same thing as $7$. The function is $f$, and $f(x)$ denotes the value of $f$ at a given number $x$.

The graph of a function $f : A \to B$ is the set $$\{ (a,b) \in A \times B : b = f(a) \}$$ Sometimes, particularly when $f : \mathbb{R} \to \mathbb{R}$, it is convenient to define a function in terms of its graph. (Indeed, $\mathbb{R} \times \mathbb{R}$ what you're depicting when you draw a pair of coordinate axes.) For example the equation $y=x^2+3$ specifies a function $f : \mathbb{R} \to \mathbb{R}$ whose graph is the set $$\{ (x,y) \in \mathbb{R} \times \mathbb{R} : y=x^2+3 \}$$ That is, the function $f$ specified by this equation is the one which associates to each $x \in \mathbb{R}$ the value $x^2+3$. Some people would then say '$y$ is a function of $x$', but this is slightly misleading: what it means is that there is a function whose values are exactly the values of $y$ satisfying the given equation.


An example of how a function works is as follows. Suppose a bird is flying in a straight line at a constant speed of $12$ metres per second. The distance the bird flies 'is a function of time', in the following sense: if $t$ is a positive real number, then the distance flown by the bird in $t$ seconds is $12t$ metres. Thus the relationship between distance and time defines a function $d : \mathbb{R}^+ \to \mathbb{R}$, which is defined by the equation $$d(t) = 12t$$ for all $t \in \mathbb{R}^+$. Thus you can consider $d$ as being the 'distance function', and for each $t$ you can consider $d(t)$ as the 'distance travelled at time $t$'.


Some non-examples of functions are:

  • $f : \mathbb{R} \to \mathbb{Q}$ defined by $f(x) = x$. This is not a function because, for example, $f(\sqrt{2})=\sqrt{2}$, which is not an element of $\mathbb{Q}$.
  • $f : \mathbb{R}^+ \to \mathbb{R}$ defined by $f(x)^2=x$. This is not a function because, for example, the expression $f(1)$ has more than one possible value satisfying the equation, namely $1$ or $-1$.
  • $f : \mathbb{R} \to \mathbb{R}$ defined by the graph $x^2+y^2=1$. This is not a function because the values of $y$ are not uniquely determined by the values of $x$, for example $0^2+1^2=1$ and $0^2+(-1)^2=1$.

In summary, if $f : A \to B$ is a function, then

  • $f$ is the function itself, which has domain $A$ and codomain $B$;
  • $f(a)=(\text{expression in terms of}\ a)$ is an equation which specifying $f$ by declaring its effect on the elements of $A$; the expression $f(a)$ is not itself a function ($f$ is the function), but a function is determined by its values, so specifying $f(a)$ suffices;
  • $y=f(x)$ is an equation that specifies $f$ in terms of its graph.

In the mathematical branch of set theory, which is used as a foundation for most mainstream mathematics, we need to specify precisely in terms of sets what it means for $f$ to be a function. In this setting, a function $f : A \to B$ is usually defined to be its graph: that is, if $f$ assigns to each $a \in A$ the value $f(a) \in B$, then we'd write $$f = \{ (a,b) \in A \times B : b=f(a) \} \subseteq A \times B$$ This formal approach isn't something you need to worry about if you're learning about functions for the first time. All that matters is that for every element of the domain $A$, $f$ identifies that element with exactly one element of the codomain $B$.


This explanation is woefully incomplete, but there's only so much you can do in an MSE answer... let me know if you need more clarifications.

Related Question