<s>[INST] An interesting definite integral $\int_0^1(1+x+x^2+x^3+\cdot\cdot\cdot+x^{n-1})^2 (1+4x+7x^2+\cdot\cdot\cdot+(3n-2)x^{n-1})~dx=n^3$ How to prove

$~~ \forall n\in\mathbb{N}^+$,
\begin{align}I_n=\int_0^1(1+x+x^2+x^3+\cdot\cdot\cdot+x^{n-1})^2 (1+4x+7x^2+\cdot\cdot\cdot+(3n-2)x^{n-1})~dx=n^3.\end{align}


My Try:
Define $\displaystyle S(n)=\sum_{k=0}^{n-1}x^k=1+x+x^2+x^3+\cdot\cdot\cdot+x^{n-1}=\frac{x^n-1}{x-1}$. Then,
\begin{align}\frac{d}{dx}S(n)=S'(n)=1+2x+3x^2+\cdot\cdot\cdot(n-1)x^{n-2}=\sum_{k=0}^{n-1}kx^{k-1}.\end{align}
Therefore,
\begin{align}
I_n&=\int_0^1 S^2(n)\left(3S'(n+1)-2S(n)\right)~dx\\
&=3\int_0^1 S^2(n)S'(n+1)~dx-2\int_0^1 S^3(n)~dx\\
&=3\int_0^1 S^2(n)(S'(n)+nx^{n-1})~dx-2\int_0^1 S^3(n)~dx\\
&=3\int_0^1 S^2(n)~d(S(n))+3\int_0^1 S^2(n)(nx^{n-1})~dx-2\int_0^1 S^3(n)~dx\\ &=n^3-1+\int_0^1 S^2(n)(3nx^{n-1}-2S(n))~dx\\
&=n^3-1+\int_0^1 \left(\frac{x^n-1}{x-1}\right)^2\left(3nx^{n-1}-2\cdot\frac{x^n-1}{x-1}\right)~dx
\end{align}
So the question becomes:

Prove \begin{align}I'=\int_0^1 \left(\frac{x^n-1}{x-1}\right)^2\left(3nx^{n-1}-2\cdot\frac{x^n-1}{x-1}\right)~dx=1.\end{align}

\begin{align}I'&=\int_0^1 \frac{3nx^{n-1}(x^n-1)^2}{(x-1)^2}-\frac{2(x^n-1)^3}{(x-1)^3}~dx\\
&=\int_0^1 \frac{(x-1)^2\left(\frac d {dx} (x^n-1)^3\right)-2(x^n-1)^3(x-1)}{(x-1)^4}~dx\\
&=\int_0^1 \frac d {dx} \left(\frac{(x^n-1)^3}{(x-1)^2}\right)~dx\\
&=\lim_{x \to 1} \frac{(x^n-1)^3}{(x-1)^2}-\frac{(0^n-1)^3}{(0-1)^2}\\
\end{align}
$$\therefore I'=1.$$

\begin{align}\therefore I_n=n^3.\end{align}

There MUST be other BETTER ways evaluating $I_n$.

Could anyone give me some better solutions? Thanks.
 [/INST] First apply the substitution $x = t^3$. Then
\begin{align*}
I_n
&= \int_{0}^{1} (1 + t^3 + \cdots + t^{3n-3})^2 (1 + 4t^3 + \cdots + (3n-2)t^{3n-3}) \cdot 3t^2 \, dt \\
&= \int_{0}^{1} 3 (t + t^4 + \cdots + t^{3n-2})^2 (1 + 4t^3 + \cdots + (3n-2)t^{3n-3}) \, dt.
\end{align*}
Now let $u = u(t) = t + t^4 + \cdots + t^{3n-2}$. Then
$$ 3 (t + t^4 + \cdots + t^{3n-2})^2 (1 + 4t^3 + \cdots + (3n-2)t^{3n-3}) = 3u^2 \frac{du}{dt}.$$
Therefore
$$ I_n = \left[ u(t)^3 \right]_{t=0}^{t=1} = u(1)^3 - u(0)^3 = n^3. $$
</s>