TITLE: What are functions used for?
QUESTION [5 upvotes]: When I say functions, I don't mean the trigonometric functions like $\sin$, $\cos$, and $\tan$, I mean defined functions like $f(x) = 2x + 4$. Why is $f(x)$ used and why isn't a single variable defined as to be equal to $2x + 4$? For instance, $n = 2x + 4$ where $x$ is defined elsewhere, say as $5$, in the same way as you'd define $x$ in the function as 5: $f(5)$. I mean to say what is the difference between these two methods that functions are used at all?

REPLY [10 votes]: The most basic benefit of having a concept of function is that it allows us to use the same function more than once in an expression with different parameter values.
For example, we could be working with two variables: $x$ is the number of days since new year's, and $y$ is the number of questions on Math.SE. Suppose we want to figure out the average number of new questions per day in February. We don't know the actual values yet (February isn't over), but we can aim to write down a formula that tells us what to do once we have the numbers. Then we need to subtract the number of questions on February 1 from the number of questions on March 1 and divide it how many days came in between. However, those two numbers of questions are both values of $y$, so if all we have is the naked variables we end up with something $\frac{y-y}{29}$ which is nonsense (or more precisely doesn't make the sense we'd like it to).
However, if we define a function $f$ by "$f(x)$ means the $y$ corresponding to day $x$", we can now write the average as $\frac{f(60)-f(31)}{29}$ which then tells us unambiguously what to do.
Alternatively, we could invent some sort of notation for using different "instances" of the same variable in a formula, something like $\frac{y_{x=60}-y_{x=31}}{29}$ -- but once we're done making that precise enough to satisfy the demands of being exact and useful in proofs, we would find that we had essentially reinvented the function concept.
More benefits. Now that we have a concept of function, we can use it to recognize similarities. If we have four variables $x$, $y$, $z$, $w$, and it turns out somehow that there is a function $f$ such that $y=f(x)$ and $z=f(w)$ for all corresponding values of the four variables, this tells us an interesting thing about the variables, namely that the relation between $x$ and $y$ is the same as the relation between $w$ and $z$. Such observations can sometimes allow us to make much quicker conclusions than if we didn't have a way to speak/think about the commonality.
Also, once we're used to thinking of functions as things in themselves, it turns out to be enormously beneficial for expressing mathematical thoughts that we can name functions, and define adjectives for properties that a function may have or not have. Since mathematics can get very complex, every trick that allows us to speak about it shorter and clearer is worth grabbing at.