Typesetting synthetic division

I’m teaching an Algebra course that highlights the Fundamental Theorem of Algebra. So of course we’re looking closely at polynomial division, and in particular at synthetic division. My students are preparing their homework assignments using LaTeX, so this begs the question about how to typeset their computations.

One of my students found the LaTeX package polynom, which can automatically compute and typeset polynomial long division and synthetic division. The examples in the polynom manual are:

\polylongdiv{X^3+X^2-1}{X-1}

which yields

and for synthetic division, the polynom command

\polyhornerscheme[x=1]{x^3+x^2-1}

which yields

But what if you want to show division by x - m using synthetic division, rather than x - 1? These commands no longer work.

Instead, you can make fancy use of \cline and \multicolumn in the array environment:

\begin{array}{r|rrrr} & 1 & 1 & 0 & -1 \\ m & & m & (m^2 + m) & (m^3 + m^2) \\ \cline{2-5} \multicolumn{2}{r}{1} & (m + 1) & (m^2 + m) & (m^3 + m^2 - 1) \end{array}

which yields

Interesting! If you divide a polynomial by x - m, the remainder is just the value of that polynomial at m!