# simplifying polynomial rational expressions

When rational expression $$\frac{x^{2} + 3x}{x^{2} + 5x}$$ is simplified it equals $$(x+3)/(x+5)$$ where $$x\ne 0$$. What I don't understand is why are the two functions not equal for the whole domain while we are just doing is dividing for example $$2/4 = 1/2$$, in this case, we only divided. (I know this is a stupid question)

If we define the domain of a rational expression as the largest subset of $$\mathbb R$$ (or of $$\mathbb C$$ or whatever) at which that expression is defined, then the domain of $$\dfrac{x^2+3x}{x^2+5x}$$ is $$\mathbb R\setminus\{0,-5\}$$, whereas the domain of $$\dfrac{x+3}{x+5}$$ is just $$\mathbb R\setminus\{-5\}$$. Since they have distinct domains, they are not the same function.
For example, consider the functions $$f(x)=\frac{x}{x}$$ and $$g(x)=1.$$ The domains are $$\operatorname{dom} f(x)=\mathbb{R}\setminus \{0\}$$, and $$\operatorname{dom} g(x)=\mathbb{R}.$$ Thus, $$f(x)\neq g(x)$$, even though $$\frac{x}{x}=1$$ when $$x\neq0$$.