Re: How to solve this natural log problem?



In article <20070129160856.171$bo@xxxxxxxxxxxxxx>,
David W. Cantrell <DWCantrell@xxxxxxxxxxx> wrote:
"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. :-)

I only recently added Excel to my computer (a Mac), but I am not yet
conversant enough to use it for math. I use Mathematica, a homebrew
arbitrary precision math package in C (which also handles rationals
and polynomials), both of which are 10 years old, or an HP calculator
which is somewhat newer.

However, my calculator has Gamma and Psi (derivative of the log of
Gamma), so it seems only a matter of time until LambertW makes it
into some calculators.

(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.

The article I cited earlier includes not only starting points for
both the principal and non-principal branches, but also a second
iteration for values near -1/e where Newton's method can bounce
around since the slope of x exp(x) is 0 at -1. Using these starting
points, one of the iterations will converge and neither will raise
errors.

Rob Johnson <rob@xxxxxxxxxxxxxx>
take out the trash before replying
to view any ASCII art, display article in a monospaced font
.



Relevant Pages

  • Re: Order of Operations problem in Excel
    ... use the RADIANS function to convert degree values to ... The "error" is> that Excel does all its trig operations in Radians, ... > Microsoft MVP - Excel ... >> my handheld calculator and the calculator under Accessories in> the Start ...
    (microsoft.public.excel)
  • Re: Scope attenuators 1,2,5, why bother?
    ... easy to multiply without using a calculator, ... My other option was to learn how to write an Excel function. ... I bought a VBA book it got yanked off ... area for cell calcs, that's how I do some intricate EE calcs. ...
    (sci.electronics.design)
  • Re: Improve Excel accuracy over 15 digits
    ... but my calculator can do it!" ... two behaviors if Excel are often confused. ... That last group is often confused because binary representation and ... With that many digits I can get the ...
    (microsoft.public.excel.misc)
  • Re: Improve Excel accuracy over 15 digits
    ... We regain all the lost productivity (because of not understanding how Excel calculates) in no time. ... but my calculator can do it!" ... That last group is often confused because binary representation and ... With that many digits I can get>> the ...
    (microsoft.public.excel.misc)
  • Re: How to do TI83 2-SampTTest (hypothesis testing)?
    ... Calculator Guidebook ... the smaller of TI's 1-sided hypothesis p-values. ... Excel may be a daunting task. ... Excel functionto compute the p-value given only the sample ...
    (microsoft.public.excel.worksheet.functions)

Quantcast