Evaluating $\int_{0}^{1} \frac{x^{2n+2}}{x^2-2x+2}\,{\rm d}x$ $$\int_{0}^{1} \frac{x^{2n+2}}{x^2-2x+2} \,{\rm d}x \tag{1}$$
This integral came up as a result of another integral I was trying to evaluate. Just for recreational purposes. Is there some closed form for this, even in terms of special functions? In general, is it possible to evaluate integrals of the form:
$$\int_{0}^{1} \frac{P(x,x^n)}{Q(x)} \,{\rm d}x \tag{2}$$
with $\text{deg}(P) > \deg(Q)$? For example:
$$\int_{0}^{1} \frac{x^n}{1+x^2} \,{\rm d}x \tag{3}$$
Can be written in terms of the digamma function. If I'm not mistaken, $(1)$ does not follow from $(3)$, because if you try to complete the square in the denominator of $(1)$, you'd end up having to perform a $u$-sub with $u = x-1$ and then a $(u+1)^{2n+2}$ in the numerator. This ruins things. Can someone give some help?
 A: Like most things in life, this is a hypergeometric integral:
$$
\fbox{$\frac{(1+i) \left(\, _2F_1\left(1,2 n+3;2
   (n+2);\frac{1}{2}-\frac{i}{2}\right)-i \,
   _2F_1\left(1,2 n+3;2
   (n+2);\frac{1}{2}+\frac{i}{2}\right)\right)}{8
   n+12}\text{ if }\Re(n)>-\frac{3}{2}$}
$$
The way to get it there is to transform $[0, 1]$ to $[0, \infty]$ by a linear fractional, and then it looks like a standard hypergeometric integral (I did not do that, but just asked mathematica).
A: Let's first try to find a simple expression for $ I_{k} $, defined for all $ k\in\mathbb{N} $, as follows : \begin{aligned}I_{k}=\int_{0}^{1}\frac{x^{k}}{x^{2}+1}\,\mathrm{d}x\end{aligned}
Let $ k\in\mathbb{N} $. Using the geometric formula for partial sums, we have : $$ \frac{\left(-1\right)^{k}}{1+x^{2}}+\sum_{j=0}^{k-1}{\left(-1\right)^{k-1-j}x^{2j}}=\frac{x^{2k}}{1+x^{2}} $$
Thus : $$ I_{2k}=\left(-1\right)^{k}\frac{\pi}{4}+\sum_{j=0}^{k-1}{\frac{\left(-1\right)^{k-1-j}}{1+2j}} $$
And : $$ I_{2k+1}=\left(-1\right)^{k}\frac{\ln{2}}{2}-\sum_{j=1}^{k}{\frac{\left(-1\right)^{k-j+1}}{2j}} $$
Now let $ n\in\mathbb{N} $, let's get back to the original integral : \begin{aligned} \int_{0}^{1}{\frac{x^{2n+2}}{x^{2}-2x+2}\,\mathrm{d}x}&=\int_{0}^{1}{\frac{x^{2n+2}}{\left(1-x\right)^{2}+1}\,\mathrm{d}x}\\ &=\int_{0}^{1}{\frac{\left(1-x\right)^{2n+2}}{x^{2}+1}\,\mathrm{d}x}\\ &=\sum_{k=0}^{2n+2}{\left(-1\right)^{k}\binom{2n+2}{k}I_{k}} \\ &=\sum_{k=0}^{n+1}{\binom{2n+2}{2k}I_{2k}}-\sum_{k=0}^{n}{\binom{2n+2}{2k+1}I_{2k+1}}\end{aligned}
We have all the formulas we need, we can continue for further possible simplifications, but I think the final formula would seem a little ugly.
