-
-
Notifications
You must be signed in to change notification settings - Fork 12.2k
ENH: add numerically robust polygcd function for numerical calculation of polynomial greatest common divisor #4829
Copy link
Copy link
Open
Description
GCD for polynomials is an important operation for computing sums of polynomial ratios A(x)/B(x) + C(x)/D(x). The naive approach to computing GCD(B(x),D(x)) is numerically ill-conditioned:
import numpy as np
def polygcd(a,b):
'''return monic GCD of polynomials a and b'''
pa = a
pb = b
M = lambda x: x/x[0]
# find gcd of a and b
while len(pb) > 1 or pb[0] != 0:
# Danger Will Robinson! requires numerical equality
q,r = np.polydiv(pa,M(pb))
pa = pb
pb = r
return M(pa)
def polylcm(a,b):
'''return (Ka,Kb,c) such that c = LCM(a,b) = Ka*a = Kb*b'''
gcd = polygcd(a,b)
Ka,_ = np.polydiv(b,gcd)
Kb,_ = np.polydiv(a,gcd)
return (Ka,Kb,np.polymul(Ka,a))
I figured there was an easy workaround that would be more robust, but apparently there isn't. There is some promising literature on the subject (see below), but I'm woefully underskilled for porting these algorithms to numpy, much less understanding how they work:
- http://math.univ-lille1.fr/~bbecker/ano/pub/1997/ano369.pdf
- http://www.mathcs.emory.edu/~boito/newfifthspecial.pdf
- http://www.mathcs.emory.edu/~boito/thesis.pdf
- http://www.mathcs.emory.edu/~boito/fast_gcd_wls.m [matlab code]
- https://who.rocq.inria.fr/Jan.Elias/pdf/je_masterthesis.pdf
- http://ieeexplore.ieee.org/xpls/abs_all.jsp?arnumber=875462
- http://www.mmrc.iss.ac.cn/pub/mm21.pdf/zhi1.pdf
- http://arxiv.org/pdf/1207.0630v2.pdf
- http://www.neiu.edu/~zzeng/
- http://www.neiu.edu/~zzeng/uvgcd.pdf
- http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.27.4881
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels