1
$\begingroup$

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"}]}
$\endgroup$

1 Answer 1

0
$\begingroup$

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
$\endgroup$
2
  • $\begingroup$ Can you please show how to call this from within the Wolfram Language & Mathematica? Thanks! $\endgroup$ Feb 5, 2022 at 20:11
  • $\begingroup$ You can use RunProcess[$SystemShell, "StandardOutput", "ruby pd.rb '3,0,0,1,1' '4,0,3' 5 x"] But you have to comment line 260 and other code lines that produce undesired output. If it doesn't work use StandardError instead of StandardOutput. ExternalEvaluate might also be an option if you really want to run the code from within Mathematica. $\endgroup$
    – Uwe Gotzes
    Feb 7, 2022 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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