# Formatting results of a polynomial long division (Extension for finite fields)

I've just read Formatting results of a polynomial long division with great interest. For my teaching purposes it would be great to enable the code given in that post to treat polynomial division with coefficients from a finite field. Is there a simple way to do that?

Code:

Column@{WolframAlpha["polynomial long division (y^3-6y+20)/(y-3)",{{"QuotientAndRemainder", 1}, "Content"}, PodStates -> {"QuotientAndRemainder__Step-by-step solution"}], WolframAlpha["polynomial long division (y^3-6y+20)/(y-3)", {{"QuotientAndRemainder", 2}, "Content"}, PodStates -> {"QuotientAndRemainder__Step-by-step solution"}]}


It seems, there is no easy solution. I wrote a ruby script that fulfills the task. It produces command line and latex output. It can be downloaded from https://github.com/demogorgi/polynomialLongDivision

Example:

Arguments are dividend, divisor, charakteristic of the finite field, variable symbol

>ruby pd.rb "3,0,0,1,1" "4,0,3" 5 x


yields (among other things):

  (   1x⁴ + 1x³             + 3  ) : (   3x²       + 4  ) =    2x² + 2x  + 4
- (   1x⁴       + 3x² )
-------------------------------------------------------------
1x³ + 2x²
- (   1x³       + 3x )
-------------------------------------------------------------
2x² + 2x  + 3
- (   2x²       + 1 )
-------------------------------------------------------------
2x  + 2