When going through some (very introductory) calculus homework I was given the function $f(x) = \frac{x}{1+x}$ and asked to find the composition $(f\circ f)(x)$ and then find its domain. Substituting, we find that $$(f\circ f)(x)= \frac{\frac{x}{1+x}}{1+\frac{x}{1+x}}$$ The domain is then found by solving $\frac{x}{1+x} = -1$ and to find that the composition is undefined at $-\frac{1}{2}$. It is also, of course, undefined at $-1$. Thus our domain is $\{x \in \mathbb{R} \mid x \neq -\frac{1}{2} $ and $x \neq -1$}. My question comes from noticing that if we take the algebra further we find that $$(f\circ f)(x)= \frac{\frac{x}{1+x}}{1+\frac{x}{1+x}} = \frac{x}{2x+1}$$ The domain is still surely unchanged. However, suppose I never did this problem and for some reason I simply desired to write down the function $\frac{x}{2x+1}$ on a sheet of paper and find its domain. I would find that it is defined for all reals except $-\frac{1}{2}$. (Wolfram alpha also verifies this). This would then imply that $$(f\circ f)(x)= \frac{\frac{x}{1+x}}{1+\frac{x}{1+x}} \neq \frac{x}{2x+1}$$ since the domain of the two functions is unequal. Couldn't we also work backwards from $\frac{x}{2x+1}$ in the following manner? $$\frac{x}{2x+1} = \frac{\frac{x}{1+x}}{\frac{1+2x}{1+x}} = \frac{\frac{x}{1+x}}{\frac{1+x}{1+x} + \frac{x}{1+x}} = \frac{\frac{x}{1+x}}{1 + \frac{x}{1+x}}$$ This is the function we orignally found the domain for. Did I some how just remove a point from the domain by just doing algebraic manipulations?
My guess is perhaps there are two (or more?) notions of equality going on here. One notion would perhaps be the idea of two functions $f$ and $g$ being "formally" equivalent if $f$ can be algebraically manipulated to $g$ and vice versa. The other notion would be the more intuitive one where two functions are equal if they have the same domain and map the elements of the domain to the same points in the codomain.
Thanks.