Remainder of polynomial division (source code)

= Remainder of polynomial division
{title2=$r$}

= Polynomial remainder
{synonym}

The polynomial remainder is the <polynomial> $r$ in <polynomial division> $q=Qs+r$. Division by $X-a$ has a constant <polynomial remainder> $q(a)$, as expressed by the <factor theorem>.

For any identity $f=gq+r$, <polynomial evaluation> at a <root of a polynomial> $a$ of $g$ gives
$$
f(a)=g(a)q(a)+r(a)=r(a).
$$
This substitution requires no division by $g(a)$. In the worked example, <polynomial factorization> gives $g=(X-1)(X+2)$, so its two <roots of a polynomial> are $1$ and $-2$. The cubic <polynomial> and its linear <polynomial remainder> agree there:
$$
\begin{aligned}
f(1)&=2+3-5+6=6=r(1),\\
f(-2)&=-16+12+10+6=12=r(-2).
\end{aligned}
$$
A cubic expression has been compressed into a straight line carrying exactly these two values.

\Image[/polynomial-remainder-evaluation.png]
{title=The original <polynomial> $f$ and its <polynomial remainder> $r$ agree at both <polynomial roots> of $g$ because $f-r=gq$ vanishes there}

Conversely, those two values determine the linear <polynomial remainder> by <polynomial interpolation>. Write $r=AX+B$; then $A+B=6$ and $-2A+B=12$, giving $A=-2$ and $B=8$. The <polynomial degree> bound is essential: adding any multiple of $g$ preserves the two values, but generally raises the <polynomial degree>. The plot also shows agreement at $x=-1/2$, where $q=0$ rather than $g=0$. Agreement of $f$ and $r$ at a point therefore does not imply that the point is a <root of a polynomial> of the divisor.