On May 21, 7:24 pm, Yi Qiang <[EMAIL PROTECTED]> wrote: > On May 21, 2007, at 7:18 PM, Brian Harris wrote: > > > > > Fair enough. A previous discussion led me to believe the goal was for > > more transparent rings. Have you considered supporting something like > > the following? > > > cos(3).toreal()
There (kind of) already is such a method: Definition: a._mpfr_(self, field) Docstring: Coerce to a multiprecision real number. EXAMPLES: sage: RealField(100)(sin(2)+cos(2)) 0.49315059027853930839845163641 sage: RR(sin(pi)) 0.000000000000000 sage: type(RR(sqrt(163)*pi)) <type 'sage.rings.real_mpfr.RealNumber'> sage: RR(coth(pi)) 1.00374187319732 sage: RealField(100)(coth(pi)) 1.0037418731973212882015526912 sage: RealField(200)(acos(1/10)) 1.4706289056333368228857985121870581235299087274579233690964 however, it's confusing to remember that name. Ideally, you're supposed to do RR() to perform coercion. However, that might confuse people who haven't read the tutorial, so I've written a .to_real() method, which by default will use RealField(53), but if you give it a field or an integer, it will approximate to that precision. So cos(3).to_real(2000) will give you cos(3) to 2000 digits of precision. I'll send it to William in my next patch. > I would second this suggestion. I was also confused as how to get a > numerical approximation when I first started using sage. Since SAGE is python, numerical approximations are done by object coercion. The standard way you perform type coercion in SAGE is by __call__ing the parent object, which will be some sort of algebraic structure, like a ring. Although we're trying to get away from requiring users to have knowledge of abstract algebra, I think it's a safe bet that most potential SAGE users know about the set of real numbers. Also, to do anything nontrivial in SAGE, you probably need to understand the concept of object and type... > > On May 21, 9:12 pm, David Joyner <[EMAIL PROTECTED]> wrote: > >> Brian Harris wrote: > >>> How can I get sage to print the numeric value of an expression such > >>> as, cos(3)? > > >> sage: cos(3) > >> cos(3) > >> sage: RR(cos(3)) > >> -0.989992496600445 > > >>> Also is there a way to switch between 'radian' and 'degree' modes > >>> like > >>> in some calculators? I'm not sure whether we should add support for this or not... how useful would it be? Do any of the M's do this? Thanks for the input and feedback, ~Bobby --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://sage.math.washington.edu/sage/ and http://sage.scipy.org/sage/ -~----------~----~----~----~------~----~------~--~---