1

The code

\documentclass{memoir}
\usepackage{polynom}

\begin{document}
\polylongdiv[style=B]{x^4 - 3x^3 + x^2 + 3x - 2}{x-1}
\end{document}

produces the following diagram of a polynomial division: enter image description here

However, this is not how I'm used to notating polynomial division; I usually drag down all the terms and write them in every line, after each subtraction. For instance, I would like the third line to be -2x^3 + x^2 + 3x - 2 (instead of just -2x^3 + x^2) and the fifth line to be -x^2 + 3x - 2 (instead of just -x^2 + 3x). Is this possible to achieve somehow?

  • This sounds like a major feature request for the polynom package. Have you attempted to contact the package's maintainer(s) to ask if such a feature might be provided? – Mico Oct 26 '14 at 18:27
  • No not yet; I first wanted to ask if it could be solved with the current package. Another question at tex.stackexchange.com/questions/63354/… shows that it is possible to manipulate polynom. But yes, asking the maintainer may be the right thing to do. – Gaussler Oct 26 '14 at 18:38
  • If you are willing to fill in all the steps, you could do the whole thing in a tabular. – John Kormylo Oct 26 '14 at 20:03
4

Of course, the downside is you must build it yourself...

\documentclass{article}
\usepackage{fixltx2e}
\usepackage{tabstackengine}
\stackMath\TABbinary
\newsavebox\tempbox
\newlength\templen
\def\rl#1{%
  \sbox\tempbox{$#1$}%
  \setlength\templen{\wd\tempbox}%
  \llap{\rule{1.5pt}{.1ex}}\rule{\templen}{.1ex}\rlap{\rule{1.5pt}{.1ex}}}
\setstacktabulargap{0pt}
\begin{document}
\tabularShortstack{crcrcrcrcl}{
 &x^4&-&3x^3&+&x^2 &+&3x&-&2 = (x-1)(x^3 - 2x^2 -x +2)\\
-&x^4&+&x^3 & &    & &  & &\\
                              \rl{-}&\rl{x^4}&\rl{-}&\rl{3x^3}&&&&&&\\
 &   &-&2x^3&+&x^2 &+&3x&-&2\\
 &   & &2x^3&-&2x^2& &  & &\\
                              &&&\rl{2x^3}&\rl{-}&\rl{2x^2}&&&&\\
 &   & &    &-&x^2 &+&3x&-&2\\
 &   & &    & &x^2 &-& x& &\\
                              &&&&&\rl{x^2}&\rl{-}&\rl{3x}&&\\
 &   & &    & &    & &2x&-&2\\
 &   & &    & &    &-&2x&+&2\\
                              &&&&&&\rl{-}&\rl{2x}&\rl{+}&\rl{2}\\
 &   & &    & &    & &  & &0
}
\end{document}

enter image description here

If you really wanted to extend the horizontal lines...

\documentclass{article}
\usepackage{fixltx2e}
\usepackage{tabstackengine}
\stackMath\TABbinary
\newsavebox\tempbox
\newlength\templen
\def\rl#1{%
  \sbox\tempbox{$#1$}%
  \setlength\templen{\wd\tempbox}%
  \llap{\rule{1.5pt}{.1ex}}\rule{\templen}{.1ex}\rlap{\rule{1.5pt}{.1ex}}}
\setstacktabulargap{0pt}
\begin{document}
\tabularShortstack{crcrcrcrcrl}{
 &x^4&-&3x^3&+&x^2 &+&3x&-&2& = (x-1)(x^3 - 2x^2 -x +2)\\
-&x^4&+&x^3 & &    & &  & & &\\
                              \rl{-}&\rl{x^4}&\rl{-}&\rl{3x^3}&\rl{+}&\rl{2x^2}&\rl{+}&\rl{3x}&\rl{-}&\rl{2}&\\
 &   &-&2x^3&+&x^2 &+&3x&-&2&\\
 &   & &2x^3&-&2x^2& &  & & &\\
                              &&&\rl{2x^3}&\rl{-}&\rl{2x^2}&\rl{+}&\rl{3x}&\rl{-}&\rl{2}&\\
 &   & &    &-&x^2 &+&3x&-&2&\\
 &   & &    & &x^2 &-& x& & &\\
                              &&&&&\rl{x^2}&\rl{-}&\rl{3x}&\rl{-}&\rl{2}&\\
 &   & &    & &    & &2x&-&2&\\
 &   & &    & &    &-&2x&+&2&\\
                              &&&&&&\rl{-}&\rl{2x}&\rl{+}&\rl{2}&\\
 &   & &    & &    & &  & &0&
}
\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.