The sum and difference of cubes is a special case of binomials that can be factored out easily by applying some patterns.
As the name suggests, the sum of two cubes is a case where two cubed terms are being added together.
$$a^3+b^3$$
In the same manner, the difference of two cubes is a case where one cubed term is subtracting another cubed term.
$$a^3-b^3$$
The strategy of factoring them out is very similar. They only differ in signs.
For the sum of two cubes, the factors are a binomial and a trinomial. The binomial has middle sign that is positive (hint: sum), while the trinomial has a middle term that is opposite in sign which is negative.
$${a^3} \color{blue}{+} {b^3} = \left( {a\color{blue}{ +} b} \right)\left( {{a^2}\color{red}{ -} ab \color{blue}{+} {b^2}} \right)$$
For the difference of two cubes, the factors are also a binomial and a trinomial. This time the binomial has middle sign that is negative (hint: difference), while the trinomial has a middle term that is opposite in sign which is positive.
$${a^3}\color{red}{ -} {b^3} = \left( {a\color{red}{ -} b} \right)\left( {{a^2} \color{blue}{+} ab \color{blue}{+} {b^2}} \right)$$
Notice that for both cases, the third term of the trinomial factor is always positive.
Let's go over some examples!
Example 1: Factor \({x^3} + 8\)
Before we can apply the pattern to factor this out, we need to check if each term of the binomial can be written as a power of \(3\). The first term is obviously a cube term because \(x\) has an exponent of \(3\). The second term can be expressed as a term with a power of \(3\), that is, \(8 = {2^3}\). This is indeed a case of the sum of two cubes where \(a=x\) and \(b=2\).
$$\eqalign{
{x^3} + 8 &= {\left( x \right)^3} + {\left( 2 \right)^3} \cr
&= \left( {x + 2} \right)\left[ {{x^2} - \left( x \right)\left( 2 \right) + {2^2}} \right] \cr
&= \left( {x + 2} \right)\left( {{x^2} - 2x + 4} \right) \cr} $$
Example 2: Factor \({y^3} - 27\)
The first term is a cube since the exponent of \(x\) is \(3\). The second term is also a cube term because \(27 = {3^3}\). This is indeed a case of the difference of two cubes where \(a=y\) and \(b=3\).
$$\eqalign{
{y^3} - 27 &= {\left( y \right)^3} - {\left( 3 \right)^3} \cr
& = \left( {y - 3} \right)\left[ {{x^2} + \left( y \right)\left( 3 \right) + {3^2}} \right] \cr
& = \left( {y - 3} \right)\left( {{x^2} + 3y + 9} \right) \cr} $$
Example 3: Factor \(64{x^3} + {y^3}\)
The second term is a cube because \(y\) has a power of \(3\). But the first term requires a little attention because it has two componets - a number and a variable. The variable is a cube since \(x\) is raised to the third power. How about \(64\)? Can we express it as a number with a power of \(3\)? Yes, it is \(64 = {4^3}\). We can factor this out now since \(a=4x\) and \(b=y\).
$$\eqalign{
& 64{x^3} + {y^3} = {\left( {4x} \right)^3} + {\left( y \right)^3} \cr
& = \left( {4x + y} \right)\left[ {{{\left( {4x} \right)}^2} - \left( {4x} \right)\left( y \right) + {{\left( y \right)}^2}} \right] \cr
& = \left( {4x + y} \right)\left( {16{x^2} - 4xy + {y^2}} \right) \cr} $$