ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Thu, 30 Aug 2012 18:14:55 +0200Way to make default output numerical not symbolic?https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/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.
Sun, 26 Aug 2012 22:08:33 +0200https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/Comment by DSM for <p>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:</p>
<pre><code>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)
</code></pre>
<p>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.</p>
https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/?comment=19163#post-id-19163I guess you could hack `sage.misc.displayhook` to do this..Mon, 27 Aug 2012 15:19:58 +0200https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/?comment=19163#post-id-19163Comment by kcrisman for <p>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:</p>
<pre><code>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)
</code></pre>
<p>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.</p>
https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/?comment=19171#post-id-19171I 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.Mon, 27 Aug 2012 10:37:16 +0200https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/?comment=19171#post-id-19171Answer by oldbrad for <p>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:</p>
<pre><code>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)
</code></pre>
<p>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.</p>
https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/?answer=13978#post-id-13978Wrap with (..).n() at the appropriate stage eg:
(vector([cos(rd(40)),sin(rd(40))])*60).n()
(45.9626665871387, 38.5672565811924)
or:
v=(vector([cos(rd(40)),sin(rd(40))])*60).n();v
(45.9626665871387, 38.5672565811924)
then:
v.norm()
60.0000000000000
Thu, 30 Aug 2012 18:14:55 +0200https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/?answer=13978#post-id-13978Answer by achrzesz for <p>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:</p>
<pre><code>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)
</code></pre>
<p>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.</p>
https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/?answer=13967#post-id-13967Use RDF ring:
sage: v=vector(RDF,[cos((40)),sin((40))])*60;v
(-40.0162836991, 44.7067896288)
sage: v.norm()
60.0
Mon, 27 Aug 2012 10:39:03 +0200https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/?answer=13967#post-id-13967Comment by kcrisman for <p>Use RDF ring:</p>
<pre><code>sage: v=vector(RDF,[cos((40)),sin((40))])*60;v
(-40.0162836991, 44.7067896288)
sage: v.norm()
60.0
</code></pre>
https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/?comment=19168#post-id-19168This makes the most sense to me, too (or using decimal point as I point out) but I suppose it isn't a "global switch"...Mon, 27 Aug 2012 10:40:15 +0200https://ask.sagemath.org/question/9268/way-to-make-default-output-numerical-not-symbolic/?comment=19168#post-id-19168