To finding the roots of $x \cos{x}-1=0$ we can write the equation as $$ f(x)=x \cos{x}-1=0 \to x \cos{x}=1 \to \cos{x}=\frac{1}{x} \to \cos{x}-\frac{1}{x}=u(x)-v(x)=g(x)=0 $$ The roots of $f(x)$ are exactly the same roots of $g(x)$. But $f(x)\ne g(x)$. How can it be correct?

Edit: My question is: Can we always simplify the equation (changing $f(x)=0$ to $u(x)-v(x)=0$) to finding the roots?
Edit 2: The main problem is that it is much easier to finding the roots graphically by writing $f(x)$ as difference between two functions $u(x)-v(x)$. Then the roots of $f(x)$ are the intersections of the two functions $u(x)$ and $v(x)$.
Edit 3: The problem is NOT where the two functions $f(x)$ and $g(x)=u(x)-v(x)$ obtained from $f(x)$ by adding or multiplying in the right and left of $f(x)=0$ are defined. The problem is are the roots of $f(x)$ equal to the roots of $g(x)$ or intersections of the two functions $u(x)$ and $v(x)$? Are there counterexamples in which the the roots of $g(x)=u(x)-v(x)$ are not equal to original function $f(x)$?
Edit 4: Can we eliminate $x/x$ from $(x \cos{x})/x=1/x$ to obtain $\cos{x}- (1/x)=0$ ? I think I shouldn't do that. But in my textbook the author does that.

Hint: Are both f(x) and g(x) defined for all x?
If not, are f(x) and g(x) the same?
Try to remember what is the necessary condition for dividing both sides of equation by an algebraic expression.