Do the grouping $x^{7}-20x^{5}-2x^{4}+64x^{3}+40x^{2}-128=\left(x^{7}-20x^{5}+64x^{3}\right)+\left(-2x^{4}+40x^{2}-128\right)$, and factor out $x^{3}$ in the first and $-2$ in the second group.
Consider $x^{4}-20x^{2}+64$. Find one factor of the form $x^{k}+m$, where $x^{k}$ divides the monomial with the highest power $x^{4}$ and $m$ divides the constant factor $64$. One such factor is $x^{2}-16$. Factor the polynomial by dividing it by this factor.
$$\left(x^{2}-16\right)\left(x^{2}-4\right)$$
Consider $x^{2}-16$. Rewrite $x^{2}-16$ as $x^{2}-4^{2}$. The difference of squares can be factored using the rule: $a^{2}-b^{2}=\left(a-b\right)\left(a+b\right)$.
$$\left(x-4\right)\left(x+4\right)$$
Consider $x^{2}-4$. Rewrite $x^{2}-4$ as $x^{2}-2^{2}$. The difference of squares can be factored using the rule: $a^{2}-b^{2}=\left(a-b\right)\left(a+b\right)$.
$$\left(x-2\right)\left(x+2\right)$$
Rewrite the complete factored expression. Polynomial $x^{3}-2$ is not factored since it does not have any rational roots.