<s>[INST] Factorization of sum of two square The difference is $a^2 - b^2 = (a - b).(a + b)$
But what about when I have $a^{25} + 1$ ? According to wolfram alpha, the alternate form is:


*

*$(a+1) (a^4 -a^3 + a^2 -a + 1)( a^{20} - a^{15} + a^{10} -a^5 +1)$


However, the square root of 25 is a rational number 5.
But If I had 50, where the square root of 50 is irrational ?


*

*$(a^2 + 1) (a^8 -a^6 +a^4 -a^2 +1) (a^{40} -a^{30} +a^{20} -a^{10} +1 )$


In fact, I'm just wondering and trying to find out patterns, I'm very curious about that, since I haven't found anything related, only the alternate forms generated by wolfram. My question is how and what mathematical algorithm they used to find $k$ forms for $a^n + 1$ ?
Thanks in advance.
 [/INST] If $n$ is odd then the polynomial $p(x)=x^n+1$ has a zero at $x=-1$, $p(-1)=(-1)^n+1=-1+1=0$.  By the factor theorem, $x+1$ is therefore a factor of $p(x)$.  Using polynomial long division (or synthetic division) you can show that $x^n+1=(x+1)(x^{n-1}-x^{n-2}+x^{n-3}-\cdots-x+1)$.
For example, consider $p(x)=x^5+1$.  By the above, since $5$ is odd, $p(x)=(x+1)(x^4-x^3+x^2-x+1)$.  Next notice that 
$\begin{align*}x^{25}+1&=(x^5)^5+1=p(x^5)\\
&=(x^5+1)((x^5)^4-(x^5)^3+(x^5)^2-x^5+1)\\
&=(x+1)(x^4-x^3+x^2-x+1)(x^{20}-x^{15}+x^{10}-x^5+1).\end{align*}$
Finally, notice that $x^{50}+1=(x^2)^{25}+1=p((x^2)^5)$, so you can just substitute $x^2$ for $x$ in the factorization of $x^{25}+1$.
</s>