[prev in list] [next in list] [prev in thread] [next in thread] 

List:       haskell-cafe
Subject:    Re: [Haskell-cafe] Confused about logBase
From:       Alexey Khudyakov <alexey.skladnoy () gmail ! com>
Date:       2016-08-25 19:27:24
Message-ID: CAMoLZqix9-AyTAQRC8ym2uWKYEiauRfy909_RCErCwMmtdg=UQ () mail ! gmail ! com
[Download RAW message or body]

On 25 August 2016 at 00:51, MarLinn via Haskell-Cafe
<haskell-cafe@haskell.org> wrote:
> Hi,
>
> I discovered that in base logBase, the functions representing arbitrary
> logarithms, are defined in terms of two applications of log. log, the
> functions representing the natural logarithm, just pass responsibility on to
> some primitives. That is fine, mathematically speaking. But from an
> implementation standpoint, I wonder why one would do that.
>
> The logarithm that should be the fastest and the most precise one to
> approximate by a cpu should be the one to base two. In fact if one already
> has a floating point representation, it should be almost ridiculously easy
> to compute from the exponent.
>
Speaking of precision.  log in any base is a transcendental function
so best we can do is to ensure that approximation differs from true
answer no more that 0.5 ULPs.

Also I don't think log in base 2 would be any more performant than
natural logarithm. Yes calculations for exponent is easy but you still
need to calculate it for mantissa and it's not easier task. And most
of the time natural logarithm is used.
_______________________________________________
Haskell-Cafe mailing list
To (un)subscribe, modify options or view archives go to:
http://mail.haskell.org/cgi-bin/mailman/listinfo/haskell-cafe
Only members subscribed via the mailman list are allowed to post.
[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic