# HG changeset patch
# User Leif Leonhardy <not.really@online.de>
# Date 1316997296 14400
# Node ID f90ca63a24aa33de0f6bd25935797f3692ebdce9
# Parent 10f49e34d981dccab46b3c81dc60a14f0ee2d747
#7852 Reviewer patch: Fix doctest errors due to noisy zero terms in polynomials.
diff git a/sage/rings/polynomial/polynomial_element.pyx b/sage/rings/polynomial/polynomial_element.pyx
a

b


1023  1023  sage: R.<x> = RDF[] 
1024  1024  sage: f = inverse_mod(x^2 + 1, x^5 + x + 1); f 
1025  1025  0.4*x^4  0.2*x^3  0.4*x^2 + 0.2*x + 0.8 
1026   sage: f * (x^2 + 1) % (x^5 + x + 1) 
 1026  sage: poly = f * (x^2 + 1) % (x^5 + x + 1) 
 1027  sage: # Remove noisy zero terms: 
 1028  sage: parent(poly)([ 0.0 if abs(c)<=1e15 else c for c in poly.coeffs() ]) 
1027  1029  1.0 
1028  1030  sage: f = inverse_mod(x^3  x + 1, x  2); f 
1029  1031  0.142857142857 
… 
… 

1031  1033  1.0 
1032  1034  sage: g = 5*x^3+x7; m = x^412*x+13; f = inverse_mod(g, m); f 
1033  1035  0.0319636125...*x^3  0.0383269759...*x^2  0.0463050900...*x + 0.346479687... 
1034   sage: f*g % m 
1035   8.881784...e16*x^3 + 8.881784...e16*x^2  8.881784...e16*x + 1.0 
 1036  sage: poly = f*g % m 
 1037  sage: # Remove noisy zero terms: 
 1038  sage: parent(poly)([ 0.0 if abs(c)<=1e15 else c for c in poly.coeffs() ]) 
 1039  1.0 
1036  1040  
1037  1041  ALGORITHM: Solve the system as + mt = 1, returning s as the inverse 
1038  1042  of a mod m. 