Polynomial long division: Difference between revisions
Content added Content deleted
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: | 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. |
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 could be: |
Then a pseudocode for the polynomial long division using the conventions described above could be: |
||
degree('''P'''): |
degree('''P'''): |
||
Line 32: | Line 32: | ||
* Error handling (for allocations or for wrong inputs) is not mandatory. |
* 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''' |
'''Example for clarification''' |