Are functions in maths “pure”

computer sciencefunctions

In computer science, some functions are said to be "pure", meaning that (amongst other things) they can only use variables defined in their parameters. In a mathematical context, are all functions pure or is something like this allowed?: $$
a = 3 \\
f(x) = x + a
$$

If this is allowed, then does this mean "variables" (e.g. $a$ in this case) is immutable? (also is this true even if math functions are pure?)

Best Answer

Well, variables in math are not really containers as in programming. You might think of them as rather being constants, in the computer science sense, but they are called variables because their meaning can vary, e.g. $x \in \mathbb{R}$ can be any real number, but it's just one (or rather, it's all of them), it doesn't change overtime.

In a function, the argument varies depending on what is actually "passed" to the function, to use a CS term, but again, it doesn't change at all. Not the function, nor anything else changes what a specific letter refers to after being defined (as in "Let $n \in \mathbb{N}$" or as in "$f : \mathbb{R} \to \mathbb{R}$" which also defines what $x$ in "$f(x) = x+3$" is).

Now, every other variables than the arguments of a function or the unknowns of an equation are called parameters. In your example, $a$ is a parameter.

So, yes, you could say that functions in math are 'pure', but that is a CS term afaik.