Determine the remainder when $f(x) = 3x^5 - 5x^2 + 4x + 1$ is divided by $(x-1)(x+2)$ This question arose while I was tutoring a student on the topic of the Remainder Theorem. Now, the Remainder Theorem tells us that when a polynomial $p(x)$ is divided by a linear factor $(x-a)$, the remainder is simply $p(a)$. However, in this case we have a product of linear factors. 
Using the Remainder Theorem we can see that neither $(x-1)$ nor $(x+2)$ is a factor of $f(x)$. Also, if we try to find the remainder using long division, we get a relatively ugly remainder of 
$$
3(14x - 13)
$$
I assume this is not the correct approach as all other questions in this topic used the Remainder Theorem. So perhaps there is a more elegant approach?

Hint: the remainder will be a polynomial of degree (at most) $1$ so:
$$f(x) = (x-1)(x+2)q(x) + ax + b$$
Substitute $x=1,-2$ in the above and you get two equations in $a,b$.

[ EDIT ]   For a less conventional approach (justified in the answer here) note that $(x-1)(x+2)=0 \iff x^2=-x+2$. Repeatedly using the latter substitution:

$$
\begin{align}
3x^5 - 5x^2 + 4x + 1 &= 3 (x^2)^2 \cdot x - 5(x^2) + 4x + 1 \\
 &= 3(x^2-4x+4)x - 5(-x+2) + 4x +1 \\
 &= 3(-x+2-4x+4)x + 9x -9 \\
 &= -15(x^2)+ 18x + 9x - 9 \\
 &= -15(-x+2) + 27 x - 9 \\
 &= 42 x -39
\end{align}
$$
