On Fri, Mar 13, 2009 at 3:19 PM, hpon <peter.norli...@gmail.com> wrote: > > Hi, > > How do I get a numerical value? > > I have a multi-parameter function where all the parameters have been > substituted by numerical values. I want Sage to calculate the > expression's numerical value. At the moment Sage prints: > > 1/sqrt((sqrt(3)/2 - 0.0173205080757)^2 - 0.0001) - "and so on" >
Do you know how to use the documentation? For example, in the notebook, I write : a = sqrt(3) Then, a.<tab> gives me the list of methods available... and you can find numerical_approx which sounds to be what you want... and if you want details of a specific method, just add a question mark at the end. For example: a.numerical_approx? *************************************************** Type: <type 'instancemethod'> Definition: a.numerical_approx(prec, digits) Docstring: Return a numerical approximation of self as either a real or complex number with at least the requested number of bits or digits of precision. NOTE: You can use foo.n() as a shortcut for foo.numerical_approx(). INPUT: prec -- an integer: the number of bits of precision digits -- an integer: digits of precision OUTPUT: A RealNumber or ComplexNumber approximation of self with prec bits of precision. EXAMPLES: sage: cos(3).numerical_approx() -0.989992496600445 Use the n() shortcut: sage: cos(3).n() -0.989992496600445 Higher precision: sage: cos(3).numerical_approx(200) -0.98999249660044545727157279473126130239367909661558832881409 sage: numerical_approx(cos(3), digits=10) -0.9899924966 sage: (i + 1).numerical_approx(32) 1.00000000 + 1.00000000*I sage: (pi + e + sqrt(2)).numerical_approx(100) 7.2740880444219335226246195788 *************************************************** After reading the details, you know you can also use the n() shortcut ;) Hope you will find the answer to your next question by yourself ;) Best, -- Johan --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---