# Integrating a hedgehog

As motivation of the title, consider the shape of the function $e^{-x}\left(x+\lfloor x\rfloor^2\right)$ as plotted by WolframAlpha:

This exercise I believe that is very easy, let $\lfloor x\rfloor$ the floor function (... obviously we combine with this function when we want to define an integral of the kind hedgehog), then

$$\int_0^6 e^{-x}\left(x+\lfloor x\rfloor^2\right)dx=\sum_{k=1}^6\left(\int_{k-1}^k xe^{-x}dx+(k-1)^2\int_{k-1}^ke^{-x}dx\right),$$ by integrating by part the first summand we get $$\sum_{k=1}^6\left(e^{-k+1}-ke^{-k+1}+ke^{-k}-2e^{-k}-k^2e^{-k}+k^2e^{-k+1}\right)\approx 2.13235.$$ Truly Wolfram Alpha online calculator get the closed-form and agree with my calculations. I know that it is using geometric series (and variation of those), if you want to see the closed-form and get the comparison type these codes, first the integral

integrate e^(-x)(x+(floor(x))^2)dx, from x=0 to x=6

and secondly the finite sum that we've obtained

sum e^(-k+1)-k e^(-k+1)+k e^(-k)-2 e^(-k)-k^2 e^(-k)+k^2 e^(-k+1), from k=1 to k=6

Now this question, maybe isn't important but I believe that it is a nice exercise with the purpose to be in a good mood

Question. Can you calculate as a closed-form with all details the infinite case of an integral for a hedgehog, this $$\int_0^\infty e^{-x}\left(x+\lfloor x\rfloor^2\right)dx?$$ If you believe that isn't feasible get a closed-form, you can provide us your approximation. Thanks a lot.

• Many thanks to Lovsovs and @Rahul – user243301 Mar 15 '17 at 23:25
• nice question! (+1) – tired Mar 16 '17 at 8:14
• The hedgehog is earning the reputation, not I, it has the merit. Many thanks I hope that other users ask in a next future about integrals of this kind @tired – user243301 Mar 16 '17 at 11:15

A piece is trivial, $\int_{0}^{+\infty}xe^{-x}\,dx=1$. The other piece equals
$$\int_{0}^{+\infty}\left\lfloor x\right\rfloor^2 e^{-x}\,dx = \sum_{n\geq 0}\int_{0}^{1}n^2 e^{-(x+n)}\,dx =\frac{e(e+1)}{(e-1)^3}\int_{0}^{1} e^{-x}\,dx=\color{red}{\frac{e+1}{(e-1)^2}}.$$
• Where does the factor of $x^2$ in the first equivalency come from? Shouldn't that be $\sum_n n^2\int_{0}^1 e^{-(x+n)}$? – Steven Stadnicki Mar 15 '17 at 23:24