Implementation of pow(3m) function

Engbert Gerrit IJff engbert at cs.vu.nl
Wed Aug 8 08:49:45 AEST 1990


In article <10803 at crdgw1.crd.ge.com>,
	volpe at underdog.crd.ge.com (Christopher R Volpe) writes:
) In article <11143 at alice.UUCP>, ark at alice.UUCP (Andrew Koenig) writes:
) |>If such an
) |>implementation uses exp and log for the ordinary cases, it will
) |>almost surely not be monotonic.  That is, it will be possible to
) |>find positive x, y, and z such that y > z and pow(x,y) < pow(x,z).
) 
) I sure hope so, since there are trivial real-life cases where this is
) true. E.g.: x=0.5, y=3, z=2. pow(x,y)=.125  <  pow(x,z)=.25
) 
) Am I missing something????
) 
) |>-- 
) |>				--Andrew Koenig
) |>				  ark at europa.att.com
) 
) Chris Volpe
) GE Corporate R&D
) volpecr at crd.ge.com                           

Well, althoug Andrews story was right,
the example might not have sufficient as an explanation.

There are, in fact, two cases, both of which shouldn't,
but could occur if the implementation uses several speed
optimizing strategies.

One could probably find:
some  y > z > 0 and     x > 1  where  pow(x,y) <= pow(x,z)
some  y > z > 0 and 0 < x < 1  where  pow(x,y) >= pow(x,z)

A correct implementation should give:
                    /  if     x > 1  then  pow(x,y) > pow(x,z)
for all  y > z > 0 {
                    \  if 0 < x < 1  then  pow(x,y) < pow(x,z)

as we expect it to be.

Bert IJff
Free University
Amsterdam
-------------------------------------
"The power of a math library function
is not always in its speed."    Bert



More information about the Comp.lang.c mailing list