[Tex/LaTex] Polynomial long division using \polylongdiv

polynom

Cryptography and Network Security
Page 126 on this book

enter image description here

\documentclass[usenames,dvipsnames]{beamer}
\usepackage{colortbl}
\usepackage{dcolumn}
\usefonttheme[onlymath]{serif}
\usepackage{amsmath}
\usepackage{array,multirow,booktabs,fourier,polynom}
\usepackage[justification=centering]{caption}
\usetheme{Madrid}
\newcolumntype{2}{D{.}{}{2.0}}
\begin{document}

  \begin{frame}
  \frametitle{Polynomial Arithmetic over $GF(2)$}
\polylongdiv{x^3+x+1}{x+1}
  \end{frame}
 \end{document}

enter image description here

Can I make the division shown in the book using \polylongdiv? I know that it can be achieved using array, but \polylongdiv is very simple.

Best Answer

A little while back I had a go at reimplementing polynomial long division as what I wanted wasn't easily available via the polynom package. I've just had a go at putting in modular arithmetic and the first attempt seems to work with some caveats - the main one being that I haven't implemented modular division, so providing your steps don't involve figuring out the multiplicative inverse of an integer modulo a base, then you should be fine.

Sample code:

\documentclass{article}
%\url{https://tex.stackexchange.com/q/444837/86}
\usepackage{polydiv}

\begin{document}

\PolySet{p}{1,0,1,1}
\PolySet{q}{1,1}

\[
  \PolyLongDiv[base=2]{p}{q}
  \]

\end{document}

Result:

Modular polynomial division

(The pink background is a "feature" of the screenshot program.)

Code is on github.