Changeset 7486:b75f20360b8d


Ignore:
Timestamp:
11/27/07 17:59:55 (5 years ago)
Author:
Carl Witty <cwitty@…>
Branch:
default
Message:

Avoid the "find roots by factoring" algorithm if the coefficient ring is not an integral domain.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • sage/rings/polynomial/polynomial_element.pyx

    r7471 r7486  
    24202420            [(I, 3), (-2^(1/4), 1), (2^(1/4), 1), (1, 1)] 
    24212421 
    2422         An example where the base ring doesn't have a factorization 
    2423         algorithm (yet).  Note that this is currently done via naive 
    2424         enumeration, so could be very slow: 
     2422        A couple of examples where the base ring doesn't have a 
     2423        factorization algorithm (yet).  Note that this is currently 
     2424        done via naive enumeration, so could be very slow: 
    24252425            sage: R = Integers(6) 
    24262426            sage: S.<x> = R['x'] 
     
    24322432            sage: p.roots(multiplicities=False) 
    24332433            [1, 5] 
     2434            sage: R = Integers(9) 
     2435            sage: A = PolynomialRing(R, 'y') 
     2436            sage: y = A.gen() 
     2437            sage: f = 10*y^2 - y^3 - 9 
     2438            sage: f.roots(multiplicities=False) 
     2439            [0, 1, 3, 6] 
    24342440 
    24352441        An example over the complex double field (where root finding 
     
    25992605        .change_ring(L) and proceed as below. 
    26002606 
    2601         The next method is to attempt to factor the polynomial. 
    2602         If this succeeds, then for every degree-one factor a*x+b, we 
    2603         add -b/a as a root (as long as this quotient is actually in 
    2604         the desired ring). 
    2605  
    2606         If factoring over K is not implemented, and K is finite, then 
    2607         we find the roots by enumerating all elements of K and checking 
    2608         whether the polynomial evaluates to zero at that value. 
     2607        The next method, which is used if K is an integral domain, is 
     2608        to attempt to factor the polynomial.  If this succeeds, then 
     2609        for every degree-one factor a*x+b, we add -b/a as a root (as 
     2610        long as this quotient is actually in the desired ring). 
     2611 
     2612        If factoring over K is not implemented (or K is not an 
     2613        integral domain), and K is finite, then we find the roots by 
     2614        enumerating all elements of K and checking whether the 
     2615        polynomial evaluates to zero at that value. 
    26092616         
    26102617 
     
    27672774 
    27682775        try: 
    2769             rts = self.factor() 
     2776            if K.is_integral_domain(): 
     2777                rts = self.factor() 
     2778            else: 
     2779                raise NotImplementedError 
    27702780        except NotImplementedError: 
    27712781            if K.is_finite(): 
Note: See TracChangeset for help on using the changeset viewer.