If $f(x)=(x-2)q(x)-8$ for polynomial $q$, and $x+2$ is a factor of $f(x)$, find the remainder when $f(x)$ is divided by $x^2-4$

Given:

$f(x)=(x-2)q(x) -8$, where $q(x)$ is a polynomial

$(x+2)$ is a factor of $f(x)$

Find the remainder when $f(x)$ is divided by $(x^2-4)$.

I know the answer is $-2x-4$, but I do not know the working behind it?


An easy way: use $\,{ab\bmod ac = a(b\bmod c)} = $ mod Distributive Law to factor out $\,a = x\!+\!2$

$\,\ \color{#0a0}{x\!+\!2\mid f}\,\Rightarrow\, f\bmod x^2\!-\!4\,$ $=\, (x\!+\!2)\underbrace{\Bigg[\color{#0a0}{\dfrac{f}{x\!+\!2}}\bmod x\!-\!\color{#c00}2\Bigg]\! = (x\!+\!2)\left[\dfrac{f(\color{#c00}{2})}{\color{#c00}2\!+\!2}\right]}_{\textstyle\!\!\!\!\! \begin{align} \color{#0a0}f\,\bmod x\!-\!\color{#c00}2\ &=\ f(\color{#c00}{2}) = -8\\ \color{#0a0}{x\!+\!2}\,\bmod x\!-\!\color{#c00}2\ &= \color{#c00}2\!+\!2\end{align}}\! = (x\!+\!2)\left[-2\right]$

Remark $\ $ As I explain in the linked answer, using this distributive law often greatly simplifies computations by reducing the modulus, e.g. above it reduces the modulus to have degree one, viz. $\,x\!-\!2,\,$ and such mods are easy: $\,\color{#0a0}{g(x)}\bmod x\!-\color{#c00}2\!\ =\ g(\color{#c00}2)\,$ by the Polynomial Remainder Theorem. Further this optimization may eliminate the need to use CRT = Chinese Remainder Theorem, so elminates possibly complicated computation of modular inverses.

See this answer for a more complex and general example of the above method for polynomials, which highlights its relationship with Lagrange interpolation and Taylor's formula.