DSPRelated.com
Forums

finding e^x in fixed pt format when x is a floating pt

Started by Unknown August 4, 2005
hi,
  how can i get an almost accurate value for e^x if x is a floating
point number. Say to find e^1.5. In that case 1.5 has to be converted
to fixed point format, say x'. Then how can I get back e^x from e^x'.
Is there an algorithm or a standard implementation that I can refer for
the same.

Hoping for a help.

--
Jagadeesh

<jagadeeshbp@gmail.com> wrote in message
news:1123128327.469494.75440@g43g2000cwa.googlegroups.com...
> hi, > how can i get an almost accurate value for e^x if x is a floating > point number. Say to find e^1.5. In that case 1.5 has to be converted > to fixed point format, say x'. Then how can I get back e^x from e^x'. > Is there an algorithm or a standard implementation that I can refer for > the same. > > Hoping for a help. > > -- > Jagadeesh >
You could try a power series but you may need quiet a few terms. e^x=1+x-x^2/2+x^3/3.2-... A second order approx is also given by the fraction e^x=e^(x/2)/e^(-x/2) and this becomes e^x : =(1+x/2)/(1-x/2) Shytot
in article jPiIe.178$iM2.10378@news.xtra.co.nz, Shytot at Shytot@yme.com
wrote on 08/04/2005 02:44:

> <jagadeeshbp@gmail.com> wrote in message > news:1123128327.469494.75440@g43g2000cwa.googlegroups.com... > >> how can i get an almost accurate value for e^x if x is a floating >> point number. Say to find e^1.5. In that case 1.5 has to be converted >> to fixed point format, say x'. Then how can I get back e^x from e^x'. >> Is there an algorithm or a standard implementation that I can refer for >> the same. >> > You could try a power series but you may need quiet a few terms.
before going to a power series, you should first convert to base 2 exponential. e^x = 2^(x*log2(e)) = 2^(x/ln(2)) then take out the integer part of x/ln(2) (it simply results in bit shifting to the left for a positive integer part), then use an optimized power series. for order=4, you might try the one at http://groups.google.com/group/comp.dsp/msg/8ba6bd6fe2474876 or find a better series. -- r b-j rbj@audioimagination.com "Imagination is more important than knowledge."
>>>>> "jagadeeshbp" == jagadeeshbp <jagadeeshbp@gmail.com> writes:
jagadeeshbp> hi, jagadeeshbp> how can i get an almost accurate value for e^x if x is a floating jagadeeshbp> point number. Say to find e^1.5. In that case 1.5 has jagadeeshbp> to be converted to fixed point format, say x'. Then Why does x have to be converted to fixed point? And why do you want a fixed-point value of e^x when x is floating-point? jagadeeshbp> how can I get back e^x from e^x'. Is there an jagadeeshbp> algorithm or a standard implementation that I can jagadeeshbp> refer for the same. There are lots of algorithms for computing e^x. The right one depends on how accurate you want and on the range of x. Computer Approximations by Hart et. al. has some ideas. You can look on netlib.org for some code for e^x. Ray
have to know the range of x first.

hi,
  thanks for all the help.

  Say im to calculate e^0.5. I converted 0.5 to Q15 format which gives
e^16384. Now i have a problem, to get scaled down.

There is an assignment:
 int t = e^x; x now in fixed pt, say x'

Then how can i get the actual value that should be there for t from
e^x'. Wont that invlove taking 32768th root of e^x', considering that
x' is Q15 format of x.

How can I get over it?

If i use power series expansion with even 3 terms with a Q31 format,
wont the squaring saturate too soon?

Please advice me on specifically where I should look in netlib.org for
such algorithms/implementations?


TIA..
--
Jagadeesh