Factoring $a^3-b^3$ I recently got interested in mathematics after having slacked through it in highschool. Therefore I picked up the book "Algebra" by I.M. Gelfand and A.Shen
At problem 113, the reader is asked to factor $a^3-b^3.$
The given solution is: 
$$a^3-b^3 = a^3 - a^2b + a^2b -ab^2 + ab^2 -b^3 = a^2(a-b) + ab(a-b) + b^2(a-b) = (a-b)(a^2+ab+b^2)$$
I was wondering how the second equality is derived. From what is it derived, from $a^2-b^2$? I know that the result is the difference of cubes formula, however searching for it on the internet i only get exercises where the formula is already given. Can someone please point me in the right direction?

Being able to quickly derive the factorization for a difference of cubes (and most other things) prevented me from having to memorize many things in school. I cannot help but share this with you as it was something I must have done a hundred times in a pinch. I will answer your question by delivering a proper full derivation of the standard factorization for a difference of cubes. Close inspection of the result will answer your question I am sure. Begin by expanding $(a-b)^3$ in any manner you choose.
$$(a-b)^3 = a^3-3a^2b+3ab^2-b^3.$$
We will now solve this equality for $a^3-b^3$ and manipulate the other side of the equality into the standard formula.
\begin{align*}
             (a-b)^3 &= a^3-3a^2b+3ab^2-b^3 \\
\Rightarrow  a^3-b^3 &=(a-b)^3+3a^2b-3ab^2 \\
                     &=(a-b)^3+3ab(a-b) \\
                     &=(a-b)\left((a-b)^2+3ab\right) \\
                     &=(a-b)(a^2-2ab+b^2+3ab) \\
                     &=(a-b)(a^2+ab+b^2).
\end{align*}
This is one handy derivation. The sum of cubes can be derived in a similar manner.
