What is the difference between 'formula' and 'function'? I hope this question fits in this site. I was asked by my student when I was explaining the concept of relation and function and after thinking, I still can't differentiate those two concepts (formula and function). I've looked for the answers from other sites and I have read these:

*

*what-is-the-difference-between-a-formula-and-a-function

*difference_between_function_and_formula
The first link above tells us

'The difference between a formula and function is that a formula is defined as the statement used for the calculation [a]. These formulas
could be simple or complex and always start with equal to operator [b].
While function is defined as the code that is designed for the
calculations and is used inside the formula [c].'

We know a function can be used to calculate to find the result of the calculation from the range with the given number taken from the domain [a]. For instance, the exponential function
$$P(t) = P_0e^{kt}$$
can be used to calculate the population in the region X.
A function also has the equal sign, because if it doesn't, I'd say it's an expression [b] & [c]. And I don't know about the relevancy of the second link since the context is used in Excel. But it says that

Formula(s) is/are nothing but doing some arithmetic operation(s) or
calculation(s).

Does that mean these are formulas?:
$$2+2=4\quad 5-3=2\quad 2(3+5)/4=4$$
How to tell to my students about their difference? Are the exactly the same concept? I have a class tomorrow and I've promised to answer their question that day.
 A: In my estimation, you are asking two different questions here. The one about what might tell your students is easier to answer, but there are lots of different answers that are reasonable. Here is what I would say to, e.g., a college student in any course before linear algebra:

A function is a machine that takes in numbers and spits out other numbers. A formula is a mathematical expression that I can use to calculate. Functions are more general objects than formulas, because not every function can be written as a formula. My favorite example is the floor function, which works like this: it takes in a number, cuts off the decimal, and spits out the whole number that's left over. [examples]. This function makes perfect sense, even though I can't write down a "formula" for it like x^2 or $\sin(x)$.

None of the first three sentences are true (the fourth one is!), even to the extent that they are meaningful. But the lies are mild, and they help simplify the language to get the point across.

The second question is what the difference actually is. I will not come to any forceful conclusion on this question, but instead frame my thoughts as a series of remarks.
Remark 1. This question has been discussed a lot on MSE, because, as you have observed, it is subtle, and it concerns relatively elementary objects. Exactly which question it is a duplicate of is not totally clear, though.
Remark 2. I can't open the first link, but based on the language used, it kind of sounds like this source is using the programming definition of a 'function', which differs in a subtle way from the mathematical definition. In particular, we usually do not agree with [c]: for us, the function is the encapsulating object, and there are various methods by which a function's values may be given, one of which is a formula (see this Wikipedia quote)
Remark 3. Continuing on this, you write

We know a function can be used to calculate to find the result of the calculation from the range with the given number taken from the domain [a]...

I know no such thing. A function may encode a calculation (or it may not!) but it is odd to me to say that we use a function to calculate elements in its range. For instance, in your example I would not say I am using the function $P$ to calculate $P(3)$; I guess I can see why you would say this, but it doesn't reflect how the calculation actually proceeds. When I am actually getting around to doing the computation, what I am using is the expression $P_0e^{kt}$ by substituting $t=3$. The result of this calculation is certainly in the range of $P$; this is guaranteed by the equation $P(t)=P_0e^{kt}$... indeed this equation is what convinced me to use the expression to compute $P(3)$.
Remark 4. The word "formula" did not appear in the previous remark, what's up with that? Well, in casual speech, I would describe both $P(t)=P_0e^{kt}$ and $P_0e^{kt}$ as formulas for $P(t)$. If I am required to be more careful, I would not use the word at all.
Remark 5. Logicians have strong opinions about [read: a definition of] what a "formula" is, that does not align well with the common-language meaning, despite being related. (The tension is well-illustrated by this answer.) To answer your question, the three equalities in your question undoubtedly are formulas if we are using the logician's definition. Still, I would not call them formulas because for me a formula needs to be something that I can compute with; those equalities look to me like a "record" of a computation that has already been completed.

As this answer has now been accepted, let me highlight
Mauro Allegranza's very useful comment [emphasis mine]:

The simplest explanation is in the answer to the linked post: "A formula is a string of symbols, arranged according to mathematical grammar [i.e. an expression of the mathematical language]. A function is a mathematical object." The clear distinction is that between the world of (mathematical) objects and the language used to speak of them (exactly like natural language). –

A: The difference between a formula and a function is like the difference between the word "Earth" and the planet Earth. A formula is something formed by combining mathematical symbols in a syntactically valid way. A function is a relation mapping each element from the domain to an element in its range. A formula can define a function.
For example, $1 + x$ is a formula because it combines the symbols '1', '+' and '$x$' in a valid way; and this formula defines a function which relates each number to the number which is 1 larger than it. On the other hand, $x + 1$ is a different formula, because the symbols are combined in a different way; however, this different formula defines the same function because it relates numbers to each other in the same way.
Perhaps a clearer example is the prime-counting function, which is certainly a function, but the phrase "the prime-counting function" is not a formula, because it combines English words, not mathematical symbols. In fact, almost all functions are not defined by any formula, because there are uncountably many functions $: \mathbb{N} \rightarrow \mathbb{N}$ (just taking $\mathbb{N}$ as an example for the domain and range) but only countably many formulae (each of which is a finite sequence of symbols chosen from a finite alphabet).
A: A function $f$ is a triple, consisting of a domain $D_f$ (a set), a set of values $V_f$, and a relation $R_f$, i.e. a subset of $D_f \times V_f$, which has the additional condition that for any element $d \in D_f$, there is only one element in $R_f$ which has this particular element $d$ as first component.
That's the mathematical definition of a function. The intention is:
$D_f$ defines all possible inputs; $V_f$ is a set containing all possible outputs, and $R_f$ contains all pairs of $(d,v)$ where $d$ is an input and $f(d) = v$, i.e. $v$ is the output belonging to the input $d$. The condition described above means that for any input there is only one output.
There is no mention at all of any formula, because there is no need for this. As Eric Nathan Stucky has mentioned, there are a lot of functions that cannot be described with a formula.
If you have a formula, you are in the lucky situation that you have a way of calculating your function values. Although I've never before heard the word "formula" in this context; to me the word would be "function term".
A: Best illustrated by examples.
$$y(x)=ax^2+bx+c$$
is a particuar function among many. Satisfied only by two x values when $ y(0)=0$
$$\sin (a+b)=\sin a\cos b+\cos a \sin b $$
is a formula/ identity satisfied by any values of $(a,b).$
The difference comes from arbitrariness of chosen variables.
A: What to tell your students
In math class, a function is a restricted kind of relation between two sets. For the sake of simplicity we'll call these sets "domain" and "range". A relation is a function when, for any given element of the domain, there is at most one related element of the range. (There are other names for these sets in use. These are the names I learned in school.) Also, most functions do not have names, but some few do. An example is cosine.
A formula is a (valid) sequence of symbols in some formal language. Most of the formulae we work with in this class are of the algebraic type, so they involve numbers, variables, operators, and the occasional function. Ordinarily, you'll interpret or manipulate a formula in order to draw some conclusion.
Often a function may be defined by a formula. For example, the function square(x) may be defined as x*x.
In other contexts, these terms may be used slightly differently. Ask a chemist about functional groups, for example.
