Live data from Hacker News

Implementing the Exponential Function

pseudorandom.com

11–20 of 62 posts

Re: Implementing the Exponential Function

#11

I recently implemented the exponential function for a sound synthesizer toolkit I’m working on. The method I used was not mentioned in the article, so I’ll explain it here. I used the Remez algorithm, modified to minimize equivalent input error. This algorithm lets you find a polynomial with the smallest maximum error. You start with a set of X coordinates, and create a polynomial which oscillates up and down around…

Remez is the most common implementation of Minimax approximation algorithms, so it's probably coming when the author makes it to section 6.

Yes, this is the plan :)

Re: Implementing the Exponential Function

#12
Need to be careful about confusing smooth (infinitely differentiable) and analytic (= to Taylor series) functions.

> Any function with this property can be uniquely represented as a Taylor series expansion “centered” at a

It's fairly easy to construct tame looking functions where this isn't true.

Re: Implementing the Exponential Function

#13
post #12

Need to be careful about confusing smooth (infinitely differentiable) and analytic (= to Taylor series) functions. > Any function with this property can be uniquely represented as a Taylor series expansion “centered” at a It's fairly easy to construct tame looking functions where this isn't true.

Nice spot, thank you! I have corrected that. I also included your comment in an acknowledgments and errata section of the doc.

Re: Implementing the Exponential Function

#14
Ugh I had to implement all the transcendental functions a while ago. It was miserable, especially dealing with intermediate rounding, etc

I don’t recommend it.

That said I liked that there’s a specific exp-1 function (otherwise you drop most precision).

Re: Implementing the Exponential Function

#16
post #12

Need to be careful about confusing smooth (infinitely differentiable) and analytic (= to Taylor series) functions. > Any function with this property can be uniquely represented as a Taylor series expansion “centered” at a It's fairly easy to construct tame looking functions where this isn't true.

Blessedly, in the complex analytic setting, these coincide, to they not? [Attempting to sanity-check my own understanding here]

Re: Implementing the Exponential Function

#18
post #16
post #12

Need to be careful about confusing smooth (infinitely differentiable) and analytic (= to Taylor series) functions. > Any function with this property can be uniquely represented as a Taylor series expansion “centered” at a It's fairly easy to construct tame looking functions where this isn't true.

Blessedly, in the complex analytic setting, these coincide, to they not? [Attempting to sanity-check my own understanding here]

Yes, all locally smooth complex functions (e.g. whose real and imaginary parts satisfy the cauchy-riemann equations) are analytic, one of the main reasons complex analysis is way less of a pain than real analysis.

Re: Implementing the Exponential Function

#19
post #14

Ugh I had to implement all the transcendental functions a while ago. It was miserable, especially dealing with intermediate rounding, etc I don’t recommend it. That said I liked that there’s a specific exp-1 function (otherwise you drop most precision).

To go with that, you need ln(1+x). HP calculators had both.

Re: Implementing the Exponential Function

#20
post #3

This is an awesome article! One of my favorite SO answers I remember researching dealt with the Padé approximation of tanh[1] (which I found was significantly better than the Taylor expansion), but the caveat was that it only worked within a very narrow neighborhood. I will say that the article didn't really touch on techniques that minimize IEEE 754 subnormal[2] performance impact, which is a very interesting proble…

Hi, I am the author. You make a good point about subnormals, thank you. I will jot that down for a future update to the doc :) It is funny you mention the Padé approximation; I was debating whether or not to include that in this article. Originally I planned to stop after Minimax (using Remez), but if I include rational approximation schemes anyway (e.g. Carathéodory-Fejer), it probably makes sense to implement and a…

Just jumping into to say I am loving the article, thanks! I'm dealing with a lot of exps in an optimization problem right now and frankly only have cursory understanding of what's going on under the hood so this was very enlightening for me. Thanks again.
Post reply on HN