Approximate e^x

Viewed 32528

I'd like to approximate the ex function.

Is it possible to do so using multiple splines type based approach? i.e between x1 and x2, then

y1 = a1x + b1, between x2 and x3,

then

y2 = a2x + b2

etc

This is for dedicated fpga hardware and not a general purpose CPU. As such I need to create the function myself. Accuracy is much less of a concern. Furthermore I can't really afford more than one multiplication circuit and/or multiple shifts/adders. Also I want something much smaller than a CORDIC function, in fact size is critical.

10 Answers

For hardware, I have an awesome solution for you IF you need it to be bit-level accurate. (Else just do an approximation like above). The identity is exp(x) = cosh(x) + sinh(x), the hyperbolic sine and cosine. The catch is that the hyperbolic sine and cosine can be computed using the CORIC technique, and best of all, they are one of the FAST CORDIC functions, meaning they look almost like multiply instead of almost like divide!

Which means for about the area of an array multiplier, you can compute exponent to arbitrary precision in just 2 cycles!

Look up the CORDIC method - it's AMAZING for hardware implementation.

One other hardware approach is using a small table in conjunction with a formula others have mentioned: exp(x + y) = exp(x) * exp(y). You can break the number up into small bit fields - say 4 or 8 bits at a time - and just look up the exponent for that bitfield. Probably only effective for narrow computations, but it's another approach.

Related