Ask Your Question
0

Change output to numerical values globally

asked 2014-10-30 19:45:47 +0100

sagefan gravatar image

updated 2014-10-30 21:24:50 +0100

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 21:01:15 +0100 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2014-10-30 21:29:18 +0100

vdelecroix gravatar image

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 19:45:47 +0100

Seen: 409 times

Last updated: Oct 30 '14