<s>[INST] Derivative of the nth order and evaluation in $x=0$ I want to solve the following exercise; be $f(x)=\frac{1}{x}e^x-\frac{1}{x^2}e^x+\frac{1}{x^2}$ with $x\neq 0$ we have that the function has derivatives in all orders for $x=0$
I want to determine $f^{(n)}(0)$
It seems that the above is equivalent to the expression $\frac{1}{a(n)}$ where $a(n)$ represents an expression in terms of n, now, how can I determine this derivative? any suggestions? thanks.
 [/INST] We know $f$ admits a Taylor expansion at $x=0$:
\begin{align*}
f(x)=\sum_{k=0}^\infty\frac{f^{k}(0)}{k!}x^k
\end{align*}
Denoting with $[x^n]$ the coefficient of $x^n$ of a series $f(x)$ we want to calculate
\begin{align*}
f^{(n)}(0)=n![x^n]f(x)
\end{align*}

Recalling the series expansion
\begin{align*}
e^x=\sum_{j=0}^{\infty}\frac{x^j}{j!}\tag{1}
\end{align*}
we obtain for $n\geq 0$:
\begin{align*}
\color{blue}{f^{(n)}(0)}&=n![x^n]f(x)\\
&=n![x^n]\left(\frac{1}{x}e^x-\frac{1}{x^2}e^x+\frac{1}{x^2}\right)\\
&=n!\left([x^{n+1}]e^x-[x^{n+2}]e^x\right)\tag{2}\\
&=\frac{1}{n+1}-\frac{1}{(n+2)(n+1)}\tag{3}\\
&\,\,\color{blue}{=\frac{1}{n+2}}
\end{align*}

Comment:

*

*In (2) we apply the rule $[x^p]x^qf(x)=[x^{p-q}]f(x)$ and note $[x^n]\frac{1}{x^2}=0$.


*In (3) we select the coefficient of $x^{n+1}$ and $x^{n+2}$ from the exponential function (1) and multiply with $n!$.
</s>