Anonymous user
Polynomial long division: Difference between revisions
m
a bit more formatting of the header matter
m (tighten up some formatting) |
m (a bit more formatting of the header matter) |
||
Line 1:
{{task|Classic CS problems and programs}}{{Wikipedia}}
:<cite>In algebra, [[wp:Polynomial long division|polynomial long division]] is an algorithm for dividing a polynomial by another polynomial of the same or lower degree.</cite>
Let us suppose a polynomial is represented by a vector, <math>x</math> (i.e.
Then a pseudocode for the polynomial long division could be:
Line 10 ⟶ 9:
'''return''' the index of the last non-zero element of '''P''';
if all elements are 0, return -∞
polynomial_long_division('''N''', '''D''') ''returns'' ('''q''', '''r'''):
<span class="co1">// '''N''', '''D''', '''q''', '''r''' are vectors</span>
Line 33 ⟶ 32:
* Error handling (for allocations or for wrong inputs) is not mandatory.
'''Example for clarification'''
<br>
This example is from Wikipedia, but changed to show how the given pseudocode works.
|