# What is the fractional part function of $e^x$?

Given a real positive number $x\in\mathbb{R^+}$.

What is the function of the fractional part of $e^x$?

-
I could give the answer $e^x - \lfloor e^x \rfloor$, but I suppose this is not what you are looking for. Why exactly do you need this expression, and in what form do you want it? – Johannes Kloos Mar 30 '12 at 11:00
@JohannesKloos sorry I missed your comment. – draks ... Mar 30 '12 at 11:10
I was looking for another function that calculate the fractional part without having to calculate $e^x$. $e^x$ will be very large for the given x. So, I need a function that gives approximately the same fractional part with smaller numbers while calculating the result. – Must Mar 30 '12 at 12:10
Have you tried playing around with the Taylor expansion? – Johannes Kloos Mar 30 '12 at 12:48
Thanks for mentioning Taylor expansion. I will try to see what can I do with the following functions: link – Must Mar 30 '12 at 13:25

As Johannes Kloos suggests, you can use the Taylor expansion. Here's the straightforward application; there may be better ones.

Let s = 0 and t = 1.
Start a loop with n = 1, incrementing by 1 each time.
Let t = t * x / n.
If t is sufficiently small, exit the loop.
Let s = s + (t - floor(t)).
If s > 1, let s = s - 1.
Return t.


Essentially all the rounding error comes from the t - floor(t). Some numerical analysis should give the maximum size of t and hence the number of significant digits in t - floor(t); this, in turn, gives an idea of what "sufficiently small" means.

-
The step "Let t = t - floor(t)." will reduce the size, but the result will be incorrect. – Must Mar 30 '12 at 14:20
@Must: Oops, I stated it wrong. In my actual code I had a different variable holding the floored part. Let me rewrite. – Charles Mar 30 '12 at 15:06

Suppose $x$ is between $100$ and $101$. To compute even one significant figure for the fractional part of $e^x$, you will need to know $x$ accurate to about $44$ significant figures...

-

The Fractional part of $e^x$ is given by $\text{frac}(e^x)=e^x-\lfloor e^x\rfloor.$

-
I suppose this is the best answer one can give under the circumstances, but I do hope we get some clarification from OP. – Gerry Myerson Mar 30 '12 at 11:38