The distinction that may be worth making is that there are (at least) two notions of factorial. One that is subject to symbolic simplification and one that is a numerical subroutine. There may be yet more.
The simplification version allows for factorial(n+1)/factorial(n) ---> n+1 and does not require anything much from n. The evaluation version only works for factorial(n) if n is a number. You could, I suppose, have an evaluation version that refuses to evaluate factorial on arguments where the result is not exactly representable, and therefore returns factorial(13/5) etc. On Jun 17, 3:15 pm, Florent Hivert <florent.hiv...@univ-rouen.fr> wrote: > Hi there, > > > > > > In Sage, the behavior of sqrt(2) versus sqrt(4) is considered very > > > reasonable > > > to most users. And it does exactly what you claim is "rather bad form". > > > > sage: sqrt(2) > > > sqrt(2) > > > sage: sqrt(4) > > > 2 > > > sage: type(sqrt(2)) > > > <type 'sage.symbolic.expression.Expression'> > > > sage: type(sqrt(4)) > > > <type 'sage.rings.integer.Integer'> > > > That clears things up. Thank you. I'm disappointed. This looks like > > it's rather deeply ingrained in the system. It's not just a > > convenience top-level sqrt that chooses output types, the "sqrt" > > method on integers does the same: > > > sage: 3.sqrt().parent() > > Symbolic Ring > > sage: 4.sqrt().parent() > > Integer Ring > > I quite agree with Nils. If there is a chance to change it without breaking to > much things, my vote would be the following: > > The *function* sqrt as a top level convenience could keep it's current > behavior, but on the contrary to the current behavior, the *method* sqrt > should not change the class/Parent of its result depending on its value: > - ZZ(4).sqrt() should return ZZ(2) > - ZZ(3).sqrt() should raise a ValueError > The current result of sqrt(3) should be computed by > - SR(3).sqrt() > > By the way, why choosing SR and not QQbar ? > > Cheers, > > Florent -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org