Ask Your Question
0

Change output to numerical values globally

asked 2014-10-30 13:45:47 -0500

sagefan gravatar image

updated 2014-10-30 15:24:50 -0500

I know how to make sage to output numerical results as described in http://ask.sagemath.org/question/8150...

However is there a magic line, a global variable or something like that to make sage output the numerical result directly in the following lines?

For example I don't want to type in

n(sin(100))

to get

-0.506365641109

or

n(sqrt(pi()*2))

to get

2.50662827463100

I just want to type sin(100) or sqrt(pi()*2) to get the numerical result.

edit retag flag offensive close merge delete

Comments

Could you please give an example of a computation that you would see to appear numerically ?

tmonteil gravatar imagetmonteil ( 2014-10-30 15:01:15 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2014-10-30 15:29:18 -0500

Hello,

In your case, the representation on the screen is intimately related to the nature of the numbers. If you want numerical output (i.e. floating point numbers), then use numerical input and not (exact) symbolic expressions. For example

sage: pi_approx = RDF(pi)
sage: sin(100.)
-0.506365641109759
sage: sqrt(pi_approx*2)
2.5066282746310002

Vincent

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

Stats

Asked: 2014-10-30 13:45:47 -0500

Seen: 146 times

Last updated: Oct 30 '14