Is there a closed form expression for $f(n) = \sum_{i=1}^n (-1)^{i+1}\frac{1}{i!}$

156 Views Asked by At

I have the series

$$ f(n) = \frac{1}{1!} - \frac{1}{2!} + \frac{1}{3!} - \frac{1}{4!} + ...... + \frac{1}{n!} \\ \text{or} \\ f(n) = \sum_{i=1}^n (-1)^{i+1}\frac{1}{i!} $$

Is there a closed form solution for this equation?

1

There are 1 best solutions below

0
On

A derangement is a permutation with no fixed point, i.e. a permutation where no element is in its original position. Let $d(n)$ be the number of derangements of $\{1,2,\ldots,n\}$. There's a nice combinatorial argument that shows $$ d(n)= n!\sum_{k=0}^{n}\frac{(-1)^k}{k!} $$Note that in terms of your function, we have $$ f(n) = 1- \frac{d(n)}{n!} $$ Then you can use the Taylor series for $e^{-x}$ to compute $$ \lim_{n\to\infty}\frac{d(n)}{n!} = e^{-1} $$Since the sum is alternating and converges quickly, we have $$ f(n) = \begin{cases} 1- \frac{1}{n!} \lfloor n!/e\rfloor,& n \text{ odd}\\ 1- \frac{1}{n!} \lceil n!/e\rceil,& n \text{ even}\\ \end{cases} $$I can't say how efficient this is, as it requires calculating $n!$, computing the floor/ceiling quotient somewhat accurately, and then dividing by $n!$ again. But it's something.