Polynomial long division: Difference between revisions

Content added Content deleted
(Added Delphi example)
(Undo revision 105246 by 75.149.84.28 (talk) [This change resulted in the wrong result])
Line 2,693: Line 2,693:


from itertools import izip
from itertools import izip
from math import fabs


def degree(poly):
def degree(poly):
Line 2,710: Line 2,709:
mult = q[dN - dD] = N[-1] / float(d[-1])
mult = q[dN - dD] = N[-1] / float(d[-1])
d = [coeff*mult for coeff in d]
d = [coeff*mult for coeff in d]
N = [fabs ( coeffN - coeffd ) for coeffN, coeffd in izip(N, d)]
N = [coeffN - coeffd for coeffN, coeffd in izip(N, d)]
dN = degree(N)
dN = degree(N)
r = N
r = N