Re: How to solve this natural log problem?



"Dirk Van de moortel" <dirkvandemoortel@xxxxxxxxxxxxxxxxxxxxxxxxxxx> wrote:
"David W. Cantrell" <DWCantrell@xxxxxxxxxxx> wrote in message
news:20070129122419.199$HL@xxxxxxxxxxxxxxxxx
"Dirk Van de moortel" <dirkvandemoortel@xxxxxxxxxxxxxxxxxxxxxxxxxxx>
wrote: <amy_burton2007@xxxxxxxxx> wrote in message
news:1170055954.369782.189430@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
How to solve for x?

4000x = -6.9 - ln x

Take excel and write a number in cell A1.
In cell A2 enter the formula
= A1 - ( 4000*A1 + 6.9 + LN(A1) ) / ( 4000 + 1/A1 )
and copy this down to about A20.

This is Newton's method with f(x) = 4000 x + 6.9 + ln(x)

You're going to need a very small number to start with in A1
Try putting 1, 0.1, 0.01, 0.001 etc... in A1 and see what happens.

If you don't have excel, just take a high precision calculator
and you'll find the result in a few minutes.

My first preference would be to use the Lambert W function, as Rob did.

Yes, although excel doesn't have the Lambert W function

And I don't have Excel. :-)

(and
I have *never* seen a home/garden/kitchen calculator offer it),
there is, at least on this group, a strange tendency to mention
Lambert W whenever someone is looking for a solution to this
kind of equations.
Strange :-)


My second preference would be to use some analysis to get an
approximate solution. Then, if that's not sufficiently accurate, it at
least gives a good value for A1 in Newton's (or some other iterative)
method.

Knowing that x must be a small positive number, the equation

a x = -b - ln(x)

has the approximate solution

x = (2a + 3c - Sqrt(-2a^2 + 24ac + 9c^2)) / (a(a - 2c))
where c = e^b.

Using a = 4000 and b = 6.9 in the above, we get the approximate
solution

x = 0.000308... For comparison, the solution, as mentioned by Rob, is

x = 0.0003016...

Yes, that's what Excel gives me after a mere 5 iterations
with a seed of 0.001.

OK, let's assume that Amy is using a common calculator. If she heeds your
advice to "Try putting 1, 0.1, 0.01, 0.001 etc... in A1 and see what
happens.", she will be frustrated by an error message at the second
iteration using 1, 0.1 or 0.01 for A1. (The error occurs because her
calculator cannot handle the log of a negative number.)

I'm advocating that one not pick A1 "blindly". If you don't like the
approximation I gave earlier (because it's too complicated?), then merely
use

1/(a + e^b)

a much cruder approximation, for A1. Doing so will still avoid any error
messages.

I had given the more accurate approximation earlier because I thought that
perhaps it would be accurate enough for Amy's purpose without any
iterations at all. (Her "6.9" might be an approximation with just two
significant digits.)

David
.



Relevant Pages

  • Re: how do i overwrite a cell and keep adding to another figure?
    ... separate source cell for adding a new total to the original. ... Iterations and set to 1. ... Gord Dibben Excel MVP ... Is there a way i can write the figure bought ...
    (microsoft.public.excel.newusers)
  • Re: Excel Bug - Excel Geeks Unite!!
    ... round "globally" all cells to a specified precision, ... around every cell that contains a formula (OK, ... to strip out some of the rounding errors automatically that Excel generated. ... The IEEE double precision approximation ...
    (microsoft.public.excel.misc)
  • Re: Excel Bug - Excel Geeks Unite!!
    ... > Will round all values to cell format precision. ... almost everyone (including Excel) follows the IEEE ... > binary approximation, unless the reason is clearly documented. ...
    (microsoft.public.excel.misc)
  • Re: Why (0.09+0.01-0.1) is not equal to 0.09+0.01-0.1 ?
    ... >Excel and almost all other computer software does binary math. ... none of your input numbers have exact representations and must ... >particular binary approximation. ...
    (microsoft.public.excel)
  • RE: Excel Bug?
    ... Excel represents numbers per the ... errors) for double precision, and appears to use the processor's basic math ... to approximation without actually doing the binary conversions. ... result is numerically correct given the initial binary conversions to IEEE ...
    (microsoft.public.excel)