#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:                                    |  
------------------------------------------------+---------------------------

Comment(by zimmerma):

 Replying to [comment:12 flawrence]:

 > * compose(f,g)(x) = f(g(x)) - is this the most common convention among
 mathematicians? or should the RHS be g(f(x))?

 compose(f,g) seems good to me.

 > * Is (f, n, a) or (f, a, n) the best order of parameters for nest?

 I prefer (f,n,a) since this is coherent with {{{self_compose(f,n)}}}.

 > * Is there somewhere more suitable than misc/misc.py for these
 functions?

 I don't know.

 Also if a symbolic n is not allowed (yet) in {{{self_compose}}}, some
 type-checking
 should be done:
 {{{
 sage: function('f')
 sage: var('m')
 sage: self_compose(f,m)(x)
 ---------------------------------------------------------------------------
 TypeError                                 Traceback (most recent call
 last)

 /localdisk/tmp/sage-4.6/<ipython console> in <module>()

 /localdisk/tmp/sage-4.6/local/lib/python2.6/site-
 packages/sage/misc/misc.pyc in self_compose(f, n)
     890     # all necessary powers of two (f, f^2, f^4), storing them in a
 list
     891     fs = [f]
 --> 892     for i in xrange(int(floor(log(n, 2)))):
     893         fs.append(compose(fs[i], fs[i]))
     894

 /localdisk/tmp/sage-4.6/local/lib/python2.6/site-
 packages/sage/symbolic/expression.so in
 sage.symbolic.expression.Expression.__float__
 (sage/symbolic/expression.cpp:5398)()

 TypeError: unable to simplify to float approximation
 }}}

 Paul

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