On Jun 17, 12:51 pm, William Stein <wst...@gmail.com> wrote: > 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 but interestingly, not always: sage: R.<y>=QQ[] sage: sqrt(y) sqrt(y) sage: y.sqrt() AttributeError: 'Polynomial_rational_dense' object has no attribute 'sqrt' which can lead to rather amusing (and wrong) results: sage: R1=QQ['y'] sage: R2=R1['y'] sage: R1.0*R2.0 y*y sage: sqrt(R1.0*R2.0) sqrt(y^2) -- 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