Formula, expression, equation, function. What's the difference?

Are they all (more-or-less) interchangeable terms in mathematics?

An expression is a combination of symbols according to some well-defined rules. In common use, it is a representation of a sequence of arithmetic operations, although in different areas of mathematics it can represent other things.
Example: (x+3)[sup]2[/sup]

An equation, as the name implies, contains an equals sign, and states that two expressions are equal.
Example: (x+3)[sup]2[/sup] = 2y
Note that the value of an expression is a number of some sort, while the value of an equation is either “true” or “false”.

There are many ways to define a function. In essence, a function is a conceptual machine which takes some value as input and produces a corresponding value as output. It must always produce the same output when given the same input, and it must produce only one output for a given input.
Example: f(x) := (x+3)[sup]2[/sup]
I’m deliberately not using the normal equals sign in this function definition to avoid confusion with an equation, although usually an equals sign is used. This is not just stating that the left side is equal to the right side, it’s saying the function is DEFINED to be the right side. Given this defintion, f(0) = 9, f(1) = 16, etc.

Formula is a more vague or informal term. It could mean expression or equation or even function, depending on the context.

I want to add that while a function is often defined by an expression, it needn’t be. If the domain of the function is finite, you could just list all the inputs and outputs:



f(1) := 6
f(2) := 6
f(3) := 7
f(4) := 9
f(5) := 7
f(6) := 6
f(7) := 8


This function outputs the length of the English name of each day of the week. It’s a valid function even though it’s not defined by an expression.

1 := 5
3 := 111
5 := 3.1415926…

This is also a function. A very limited one, with three elements in the domain, and three elements in the range. Not really expressible as an expression.

Actually it’s always possible to express a function with a finite domain as an expression. This illustrates a simple but tedious technique:

f(x) := 5(x-3)(x-5)/(1-3)(1-5) + 111(x-1)(x-5)/(3-1)(3-5) + 3.1415(x-1)(x-3)/(5-1)(5-3)

The (x-n) factors ensure that each term is zero except when needed, and the denominators correct the value, if you see what I mean.

This is true as far as it goes but also it represents a value.

(Also, in most programming languages an assignment statement is written in the form of an equation but it is not an equation. But I don’t think the OP is asking about that.)

Most of the above is biased towards programming.

Worth mentioning, that usually a function only has one value at any given location. Functions have a domain and range - the domain being those values for which the function is defined, and the range being those values that the function can return. For instance the sine function has a domain from -infinity to + infinity, but a range of -1 to +1.
A circle is not a function, since it has two values at most values in its domain.

An expression can be almost anything. You will hear a mathematician say something along the lines of, “… long winded hand waving explanation of a concept…” and then say “and we can express this like this…” and then write down a set of squiggles, that within the domain being discussed capture the idea in a formal form. In particular, a form that can be manipulated with the rules defined for that domain. This may well include equations, and usually does. You will often see a lot of backwards Es and upside down As.

Equations are the magic. Once you have an equation, and you have the manipulation tools, you can transform the equation. This will often involve the substitution of other equations into your first equation, or the application of other manipulations. The golden rule being - whatever operation you apply to one side of the equation, you do to the other.

In programming languages, we were stuck with just the equals sign. So many languages - Fortran, C etc, used it to denote assignment. (Then they use things like .eq. or == for the equality operator.) Some languages (eg Pascal) used := to denote assignment, and the := operator was pronounced “becomes”. I tend to always pronounce the assignment operator “becomes” no matter what language I am coding in. Classic horrible typo in C syntax languages (which is most of the popular ones now) is to mistype == (the equality test) as = , which is often legal, but instead of returning the result of a comparison, returns the RHS of the expression.

And I used the word “expression” in a programming context. One thing you will very often see is that the syntax of programming expressions (usually an R-value - something that can appear on the right hand side of an operation) is defined using a recursive syntax that uses the three basic components - expression , term, factor. Here expression has an exact syntactic definition.

In most programming languages the distinction between L-value and R-value is fundamental. L-values can be assigned to, R-values are values that can be assigned. Sometimes the precise distinction can be unclear, depending upon the language. (Can you write 2 = 5 ? - In some languages you can, and henceforth any use of the value 2 will have the numeric value 5. Can you write a* = b* ? Sometimes you may discover that a* is only an R-value. Hilarity tends to not ensue.)

This is why I love the Dope. :slight_smile: Thank you for the responses.

An equation has the equals sign with LHS and RHS… the sides could be anything and 0, 1 or 2 or more variables. When the equation has one variable on its own on one side, then the other side might be a function (basically you can work with it on the assumption it is a function… because maths is so full of expressions that are functions… for example, if the right hand side is square root of (Something), well its not clear if its a function or not, as the right hand side has a + and a - possibility … One or both might be valid… but you can work with the +ve or -ve You should probably always note that you rule out one value as absurd … or note that its equally valid… as the case may be )

