From: Vladimir Vassilevsky on


kc6zut wrote:
> I need an algorithm for computing the exponential of a real number using
> only elementary operations (addition, subtraction, multiplication and/or
> division). I have a PLC (Programmable Logic Controller - used in
> industrial controls) as the processor. It has no built-in math functions
> other that the above. I need to convert a voltage from a pressure
> transducer to a displayed value. The transducer output is scaled to
> produce X volts per decade of pressure e.g. 1 volt is 1.6e-10 Torr, 1.6
> volts is 1.6e-9 Torr. The conversion formula is; pressure =
> 10^(1.667*Voltage - 11.46). I only need 2 - 3 significant figures for the
> display. I've tried using a Taylor series but even with 5 terms it is only
> good over a small range. The available memory would only support a small
> look up table. Any other ideas? Any references?

Calculate pow(10,x) as pow(2,x). The integer part of X is just the
number of arithmetic shifts. The fractional part of X is going to be in
the range from 1 to 2. In this range, pow(2,x) function can be easily
approximated to desired accuracy by a polynomial of the order ~2 or ~3.
Or by piecewise linear interpolation.

Vladimir Vassilevsky
DSP and Mixed Signal Design Consultant
http://www.abvolt.com
From: glen herrmannsfeldt on
kc6zut <mmiller(a)ushio.com> wrote:
> I need an algorithm for computing the exponential of a real number using
> only elementary operations (addition, subtraction, multiplication and/or
> division). I have a PLC (Programmable Logic Controller - used in
> industrial controls) as the processor. It has no built-in math functions
> other that the above. I need to convert a voltage from a pressure
> transducer to a displayed value. The transducer output is scaled to
> produce X volts per decade of pressure e.g. 1 volt is 1.6e-10 Torr, 1.6
> volts is 1.6e-9 Torr. The conversion formula is; pressure =
> 10^(1.667*Voltage - 11.46). I only need 2 - 3 significant figures for the
> display. I've tried using a Taylor series but even with 5 terms it is only
> good over a small range. The available memory would only support a small
> look up table. Any other ideas? Any references?

When the input is floating point, the usual system is to
multiply by the appropriate constant to get in in the from 2**x.
The integer part goes to the exponent of the result. Then a
taylor series in frac(x)-1 shouldn't take many terms. For small x,
exp(x) is about 1+x.

Otherwise, for a scaled fixed point exp see Knuth's
"Metafont: The Program".

-- glen
From: glen herrmannsfeldt on
Scott Hemphill <hemphill(a)hemphills.net> wrote:
> "kc6zut" <mmiller(a)ushio.com> writes:
(snip)

> Over what range do you want the approximation to be good? Are you
> displaying the result in exponential form?

> If you are displaying the result in exponential form, you will need to
> pick off the decade part of the answer first.

Oh, yes, I forgot to say that. On machines with binary floating
point, one scales such that it is the form 2**x, but for decimal
then scale to 10**x. The integer part is the exponent for the
(decimal) result, the fractional part goes to the polynomial
approximation.

> Then you can use a
> Chebyshev polynomial approximation on the remainder. Otherwise, if
> you are converting to fixed point, you can use Chebyshev polynomials
> on the entire quantity. Chebyshev polynomials will minimize the
> maximum absolute error for a given order of polynomial.

-- glen