CompuChip said:
f has to be defined unambiguously. You are of course allowed to define a function g(y) = y - 5, but you shouldn't call it f if f is defined in another way.
Also note that the names of variables are completely arbitrary. E.g. if f(x) = 3x + 1 then you can not only substitute x = 3 to get f(3) = 3 * 3 + 1 = 10, but also x = y to get f(y) = 3y + 1 or x = a
0 to get f(a
0) = 3a
0 + 1. So the function g(y) = y - 5 can also be written as g(x) = x - 5. Therefore you are not allowed to say
f(x) = 3x + 1 and f(y) = y - 5
because that would give two different definitions to the same function.
This is an interesting point and I want to continue a bit on it. What CompuChip is saying is that the functions f(x)=x+5 and f(y)=y+5 are the same thing. In textbooks you will often encounter the phrase that x is a "dummy variable". This means that you can change x in any other symbol (that's not used already) and that the function won't change.
Now, why is this? Well, remember that a function is essentially a set. What set is the function f(x)=x+5. By definition is a subset of ##\mathbb{R}\times \mathbb{R}##. Which subset?
f=\{(x,x+5)~\vert~x\in \mathbb{R}\}\subseteq \mathbb{R}\times \mathbb{R}
When we claim that the variable x and y can be interchanged, then we actually say that we have the following equality of sets:
\{(x,x+5)~\vert~x\in \mathbb{R}\} = \{(y,y+5)~\vert~y\in \mathbb{R}\}
This equality can be checked directly. Indeed, take an element in the left hand side and show it is in the right hand side and vice versa. For example, take an arbitrary element of the left-hand side, this has the form ##(x,x+5)## for a certain ##x\in \mathbb{R}##. Define ##y=x##, then ##y\in \mathbb{R}##. Furthermore, we have that ##(y,y+5)## is in the right-hand side (by definition) and that ##(x,x+5) = (y,y+5)##. So ##(x,x+5)## is in the right-hand side too.
Showing that an element on the right-hand side is in the left-hand side is analogous.
Now, the above is a bit imprecise. Take two functions ##f:A\rightarrow B## and ##g:C\rightarrow D## are the same thing if
\{(x,f(x))~\vert~x\in A\}= \{(x,g(x))~\vert~x\in C\}
This is nice and it works suitably well. But usually we
also demand that ##A=C## and that ##B=D##. This has a few consequences that can look weird at first. For example, take ##f:\mathbb{R}\rightarrow \mathbb{R}:x\rightarrow x^2## and ##g:\mathbb{R}\rightarrow \mathbb{R}^+ = \{x\in \mathbb{R}~\vert~x\geq 0\}##.
We can see easily that the following equality holds:
\{(x,f(x))~\vert~x\in \mathbb{R}^2\}= \{(x,g(x))~\vert~x\in \mathbb{R}\}
so the graphs of the function are the same and the functions behave the same way. However, the functions are not the same thing, since the codomains of the functions are different.
I agree that this is very weird when you first encounter this. But it makes the life of the mathematician a lot easier!