I think most of the above is based on definitions from mathematics. I was careful to mention programming parenthetically and specifically point to it as such.

Not usually. A function must have no more than one value for a given input value. That is by definition. Your explanation seems to bear that out. (If it has more than one value for an input then it is a relation, not a function.)

Although, while a function must have only one value for each set of inputs, that one value might well be a set, sequence, or tuple. So one can define sqrt, for instance, to be a function whose value is the set of square roots of its input, so that sqrt(4) = {2,-2}, for instance. Or one might have a function to convert between polar and Cartesian coordinates, such that polar(0,1,0) = (1,pi/2,pi/2).

You can also define a function to return a value lying in a torsor, which means that it is equivalent to an infinite number of values from the group we’ve defined the torsor in terms of.

Believe it or not, we do this all the time.

Voltages always lie in a torsor, in this case an R-torsor, because R means Real numbers, and voltages look like Real numbers if you’ve forgotten the simple trick: The zero is arbitrary. Therefore, you can add or subtract any number from a voltage depending on your choice of ground. Only differences between two voltages, or ratios between two voltages, are meaningful. To get more esoteric, phase in quantum wavefunctions is the same way: Absolute phase is meaningless, or arbitrary, and only relative phase has a physical reality.

We can use this as an entry point to expand our idea of what a function is. For example, the antiderivative operator returns, not functions, but objects in a function torsor, because you can always add an arbitrary constant to what you get and the result is also a valid antiderivative. Derivatives take these things and make them functions, because the derivative of a constant function is always zero. It removes the ambiguity. (Definite integrals don’t return members of a torsor because fixing the endpoints removes the ambiguity as well.)

Of course, once you expand your definition of what a function is to include more complex operations, the next step beyond that is to define functions in terms of algorithms, at which point you get into computability theory, and fascinating things like the Busy Beaver function.

Heck, it doesn’t even have to be numeric.

f(cat) := dog
f(salt) := pepper
f(1) := 0

is a perfectly fine function so long as the objects cat, dog, salt and pepper are well defined. I like to think of a function as a machine that takes something in and puts something out, and any time you put the same thing in, the same thing comes out. But as far as what goes in, what comes out, or what happens in the middle it doesn’t matter so much/

I’ve mentioned before that the way to tell the difference between a mathematician, a physicist, and a computer programmer is to ask which of the following three is a function: The Dirac function, the Dirichlet function, or the printf function.

:smiley:

Dirac was why I wrote “usually” above. I will remain agnostic about the acceptability of this :slight_smile:
On the programming side it is worth noting that some languages either support or enforce the notion of a pure function. That is a function that has no side effects. It does not change global state or the state of any of its parameters, only returning a value. This is of particular practical value when optimising and parallelising code.

I hope this is not too much of a sidetrack but I have always disliked the de facto-industry-standard practice, especially in C, of writing a procedure then turning it into a function that returns a boolean to indicate whether it was successful. The entire function is one big side effect.

Status returns are one of things people get religious about.

It isn’t any sort of industry standard, but it you do see it in all sorts of guises, and it is often more related to the operating system standards.

VMS used to return an integer on all system and library calls.
You see many languages now use an exception handler. But you get questions about the use of this, as under some systems exceptions are really expensive, whereas on others they are cheap. gain, VMS had a very complex exception handling system, and much of this was inherited by NT.

Unix has a whole mess. Status returns, exceptions, and the wonderful global errno.

Overall it does underline the point that programming functions have little to nothing to do with mathematical ones. The function status return design always ran into trouble when a proper function needed to signal an error. I have seen more than a few such functions where the result was either the right answer, or a reserved bad value indicating an error. One gets very tired of programming in such systems.

Well, multi-valued functions are a thing, particularly in complex analysis, where you may have to deal with branch cuts of logarithms. But in these cases, what’s really the output of the function is an equivalence class. If there are multiple possible outputs of a function, they will all be related to each other by an equivalence relation, perhaps as simple of one as “they are equivalent if they are both outputs of the function”, but usually ones that are a bit more interesting, like the previously mentioned antiderviative.

Status returns in programming are (roughly) an example of in-band signaling. With all the evils appurtenant thereunto.

Until / unless something more structured, e.g. exceptions, are provided at the very depth of the kernal and used all the way up to the surface we’re stuck with the mishmash.

This also highlights the point that computer functions are a Leaky abstraction - Wikipedia of mathematical functions. Just as computers are leaky abstractions of math.

Although, sometimes the computer abstraction is more watertight than people would like. For instance, in most constructions of various sorts of numbers, the real number 1.0 is not the same object as the integer 1 (it’s a closely-corresponding object, but not the same). Now, in most mathematical contexts, we can ignore that distinction… but it’s a necessary distinction in most programming languages.