<s>[INST] Integral $\int_0^1 \frac{x^n}{x^2-x+1} dx$ Greetings I desire to find a closed form for $$I=\int_0^1 \frac{x^n}{x^2-x+1} dx$$  My try was to use $x-\frac{1}{2}=t$ to get $$\int_{-\frac{1}{2}}^{\frac{1}{2}}\frac{(t+\frac{1}{2})^n}{t^2+\frac{3}{4}}dt$$ then $\frac{\sqrt 3}{2}\tan u=t$ $$I=\frac{2}{\sqrt 3}\int_{-\frac{\pi}{3}}^{\frac{\pi}{3}}\left(\frac{\sqrt3}{2}\tan u+\frac{1}{2}\right)^ndu$$ I dont know how to takle this down. I am thinking that this can be evaluated using Contour integration because I saw other similarly integrals evaluated that way, but I dont have so much knowdeledge about it. Could you  help me find a closed form for this integral?
 [/INST] Sketch: Write $I_n = \int_0^1 \frac{x^n}{x^2-x+1}\,dx$, then consider $f(t) = \sum_{n=0}^\infty I_n t^n$:
\begin{align}\sum_{n=0}^\infty I_n t^n&=\sum_{n=0}^\infty \int_0^1 \frac{(xt)^n}{x^2-x+1}\,dx
\\&=\int_0^1\frac{1}{1-xt}\frac{1}{x^2-x+1}\,dx\\
&=-\frac{\sqrt{3} \pi (t-2) + 9t\log(1-t)}{9t^2-9t+9}\end{align}
by partial fractions, and the swap of the limit and sum is justified easily since they are non-negative, so Fubini applies. Then
$$f(t) = -\frac{\frac{\pi}{3 \sqrt{3}}(t-2)+t \log(1-t)}{t^2-t+1}$$
is a generating function for $I_n$, so Taylor expansion gives the integrals each as a finite sum of the form $q + \frac{\pi}{3 \sqrt{3}} a$ for rational $q$ and $a \in \{\pm 1, \pm 2\}$.
</s>