Two part question.
(i) Consider the function $f(x)=x^3-6kx+k^3+8$. Show that we can write $f(x)$ as $(x+k+2)P(x)$ where $P(x)$ is a quadratic function.
(ii) Show that $2P(x)$ can be written as the sum of three perfect squares and hence solve $f(x)=0$ for all values of $k$.
My attempt.
(i) By long division I have $P(x)=x^2-(k+2)x+k^2-2k+4$. I believe this part to be correct by trying a few cases of $k$ with Wolfram Alpha.
(ii) $2P(x)=2x^2-2kx-4x+2k^2-4k+8$. No idea how to continue.
You are correct on (i). For (ii), just split it up. First, notice the $-2kx$ term, that'd be the middle term in one square:
$$2x^2 - 2kx - 4x + 2k^2 - 4k + 8$$ $$= (x^2 - 2kx + k^2) + x^2 - 4x + k^2 - 4k + 8$$
Then $(x^2 - 4x)$ looks like the beginning of another square:
$$= (x^2 - 2kx + k^2) + (x^2 - 4x + 4) + k^2 - 4k + 4$$
And there's our third:
$$= (x-k)^2 + (x-2)^2 + (k-2)^2$$
The first zero is $x = -(k+2)$. The other zeros come from the fact that all three terms here are non-negative, the only possible zero arises when all three terms are themselves zero: $x = k = 2$ (which is a double root, or no real root).