How to solve log(x)-x+2=0 for x?

Hi,

Could anyone give me some ideas on how to solve the following question:

log (x) - x + 2 = 0

or generally

log (x) -x + c = 0 where c is a constant.

I know how to approximate this by graphing but is there any general method(s) to obtain an exact solution for equations of this type?

Thanks!
 
There are no elementary solutions for this problem. The easiest thing to do is to graph it. To get a "closed" form solution will require the Product Log function:

http://mathworld.wolfram.com/LambertW-Function.html

Also note that there are two solutions to your equation.
 
726
1
Nevermind...
 
1,786
53
but is there any general method(s) to obtain an exact solution for equations of this type?

Thanks!
[tex]\log(x)=x-2[/tex]

[tex]x e^{2-x}=1[/tex]

[tex]-xe^{-x}=-\frac{1}{e^2}[/tex]

Now take the W function of both sides:

[tex]x=-W(-\frac{1}{e^2})[/tex]

Now, the W-function is infinitely valued and so there are an infinite number of solutions to this equation.
 

D H

Staff Emeritus
Science Advisor
Insights Author
15,329
681
[tex]Now, the W-function is infinitely valued and so there are an infinite number of solutions to this equation.
While there an infinite number of solutions in the complex numbers, there are only two solutions in the reals.
 

uart

Science Advisor
2,776
9
Hi rukawukaede. The W(x) function has infinitely many complex solutions, but only zero, one or two real solutions (x,W(x) real).

- For -1/e < x < 0 it has two real solutions (your case).

- For x < -1/e it has no real solutions.

- otherwise it has a unique real solution.
 

D H

Staff Emeritus
Science Advisor
Insights Author
15,329
681
Without use of the Lambert W function (you will be hard put to find implementations outside of Mathematica, Maple, or Matlab) there is a very simple technique you can use to find the real solutions to

[tex]x - \log x = c,\,\,c>=1[/tex]

Fixed point iteration can be used to find both solutions. Note that the above is equivalent to [itex]x=\log x + c[/itex]. Writing this as a fixed point iteration scheme,

[tex]x_{n+1} = \log x_n + c[/tex]

Simply start with some initial guess [itex]x_0[/itex] and iteratively generate [itex]x_1, x_2,[/itex] etc. using the above. If the sequence [itex]{x_0, x_1, x_2, \cdots}[/itex] does converge, it will converge at one of the solution points. An initial guess of 1 will always converge. It will take a while if c is fairly close to 1. Fixed point iteration is very simple but it can be very slow to converge.

In fact, this will only find the larger of the two solutions. So how to find the other solution? Since exp(x) is a bijection, we can go from [itex]x-\log x = c[/itex] to [itex]\exp(x)/x = \exp(c)[/itex], or [itex]x = \exp(x-c)[/itex]. This suggests another fixed point iteration scheme,

[tex]x_{n+1} = \exp(x_n-c)[/tex]

If this sequence converges it will converge to the smaller of the two solutions, and once again, an initial value of 1 will always result in a convergent sequence. Once again the convergence is rather slow when c is just slightly larger than 1.
 
1,786
53
Oh man, you guys are missin' the beauty of this problem by using "real" blinders and he didn't say anything about real solutions neither. It's like just the tip of the iceberg; whole nother world down below the surface which makes crystal-clear many problems above. I say not only solve it, but draw it, then pick out the (complex) solutions like ornaments on an (upside-down) christmas tree. That to me is one of the real beauties of mathematics. Yeah, that's the assignment then, figure out how this problem is like a christmas tree turned upside-down.
 

Related Threads for: How to solve log(x)-x+2=0 for x?

Replies
4
Views
1K
  • Posted
Replies
8
Views
2K
Replies
2
Views
2K
Replies
11
Views
19K
Replies
7
Views
2K
  • Posted
Replies
11
Views
17K
Replies
1
Views
1K
  • Posted
Replies
3
Views
1K

Physics Forums Values

We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling
We Value Civility
• Positive and compassionate attitudes
• Patience while debating
We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving

Hot Threads

Top