This question arose when I was going to determine the domain for $f \circ f(x)$.
Let $f(x) = \dfrac{1-x}{1+x}$.
$f \circ f(x) = x, \quad$ But the domain is not $\mathbb{R}$ because $f(x)$ is undefined for $x = -1$.
This made sense to me after some thinking, $f \circ f(x)$ is only equivalent to $x$ if $x \neq -1$, so really one needs to specify the domain.
So far so good, but then I started questioning the way I usually simplify algebraic expressions and solve equations. If I were to solve the equation
$p_1(x) = q_1(x)$
I might start simplifying both expressions and come up with a simpler equation:
$p_1(x) = q_1(x) \iff p_2(x) = q_2(x) \iff ... \iff p_n(x) = q_n(x)$
and here any $q_k(x)\iff q_t(x)\quad$ right?
So I tried to come up with cases when I felt I probably would not bother with specifying domains before simplifying an expression, but probably would if the expression was used in an equation, as an example:
$\dfrac{1}{x} + x - \dfrac{1}{x} = 0$
So usually I feel like I have always just regarded the left hand side as equivalent to $x$, if just asked to simplify the left hand side as an expression. But the equation makes me confused. Obviously $\dfrac{1}{x}$ is not defined when $x = 0$, but then again $\dfrac{1}{x}$ and $-\dfrac{1}{x}$ cancel eachother out, so does it really matter that they are not defined when $x = 0$?
I tried to consult wolframalpha, but if I plug in $x = x + \dfrac{1}{x} - \dfrac{1}{x}$, it evaluates to true and if I plug in $x + \dfrac{1}{x} - \dfrac{1}{x} = 0$ it doesn't give an answer, as it does if $0$ is substituted for any real number.
So now I feel like I've failed to understand a very fundamental concept of mathematics, that is when algebraic expressions really can be seen as equivalent and if it matters if they are used in equations or not?