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.
ex = limn→∞(1+xn)n = ∞∑k=0xkk! Here the symbol ∼ means that the ratio of the two sides goes to 1 as x goes to 0. You can see this approximation in the figure. Around x=0, the blue graph of ex and the red graph of 1+x are almost indistinguishable.
The linear approximation formula is based on the equation of the tangent line of a function at a fixed point. The linear approximation of a function f(x) at a fixed value x = a is given by L(x) = f(a) + f '(a) (x - a).
For example, while performing a calculation using π we certainly use the value π=3.14, but the value of pi is supposed to be 3.142857142857143. Hence, π=3.14 is an approximate value to make the calculation convenient.
How about a strategy like this that uses the formula
ex = 2 x/ln(2)
1/ln(2)
I realize this is not a complete solution, but it does only require a single multiplication and reduces the remaining problem to approximating a fractional power of 2, which should be easier to implement in hardware.
Also, if your application is specialized enough, you could try to re-derive all of the numerical code that will run on your hardware to be in a base-e number system and implement your floating point hardware to work in base e as well. Then no conversion is needed at all.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With