"Jeremy Howard" <[EMAIL PROTECTED]> writes:

> Uri Guttman wrote:
> > >>>>> "BS" == Benjamin Stuhl <[EMAIL PROTECTED]> writes:
> >
> >   >> Can anyone think of things I've forgotten? It's been a while since
> >   >> I've done numeric work.
> >
> >   BS> ln, asinh, acosh, atanh2?
> >
> > dan mentioned log (base anything) but i don't recall ln. and definitely
> > the arc hyberbolics are in after i pointed them out. dunno about atanh2.
> >
> We only really need ln(). Then [log(y) base x] is simply [ln(y)/ln(x)].
> There's no need to have separate functions for different bases.

Assuming infinitely precise arithmetic this is true.  Unfortunately
that is not the case.


For instance, try this:

    perl -MPOSIX -le 'print log10(2550); print log(2550)/log(10)'

On a machine with IEEE doubles, I get:

3.40654018043396
3.40654018043395

Or try 2022 instead of 2550.

Still not convinced?

    <chile 110 [15:07] ~ >perl -MPOSIX -le 'print 10000466-pow(10,log10(10000466)); 
print 10000466-pow(10,log(10000466)/log(10))'
    7.45058059692383e-09
    2.79396772384644e-08


I think the functions in <math.h> (before C99, which probably won't be
supported on all platforms) are a reasonable set of functions to
include.  That lets us translate standard C code involving doubles
into Perl code which has a chance of producing the same output.

People who want erf() know where to get it, or can use XS or SWIG or
Inline.

Harbison & Steele list these fp functions in <math.h>: fabs, acos,
asin, atan, atan2, ceil, cos, cosh, exp, floor, fmod, frexp, ldexp,
log, log10, modf, pow, sin, sinh, sqrt, tan, tanh.  The same list of
functions standard before C99 appears in DinkumWare's online reference
(it gives the entire list, annotating what's new in C99).

Notably missing are the arc-hyperbolic functions, lgamma(), hypot(),
and cbrt(), as well as some more esoteric fp manipulations.
-- 
Ariel Scolnicov        |"GCAAGAATTGAACTGTAG"            | [EMAIL PROTECTED]
Compugen Ltd.          |   +++ THIS SPACE TO LET +++    \ We recycle all our Hz
72 Pinhas Rosen St.    |Tel: +972-3-7658117 (Main office)`---------------------
Tel-Aviv 69512, ISRAEL |Fax: +972-3-7658555    http://3w.compugen.co.il/~ariels

Reply via email to