Ask Your Question

Way to make default output numerical not symbolic?

asked 2012-08-26 22:08:33 +0200

Eman27 gravatar image

Is there a way I can set a flag so sage's default output is numerical instead of symbolic? I'm looking to set a flag so I can do something like this:

sage: vector([cos(rd(40)),sin(rd(40))])*60
(60*cos(2/9*pi), 60*sin(2/9*pi))
sage: set numerical=true
sage: vector([cos(rd(40)),sin(rd(40))])*60
(45.9626665871387, 38.5672565811924)

I know that I can use n(generic_varible) or generic_variable.n() but when I'm doing my homework it's very time consuming, because it involves either a lot of switching or a lot of writing.

edit retag flag offensive close merge delete


I don't think this is possible per se, unless you do something naughty like `Integer = RR`. Keep in mind that you can also just add a decimal point `cos(rd(40.))` and that will do most of what you want, though it's not really an "answer" to your question.

kcrisman gravatar imagekcrisman ( 2012-08-27 10:37:16 +0200 )edit

I guess you could hack `sage.misc.displayhook` to do this..

DSM gravatar imageDSM ( 2012-08-27 15:19:58 +0200 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2012-08-27 10:39:03 +0200

achrzesz gravatar image

Use RDF ring:

sage: v=vector(RDF,[cos((40)),sin((40))])*60;v
(-40.0162836991, 44.7067896288)
sage: v.norm()                                
edit flag offensive delete link more


This makes the most sense to me, too (or using decimal point as I point out) but I suppose it isn't a "global switch"...

kcrisman gravatar imagekcrisman ( 2012-08-27 10:40:15 +0200 )edit

answered 2012-08-30 18:14:55 +0200

oldbrad gravatar image

Wrap with (..).n() at the appropriate stage eg:

(45.9626665871387, 38.5672565811924)


(45.9626665871387, 38.5672565811924)


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


Asked: 2012-08-26 22:08:33 +0200

Seen: 897 times

Last updated: Aug 30 '12