#7742: add a compose function to sage
------------------------------------------------+---------------------------
   Reporter:  was                               |       Owner:  AlexGhitza
       Type:  defect                            |      Status:  needs_work
   Priority:  major                             |   Milestone:  sage-4.6.1
  Component:  basic arithmetic                  |    Keywords:            
     Author:  Christopher Olah, Felix Lawrence  |    Upstream:  N/A       
   Reviewer:  Paul Zimmermann                   |      Merged:            
Work_issues:                                    |  
------------------------------------------------+---------------------------
Changes (by zimmerma):

  * status:  needs_review => needs_work


Comment:

 I am not very happy with the fact that when f is an expression, the code
 assumes it has exactly
 one symbolic variable:
 {{{
 sage: f = 2
 sage: self_compose(f,0)
 <function <lambda> at 0x41031b8>
 sage: self_compose(f,1)
 2
 sage: self_compose(f,2)
 <function <lambda> at 0x7fa8ac2b0d70>
 }}}
 or
 {{{
 sage: f = x+y
 sage: self_compose(f,0)
 x
 sage: self_compose(f,1)
 x + y
 sage: self_compose(f,2)
 x + 2*y
 }}}
 Consider also:
 {{{
 sage: f = pi+1
 sage: self_compose(f,0)
 ---------------------------------------------------------------------------
 IndexError                                Traceback (most recent call
 last)

 /tmp/cado-nfs-1.0-rc1/<ipython console> in <module>()

 /usr/local/sage-4.6/sage/local/lib/python2.6/site-
 packages/sage/misc/misc.pyc in self_compose(f, n)
     911     if n == 0:
     912         if type(f) == sage.symbolic.expression.Expression:
 --> 913             return f.parent()(f.variables()[0])
     914         else:
     915             return lambda x: x

 IndexError: tuple index out of range
 }}}

 I would prefer that symbolic expressions such as {{{f=x+1}}} are not
 allowed,
 and we should write instead {{{f(x)=x+1}}} or {{{f = lambda x : x+1}}}.

 Paul

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