Polynomial synthetic division: Difference between revisions
m
→{{header|Python}}: ahora funciona en Python 2.7 y 3.x
m (→{{header|Python}}: ahora funciona en Python 2.7 y 3.x) |
|||
Line 579:
=={{header|Python}}==
Here is an extended synthetic division algorithm, which means that it supports a divisor polynomial (instead of just a monomial/binomial). It also supports non-monic polynomials (polynomials which first coefficient is different than 1). Polynomials are represented by lists of coefficients with decreasing degree (left-most is the major degree , right-most is the constant).
{{works with|Python 2.
{{works with|Python 3.x}}
<lang python>from __future__ import print_function
from __future__ import division
#!/usr/bin/python
# coding=UTF-8
def extended_synthetic_division(dividend, divisor):
Line 604 ⟶ 609:
if __name__ == '__main__':
print
N = [1, -12, 0, -42]
D = [1, -3]
print
</lang>
Line 614 ⟶ 618:
<pre>
POLYNOMIAL SYNTHETIC DIVISION
[1, -12, 0, -42] / [1, -3] = [1, -9, -27] remainder [-123]
</pre>
|