Ticket #7852: trac_7852-fix_noise_errors_in_polys.reviewer.patch

File trac_7852-fix_noise_errors_in_polys.reviewer.patch, 1.6 KB (added by leif, 10 years ago)

Reviewer patch. Apply on top of main patch, which causes doctests to fail on a couple of systems due to noisy zero terms.

  • sage/rings/polynomial/polynomial_element.pyx

    # 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  
    10231023            sage: R.<x> = RDF[]
    10241024            sage: f = inverse_mod(x^2 + 1, x^5 + x + 1); f
    10251025            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)<=1e-15 else c for c in poly.coeffs() ])
    10271029            1.0
    10281030            sage: f = inverse_mod(x^3 - x + 1, x - 2); f
    10291031            0.142857142857
     
    10311033            1.0
    10321034            sage: g = 5*x^3+x-7; m = x^4-12*x+13; f = inverse_mod(g, m); f
    10331035            -0.0319636125...*x^3 - 0.0383269759...*x^2 - 0.0463050900...*x + 0.346479687...
    1034             sage: f*g % m
    1035             -8.881784...e-16*x^3 + 8.881784...e-16*x^2 - 8.881784...e-16*x + 1.0
     1036            sage: poly = f*g % m
     1037            sage: # Remove noisy zero terms:
     1038            sage: parent(poly)([ 0.0 if abs(c)<=1e-15 else c for c in poly.coeffs() ])
     1039            1.0
    10361040
    10371041        ALGORITHM: Solve the system as + mt = 1, returning s as the inverse
    10381042        of a mod m.