How to solve $\displaystyle \log(x)=-x$? log is base e

Printable View

- Feb 19th 2011, 04:15 PMcrossbonelog/exponential question
How to solve $\displaystyle \log(x)=-x$? log is base e

- Feb 19th 2011, 04:19 PMtopsquark
- Feb 19th 2011, 04:22 PMcrossbone
where do you start numerically? I know the solution must be between 0 and 1.

- Feb 19th 2011, 04:59 PMSammyS
Look at the roots of the function: $\displaystyle f(x)=x+\log(x)\,.$

Try $\displaystyle f(1/2)=-0.1931...\,.$ That's negative. $\displaystyle f(1)=1\,.$ That's positive, so the root is between 1/2 and 1.

Use linear interpolation or the bisection method. - Feb 20th 2011, 02:54 AMHallsofIvy
Whether or not you can solve it "analytically" depends upon what you mean by "analytically". From $\displaystyle log(x)= -x$ we get $\displaystyle x= e^{-x}$ and the $\displaystyle xe^x= 1$. From that, $\displaystyle x= W(1)$ where "W" is the "Lambert W function" which is

**defined**as the inverse function to $\displaystyle f(x)= xe^x$. Of course, values of the W function are calculated numerically, just as values of logarithms, exponentials, or trig functions are.

"Linear Interpolation", that Sammy S referred to, is also called the "secant method" since you use a line between two points on the curve to approximate the curve rather than the tangent line as Newton's method does. Now that you know that (0.5, -0.9131) and (1, 1) are on the curve, you could calculate the straight line between those two points and and determine where**that**line crosses the y-axis. Take that together with either 0.5 or 1, depending upon whether the actual value of the function is positive or negative, and do it again.

If you don't have a computer doing the calculations for you "bisection" is simpler. As SammyS calculated, f(.5)= -0.9131< and f(1)= 1> 0 (f(x)= x+ ln(x)) so there must be a 0 between them. The simplest thing to do is to take half way between: 0.75. Now f(0.75)= 0.75+ ln(0.75)= 0.46231> 0. So there must be a root between 0.5 and 0.75. Half way between is 0.625. Continue until you have an accurate enough result.