Polynomial long division: Difference between revisions

Content deleted Content added
m added notes to "allow" workinprogress octave (and ocaml?) impl, which use(s) the (alas!) better convention to keep the "highest" power coeff first
Line 4:
Let us suppose a polynomial is represented by a vector, <math>x</math> (i.e., an ordered collection of [[wp:Coefficient|coefficients]]) so that the <math>i</math><sup>th</sup> element keeps the coefficient of <math>x^i</math>, and the multiplication by a monomial is a ''shift'' of the vector's elements "towards right" (injecting zeros from left) followed by a multiplication of each element by the coefficient of the monomial.
 
Then a pseudocode for the polynomial long division using the conventions described above could be:
 
degree('''P'''):
Line 32:
 
* Error handling (for allocations or for wrong inputs) is not mandatory.
* Conventions can be different; in particular, note that if the first coefficient in the vector is the highest power of x for the polynomial represented by the vector, then the algorithm becomes simpler and shifting can be avoided.
 
'''Example for clarification'''