# Expanding a function undefined at zero.

As part of my homework I was asked to expand this function by powers of $$x$$:

$$f(x)=\frac{e^{\pi x}}{(e^{\pi x}-1)^2}$$

The answer is given as: $$\frac{1}{\pi^2 x^2}-\frac{1}{12}+O(x^2)$$

I've tried expanding the denominator and numerator around zero, separately and then dividing them but I only derived the first term. I've also tried writing the function in partial fractions and I reached this: $$\frac{1}{(e^{\pi x}-1)}+\frac{1}{(e^{\pi x}-1)^2}$$ I attempted to use the Taylor series for $$(e^{\pi x}-1)$$ and $$(e^{\pi x}-1)^2$$ but again I couldn't reach the answer. Wolfram Alpha gave the answer with even more terms than I needed but not the steps on how it got them. I would very much appreciate it if someone can enlighten me on how to reach the answer. Thank you!

Hint: Your function has a double pole in $$0$$, so multiply the function with $$x^2$$ and then Taylor expand.
Considering $$f(x)=\frac{e^{\pi x}}{(e^{\pi x}-1)^2}$$ let $$t=\pi x$$ and use the normal expansions $$e^{t}=1+t+\frac{t^2}{2}+\frac{t^3}{6}+\frac{t^4}{24}+\frac{t^5}{120}+\frac{t^6}{720}+ O\left(t^7\right)$$ $$e^{t}-1=t+\frac{t^2}{2}+\frac{t^3}{6}+\frac{t^4}{24}+\frac{t^5}{120}+\frac{t^6}{720}+ O\left(t^7\right)$$ $$\left(e^t-1\right)^2=t^2+t^3+\frac{7 t^4}{12}+\frac{t^5}{4}+\frac{31 t^6}{360}+\frac{t^7}{40}+O\left(t^8\right)$$ $$\frac{e^t}{\left(e^t-1\right)^2}=\frac{1+t+\frac{t^2}{2}+\frac{t^3}{6}+\frac{t^4}{24}+\frac{t^5}{120}+\frac{t^6}{720}+ O\left(t^7\right)} {t^2+t^3+\frac{7 t^4}{12}+\frac{t^5}{4}+\frac{31 t^6}{360}+\frac{t^7}{40}+O\left(t^8\right) }$$ Now, long division $$\frac{e^t}{\left(e^t-1\right)^2}=\frac{1}{t^2}-\frac{1}{12}+\frac{t^2}{240}+O\left(t^4\right)$$
Just replace $$t$$ by $$\pi x$$.
Note that $$f(x)=\frac{e^{\pi x}}{(e^{\pi x}-1)^2}=\frac{e^{\pi x}}{\pi^2x^2(\frac{e^{\pi x}-1}{\pi x})^2}=\frac{1}{\pi^2x^2}g(\pi x)$$ where $$g(x)= \frac{e^{x}}{(\frac{e^{x}-1}{x})^2}.$$ Clearly $$g(0)=\lim_{x\to0}\frac{e^{x}}{(\frac{e^{x}-1}{x})^2}=1$$ and $$g'(0)=\lim_{x\to0}g'(x)=\lim_{x\to0}-\frac{xe^x(2+e^x(x-2)+x)}{(e^x-1)^3}=\lim_{x\to0}-\frac{e^xx^3}{(e^x-1)^3}\cdot\frac{2+e^x(x-2)+x}{x^2}=0.$$ You can check that $$g''(0)=\lim_{x\to0}g''(x)=\cdots=-\frac1{12}, g'''(0)=0.$$ So $$g(x)=g(0)+g'(0)x+\frac12g''(0)x^2+\frac1{3!}x^3+O(x^4)=1-\frac1{12}x^2++O(x^4)$$ and hence $$f(x)=\frac{1}{\pi^2x^2}g(\pi x)=\frac{1}{\pi^2x^2}(1-\frac1{12}\pi^2x^2+O(x^4))=\frac{1}{\pi^2x^2}-\frac1{12}+O(x^2)).$$