Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss
Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

Looking for a fast exp(x) where -10.0<=x<=10.0

10 views
Skip to first unread message

Scott Watson

unread,
Nov 1, 1990, 1:48:20 PM11/1/90
to
Hi y'all -

I have a need for an fast exp(x) function...

x is a float and can range inside +-10.0.

Some sort of low granularity (read: *big array*) lookup table w/
interpolation, or something...

Any ideas?

Thanks in advance

Scott Watson / Walt Disney Imagineering sc...@walt.disney.com
#ifdef SANE
#include <std_disclaimer.h>
#endif

--
Scott Watson / Walt Disney Imagineering sc...@walt.disney.com
#ifdef SANE
#include <std_disclaimer.h>
#endif

Craig Hansen

unread,
Nov 1, 1990, 10:17:33 PM11/1/90
to
In article <1990Nov1.1...@walt.disney.com>, sc...@walt.disney.com (Scott Watson) writes:
> I have a need for an fast exp(x) function...
> Any ideas?

Decompose your exp(x) into exp(a+b), where a and b are
the most-significant and least significant parts of x.
exp(a+b)=exp(a)*exp(b), so get exp(a) and exp(b) from
two small tables and multiply them together.

Regards,
Craig Hansen
cr...@microunity.com

Dave Mc Mahan

unread,
Nov 1, 1990, 10:19:26 PM11/1/90
to

In a previous article, sc...@walt.disney.com (Scott Watson) writes:
>Hi y'all -
>
>I have a need for an fast exp(x) function...
>
>x is a float and can range inside +-10.0.
>
>Some sort of low granularity (read: *big array*) lookup table w/
>interpolation, or something...

How much accuracy do you need, and how fast does it have to be? Also, what
kind of CPU are you using and how much memory can you dedicate to a lookup
table?

>Scott Watson / Walt Disney Imagineering sc...@walt.disney.com

-dave

--
Dave McMahan mcm...@netcom.uucp
{apple,amdahl,claris}!netcom!mcmahan

Ken Turkowski

unread,
Nov 2, 1990, 3:28:26 AM11/2/90
to
In a previous article, sc...@walt.disney.com (Scott Watson) writes:
>>Hi y'all -
>>
>>I have a need for an fast exp(x) function...
>>
>>x is a float and can range inside +-10.0.

You can calculate exp(x) in fixed-point with a series of shifts
and adds and a small lookup table using CORDIC iterations.
Convergence is linear, so you get about one bit of precision with
each iteration through a simple loop. With 32-bit words, you can
probably get 26 bits of precision. If you can get by with less
bits of precision, you can by with less iterations.

I don't have the references handy, but I just recently published
a paper in Graphics Gems (Academic Press, 1990) on CORDIC trigonometry.
In the references to that paper are pointer to papers by Walthers
and Chen which address exp, log, sqrt, and a host of other nonlinear
functions.
--
Ken Turkowski @ Apple Computer, Inc., Cupertino, CA
Internet: tu...@apple.com
Applelink: TURK
UUCP: sun!apple!turk

Ken W. Sarkies

unread,
Nov 4, 1990, 10:56:23 PM11/4/90
to
In article <1990Nov1.1...@walt.disney.com> sc...@walt.disney.com (Scott Watson) writes:
>
>I have a need for an fast exp(x) function...
>

Another idea I have used is the polynomial approximations as given in
Abramowitz and Stegun ``Handbook of Mathematical Functions''. For exp(x) you
can get accuracy to 2 x 10^{-10} for seven terms with 0<x<ln(2). Outside that
range use known results i.e. exp(x) = 2 x exp(x - ln(2)) for ln(2)<x<2ln(2).
The seven terms might be a bit much if you want real speed, but with other
suggestions given you may be able to tailor a useful algorithm depending on
your speed/accuracy/memory tradeoff.

--
Ken Sarkies

No disclaimer. My boss takes all responsibility for my big mouth.

Joe Keane

unread,
Nov 6, 1990, 5:02:58 PM11/6/90
to
In article <1990Nov1.1...@walt.disney.com> sc...@walt.disney.com (Scott
Watson) writes:
>I have a need for an fast exp(x) function...

My standard questions: how fast do you want it, how accurate do you want it,
and how much memory are you willing to use?

Actually the exponential function is very easy to compute, because exp(x+y) =
exp(x) exp(y). So don't even need CORDIC, you can get by with one dimension.
All you need is a table of exp(2^n) for a wide range of n. For each bit
that's on in the argument, you multiply the result by the corresponding value.
If you want it to be faster and you're willing to use more memory, you can do
many bits at a time.

0 new messages