First time here? Check out the FAQ!

Ask Your Question
0

Change output to numerical values globally

asked 10 years ago

sagefan gravatar image

updated 10 years ago

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.

Preview: (hide)

Comments

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

tmonteil gravatar imagetmonteil ( 10 years ago )

1 Answer

Sort by » oldest newest most voted
1

answered 10 years ago

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

Preview: (hide)
link

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: 10 years ago

Seen: 460 times

Last updated: Oct 30 '14