#9463: Integer factorization should handle perfect powers efficiently
---------------------------------+------------------------------------------
   Reporter:  fredrik.johansson  |       Owner:  AlexGhitza
       Type:  defect             |      Status:  new       
   Priority:  major              |   Milestone:            
  Component:  basic arithmetic   |    Keywords:            
     Author:                     |    Upstream:  N/A       
   Reviewer:                     |      Merged:            
Work_issues:                     |  
---------------------------------+------------------------------------------
 factor() is extremely slow at factoring large perfect powers (with a
 nontrivial base).
 {{{
 sage: %time factor(next_prime(10^20)^150)
 CPU times: user 0.75 s, sys: 0.00 s, total: 0.75 s
 Wall time: 0.75 s
 100000000000000000039^150
 sage: %time factor(next_prime(10^20)^250)
 CPU times: user 2.68 s, sys: 0.00 s, total: 2.68 s
 Wall time: 2.69 s
 100000000000000000039^250
 sage: %time factor(next_prime(10^20)^500)
 CPU times: user 13.19 s, sys: 0.00 s, total: 13.19 s
 Wall time: 13.20 s
 100000000000000000039^500
 }}}
 For comparison, !SymPy handles such numbers in an instant:
 {{{
 sage: from sympy import factorint
 sage: %time factorint(next_prime(10^20)^150)
 CPU times: user 0.01 s, sys: 0.00 s, total: 0.01 s
 Wall time: 0.01 s
 {100000000000000000039L: 150}
 sage: %time factorint(next_prime(10^20)^250)
 CPU times: user 0.01 s, sys: 0.00 s, total: 0.01 s
 Wall time: 0.01 s
 {100000000000000000039L: 250}
 sage: %time factorint(next_prime(10^20)^500)
 CPU times: user 0.02 s, sys: 0.00 s, total: 0.02 s
 Wall time: 0.02 s
 {100000000000000000039L: 500}
 }}}
 Perfect power testing is very cheap, so it should be attempted early on
 for large numbers.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9463>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/sage-trac?hl=en.

Reply via email to