If $f(x) = \frac{x^2}{x}$, what is the domain of $x$?
Should we simplify it to $f(x) = x$ so that $x$ is any real number?
Or we do not simplify it and that the $x$ is any real number and $x \ne 0$.
But depend on the web service such as this example from Wolfram Alpha, the domain of $x$ does not include 0.
The usual convention in such cases is that the domain of the function is the largest subset of $\Bbb R$ on which the function is defined. Thus, the function $f(x)=\frac{x^2}x$ is not identical to the function $g(x)=x$: while they agree on $\Bbb R\setminus\{0\}$, the domain of $f$, the domain of $g$ is all of $\Bbb R$. Two functions with different domains are by definition not the same function. Thus, in general you may not simplify $f$ to $g$. Of course if you’re only interested in the behavior of $f$ on some subset of $\Bbb R\setminus\{0\}$, then it’s perfectly fine to replace $f$ by $g$, since $f=g\upharpoonright(\Bbb R\setminus\{0\})$.