Live data from Hacker News

Implementing the Exponential Function

pseudorandom.com

61–62 of 62 posts

Re: Implementing the Exponential Function

#61
post #57

"We can see the values are relatively densely clustered near 0 and increasingly sparse the further you move away from the origin. As another example, half of all 32-bit floating point numbers reside in the real interval [-1,1]. " I knew this in general but this specific statistic was eye-opening to me. Systems like OpenGL normalize coordinates so they only use values in this [-1,1] range. That means they effectively…

'half' is ambiguous here: They lose 1 bit of expressiveness for the mantissa, and 1 bit in the exponent, giving an efficiency loss of 2 bits from 32 == ~3%. So there's very little loss in using single-precision floating point, and a lot of gains in smoothly handling larger numbers that arise from addition et al. edit: I'm half wrong. The bit in mantissa isn't wasted, the only bit that's wasted in the sign bit in the…

It agrees with my intuition that one bit lost would reduce the values by half. I probably don't understand what is meant by efficiency loss but my point is that a different (theoretical non floating point) encoding would be able to represent twice as many values within [-1,1] for the same 32 bits. For some applications that seems like it would be a win.

Re: Implementing the Exponential Function

#62
post #58

Nice article, thanks. For anyone interested in the topic, I highly recommend Trefethen's Approximation Theory and Approximation Practice. It's approachable, intuitive, and fun while still covering a lot of technical detail.

I have that in the further reading section :) I personally consider it one of the best textbooks on numerical analysis.

I only wish Trefethen had written it with general C/C++ instead of his own custom MATLAB library, chebfun. One of these days I'd like to get around to implementing chebfun in C++.

Post reply on HN