#6482: [with patch, needs review] multivariate polynomial substitution has a
design flaw
---------------------------------+------------------------------------------
 Reporter:  was                  |       Owner:  malb      
     Type:  defect               |      Status:  new       
 Priority:  critical             |   Milestone:  sage-4.1.2
Component:  commutative algebra  |    Keywords:            
 Reviewer:                       |      Author:            
   Merged:                       |  
---------------------------------+------------------------------------------

Comment(by malb):

 '''Performance'''

 {{{
 #!python
 sage: P.<a,b,c,d,e> = PolynomialRing(QQ)
 sage: f = P.random_element(degree=3,terms=50)
 sage: g = {a:b,b:c,c:d,d:e,e:a}
 sage: %timeit f.subs(g)
 1000 loops, best of 3: 271 µs per loop
 }}}

 {{{
 #!python
 sage: phi = P.hom([b,c,d,e,a])
 sage: %timeit phi(f)
 1000 loops, best of 3: 939 µs per loop
 }}}

 {{{
 #!python
 sage: phi(f)
 -a^2*b - 11/2*b^3 - 8*a^2*c + 1/51*b*c^2 + 1/2*c^3 - a^2*d + 1/3*a*b*d -
 2/11*a*c*d + 195*b*c*d + 1/3*a*d^2 + 2*b*d^2 - c*d^2 - 2/3*a^2*e +
 1/2*a*b*e - 203*b^2*e + 1/4*a*c*e + b*c*e - 5*c^2*e + 6*a*e^2 + b*e^2 -
 1/3*c*e^2 - 5*d*e^2 + 3*e^3 + 1/3*a^2 - a*b - 7/48*a*c - 2*b*c - 53/2*c^2
 - 1/3*a*d - 1/2*b*d + c*d - d^2 - a*e - 4*b*e - d*e + 13*e^2 - 2*a - 1/2*b
 - c + 9/2*d - 1/2
 sage: f.sub
 f.sub_m_mul_q  f.subs         f.substitute
 sage: f.subs(g)
 -a^2*b - 11/2*b^3 - 8*a^2*c + 1/51*b*c^2 + 1/2*c^3 - a^2*d + 1/3*a*b*d -
 2/11*a*c*d + 195*b*c*d + 1/3*a*d^2 + 2*b*d^2 - c*d^2 - 2/3*a^2*e +
 1/2*a*b*e - 203*b^2*e + 1/4*a*c*e + b*c*e - 5*c^2*e + 6*a*e^2 + b*e^2 -
 1/3*c*e^2 - 5*d*e^2 + 3*e^3 + 1/3*a^2 - a*b - 7/48*a*c - 2*b*c - 53/2*c^2
 - 1/3*a*d - 1/2*b*d + c*d - d^2 - a*e - 4*b*e - d*e + 13*e^2 - 2*a - 1/2*b
 - c + 9/2*d - 1/2
 }}}

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/6482#comment:5>
Sage <http://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