# How to find the roots of a equation involving log terms?

This question was in my test and I am not sure what to do with it

let $f:(0,\infty)\rightarrow \mathbb{R}$ be given by $$f(x)=\log x-x+2$$ then its number of roots of $f$are.

So putting it equal to zero might won't help gives this $x=e^(x-2)$ I am not getting it how to solve it, then I thought of doing its derivatives and find out where it is zero (it is at 1 easy to find) then I tried finding an interval around it so that I will get negative value on one side and positive value on other but I find it usually non-negative (by hit and trial) so what else I can do to solve it.

• But how do you get this one? – Onix Jan 26 '16 at 16:35
• You know it will be negative for very small $x$ because the $\log$ will dominate. In the middle, you found positive values. Since $\log(x) < x$, for large values the $-x$ will dominate and it will be negative again. So it might be reasonable to guess that it has two roots. – TokenToucan Jan 26 '16 at 16:36
• This is casual and flip but you have $x = e^{x -2}$. f(x) = x is a linear function whose graph is a line. g(h) = e^{x-2}$is a convex "bowed" shape function. g and f will intersect twice, or once at a tangent point or f will be entirely disjoint and to the right of g(h). so there are exactly two roots. You can use derivatives and intermediate value theorems to argue this more formally. But we know it is true. – fleablood Jan 26 '16 at 16:51 • The question only asks how many roots there are. Not what they are. Use intermediate value theorems on intervals where f is pos on one endpoint and negative on the other. Then use derivatives to show there is only one minimum so there are only two roots. – fleablood Jan 26 '16 at 16:55 • Yeah exactly that's what I tried but was not checked adequately for the negative values where the function will be negative. – Onix Jan 26 '16 at 16:57 ## 1 Answer$f'(x) = 1/x - 1.$For x:(0,1)$f'(x) >0.$Now$\lim_{x\to 0^+}f(x)=-\infty$. And f(x) is monotonically increasing upto x=1 where f(1)=1. So it becomes 0 somewhere between 0 and 1. So here we get our 1st root. For x>1 :$ f'(x) <0.$Now the function is monotonically decreasing and$ f(1)=1 \$and f(a large number say 100) = - ve. So it again becomes 0 once. So we get our 2nd root. Now it just gets more negative since it goes on decreasing so there's no other root.

So we can conclude that there are 2 roots of the equation.