Re: pow() problem

From: Tom St Denis (tomstdenis_at_gmail.com)
Date: 02/23/05


Date: 23 Feb 2005 08:50:30 -0800


Eric Sosman wrote:
> Tom St Denis wrote:
> > [...]
> > That's nonsense. pow is normally implemented as
> >
> > pow(a, b) = exp(ln(a) * b)
>
> (Slight topic drift): For suitable values of "normally,"
> with implications of "quick and dirty." This is not a very
> accurate implementation of pow(), and I wouldn't expect to
> find it in a high-quality math library. Reference: "The
> Standard C Library" by P.J. Plauger gives a brief but quite
> understandable explanation of the problems and exhibits an
> implementation that mitigates them.

pow(a, b) = exp(ln(a) * b)

is EXACTLY correct.

... however as implemented [and executed] it may not be ideal. The
"crux" of what the pow function does is probably along the lines of the
equivalence since you can easily find exp and ln from two convergent
series.

Tom



Relevant Pages

  • Re: pow() problem
    ... with implications of "quick and dirty." ... accurate implementation of pow(), ...
    (comp.lang.c)
  • Re: pow() problem
    ... >>accurate implementation of pow(), ... >>understandable explanation of the problems and exhibits an ...
    (comp.lang.c)