<s>[INST] Closed form of $\sum_{x=1}^{n} \dfrac{x-1}{e^x}$ Is there a closed form for this series?
$$\sum_{x=1}^{n} \dfrac{x-1}{e^x}$$
Ultimately, I want to find its convergence i.e.
$$\lim_{n \to \infty} \sum_{x=1}^{n} \dfrac{x-1}{e^x}$$
By the integral test, the series converges and for arbitrary large $n$ my code tells me  it's approaching $\dfrac{1}{(e-1)^2}$
 [/INST] Define
$$f(y)=\sum_{x=1}^n y^x=\frac{y(1-y^n)}{1-y}$$
Differentiate $f$ with respect to $y$ and manipulate as follows:
$$\begin{aligned}
\frac{\text{d}f}{\text{d}y}=\sum_{x=1}^nxy^{x-1}&=\frac{1-(n+1)y^n+n y^{n+1}}{(1-y)^2}\\
\sum_{x=1}^nxy^x&=y\cdot\frac{1-(n+1)y^n+n y^{n+1}}{(1-y)^2}\\
\sum_{x=1}^n(x-1)y^x&=y\cdot\frac{1-(n+1)y^n+n y^{n+1}}{(1-y)^2}-f(y)\\
&=y\cdot\frac{1-(n+1)y^n+n y^{n+1}}{(1-y)^2}-\frac{y(1-y^n)}{1-y}\\
&=\frac{y(y-ny^n+(n-1)y^{n+1})}{(1-y)^2}
\end{aligned}$$
From here, substitute in $y=e^{-1}$ to get
$$\sum_{x=1}^n\frac{x-1}{e^x}=\frac{e^{-n}(n-1-en)+1}{(e-1)^2}$$
</s>