# What is the difference between a function and a formula?

I think that the difference is that the domain and codomain are part of a function definition, whereas a formula is just a relationship between variables, with no particular input set specified.

Hence, for two functions $f$ and $g$, $f(x)$ can be equal to $g(x)$ for all integers, say, but if the domain of $f$ is {2, 3, 4} and the domain of $g$ is {6, 7, 8, 9}, the two functions will be different.

And on the converse, if the functions 'do different things' - i.e. $f(x) = x$ and $g(x) = x^3$ - but the domains of $f$ and $g$ (these are the same) are set up such that the values of the functions are the same over the domain (this would work in this case for {-1, 0, 1}), then the functions are the same, even though the formulas are different.

Is this correct?

Thank you.

• "Formula" is a loose term which doesn't actually mean anything rigorous in (most?) mathematics. – Thomas Andrews Dec 27 '14 at 20:20
• It is also possible for two functions to be the same with different formulas. For example $f(x)=x+x$ and $g(x)=2x$ are the same function on the same domain, but the "formula," at least with an intuitive definition of that term, are different. – Thomas Andrews Dec 27 '14 at 20:24

A formula is a string of symbols, arranged according to mathematical grammar.

A function is a mathematical object that plays a role in arithmetic operations like "evaluation" or "composition". A key point is that if $f$ and $g$ are expressions that denote two functions with the same domain and codomain, and we have $f(x) = g(x)$ for every $x$ in the domain, then $f$ and $g$ denote the same function.

So, in your example of functions $f$ and $g$ on the set $\{ -1, 0, 1 \}$, it is indeed true that $f=g$.

Some examples of mathematical grammar

Let $f$ be a variable that denotes a function on the reals. Let $x$ be a real-valued variable. Then:

• $f$ is a function.
• $f(x)$ is a real number.
• $x^2 + 3$ is a real number. In particular, it is not a function. Unfortunately, people are frequently grammatically incorrect on this point. :(
• $f(x) = x^2 + 3$ is an equation that relates two real numbers.

and all of the bullet points above are examples of formulas.

Recall that I mentioned functions were 'defined' pointwise: if two functions solve "$f(x) = x^2 + 3$ for all $x$" for $f$, then they must be the same function. Because of this, we can use equations like this as a way to specify functions.

But as you note, if two different formulas for the right hand side actually give the same values when you substitute values from the domain, then the functions so defined will be the same.

Incidentally, it is possible to define functions directly rather than pointwise, although it often isn't pleasant. e.g. the function $f$ defined above is given by

$$f = p \circ ((\mu \circ \Delta), c_3)$$

where I'm using the notation

• $\Delta$ is the diagonal function $\Delta(x) = (x, x)$
• $\mu$ is the multiplication function $\mu(x,y) = xy$
• $p$ is the addition function $p(x,y) = x+y$
• $c_3$ is the constant function $c_3(x) = 3$
• $(,)$ is a binary operation on functions; it's defining property is $(g,h)(x) = (g(x), h(x))$. I don't actually know of standard notation for this; sometimes I see $\times$ in place of $,$.
• $\circ$ is composition of functions: $(g \circ h)(x) = g(h(x))$.
• I think "arithmetic" in the second sentence can be confusing here. – Thomas Andrews Dec 27 '14 at 20:26

From Wikipedia

A function can be defined by any mathematical condition relating each argument (input value) to the corresponding output value. If the domain is finite, a function f may be defined by simply tabulating all the arguments x and their corresponding function values f(x). More commonly, a function is defined by a formula, or (more generally) an algorithm — a recipe that tells how to compute the value of f(x) given any x in the domain. There are many other ways of defining functions. Examples include piecewise definitions, induction or recursion, algebraic or analytic closure, limits, analytic continuation, infinite series, and as solutions to integral and differential equations. The lambda calculus provides a powerful and flexible syntax for defining and combining functions of several variables. In advanced mathematics, some functions exist because of an axiom, such as the Axiom of Choice.

• I think - a commonly written formula in science is just a "badly written" real function... If we start writing the formulae in a more elaborated way, there won't be any distinction between formula and function.. – KawaiKx Sep 28 '15 at 6:06

A function is a map from one set to another. They are the same if both the domain and the 'formula' are the same. A formula on the other hand is a word physicists and chemists like to use for a function that expresses a relation between variables that arise in nature.

• A formula can also mean something like $1+2+3+...+n=n(n+1)/2$ so I wouldn't say that this word is limited to the world of physics or chemistry. – Belgi Dec 27 '14 at 19:56
• @Begi You have a point. Based on the question, I decided that the answer should be kept as simple as possible, so I probably left out a few things. – Johanna Dec 27 '14 at 19:57
• I agree, and I think that this answer fits for this type of question. But I just wanted to mention that in high school math, simple equalities are also referred to as formulas – Belgi Dec 27 '14 at 19:59

I was taking a refresher course on Calculus and as a pre-requisite, was reviewing algebra and some pre-algebra as well :). It was said, for a function to be a function, it must have a definite output corresponding to every input. Based on that, $f(x) = x$ is a function, but $f(x) = \sqrt{x}$ is not, as there are always two answers that could be the square root of a positive number (one positive and the other negative). However, both can be called formula. I believe this is at least one key differentiator of the two.