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.Sun, 29 Jun 2014 18:17:39 +0200Problem with sign / sgn and .n()https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/I have an urgent problem with the sign function. I have done a symbolic calculation and want to evaluate the result numerically. The symbolic terms have a sgn() function within, which gives me an error when I try to evaluate the expression numerically. Please find the error below. I do not have the slightest ideas why sage can not evaluate that (simple) expression:
sign(1050*cos(61075634/181449129) + 900).n()
How can i solve that problem?
Thanks a lot in advance,
Best Markus
Error:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_60.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + .....
execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmp4W3s9l/___code___.py", line 4, in <module>
exec compile(u'qwer.n()
File "", line 1, in <module>
File "expression.pyx", line 4053, in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:17894)
TypeError: cannot evaluate symbolic expression numerically
edit by kcrisman: Here's a minimal example:
sage: M = sgn(cos(3/2))
sage: M.n()
It doesn't suffice to do `sgn(cos(1))`, because that turns out to be `1`.Tue, 06 Dec 2011 15:28:55 +0100https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/Comment by Louis Cypher for <p>I have an urgent problem with the sign function. I have done a symbolic calculation and want to evaluate the result numerically. The symbolic terms have a sgn() function within, which gives me an error when I try to evaluate the expression numerically. Please find the error below. I do not have the slightest ideas why sage can not evaluate that (simple) expression: </p>
<p>sign(1050*cos(61075634/181449129) + 900).n()</p>
<p>How can i solve that problem?</p>
<p>Thanks a lot in advance,</p>
<p>Best Markus</p>
<p>Error:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_60.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + .....
execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmp4W3s9l/___code___.py", line 4, in <module>
exec compile(u'qwer.n()
File "", line 1, in <module>
File "expression.pyx", line 4053, in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:17894)
TypeError: cannot evaluate symbolic expression numerically
</code></pre>
<p>edit by kcrisman: Here's a minimal example:</p>
<pre><code>sage: M = sgn(cos(3/2))
sage: M.n()
</code></pre>
<p>It doesn't suffice to do <code>sgn(cos(1))</code>, because that turns out to be <code>1</code>.</p>
https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20652#post-id-20652Thanks for the answers. Would you mind explaining me what a SD 35.5. fodder ist?Thu, 22 Dec 2011 15:28:55 +0100https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20652#post-id-20652Comment by Louis Cypher for <p>I have an urgent problem with the sign function. I have done a symbolic calculation and want to evaluate the result numerically. The symbolic terms have a sgn() function within, which gives me an error when I try to evaluate the expression numerically. Please find the error below. I do not have the slightest ideas why sage can not evaluate that (simple) expression: </p>
<p>sign(1050*cos(61075634/181449129) + 900).n()</p>
<p>How can i solve that problem?</p>
<p>Thanks a lot in advance,</p>
<p>Best Markus</p>
<p>Error:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_60.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + .....
execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmp4W3s9l/___code___.py", line 4, in <module>
exec compile(u'qwer.n()
File "", line 1, in <module>
File "expression.pyx", line 4053, in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:17894)
TypeError: cannot evaluate symbolic expression numerically
</code></pre>
<p>edit by kcrisman: Here's a minimal example:</p>
<pre><code>sage: M = sgn(cos(3/2))
sage: M.n()
</code></pre>
<p>It doesn't suffice to do <code>sgn(cos(1))</code>, because that turns out to be <code>1</code>.</p>
https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20649#post-id-20649OK, thanks. This : http://ask.sagemath.org/question/1014/pi-and-e-not-evaluated-when-i-use-my-own-classes might be a related problem. There are also some sage constants that are not evaluated at all.Thu, 22 Dec 2011 17:37:56 +0100https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20649#post-id-20649Comment by kcrisman for <p>I have an urgent problem with the sign function. I have done a symbolic calculation and want to evaluate the result numerically. The symbolic terms have a sgn() function within, which gives me an error when I try to evaluate the expression numerically. Please find the error below. I do not have the slightest ideas why sage can not evaluate that (simple) expression: </p>
<p>sign(1050*cos(61075634/181449129) + 900).n()</p>
<p>How can i solve that problem?</p>
<p>Thanks a lot in advance,</p>
<p>Best Markus</p>
<p>Error:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_60.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + .....
execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmp4W3s9l/___code___.py", line 4, in <module>
exec compile(u'qwer.n()
File "", line 1, in <module>
File "expression.pyx", line 4053, in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:17894)
TypeError: cannot evaluate symbolic expression numerically
</code></pre>
<p>edit by kcrisman: Here's a minimal example:</p>
<pre><code>sage: M = sgn(cos(3/2))
sage: M.n()
</code></pre>
<p>It doesn't suffice to do <code>sgn(cos(1))</code>, because that turns out to be <code>1</code>.</p>
https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20742#post-id-20742Yup. Problem seems to be that in `M.n??` we see that it's looking for `is_a_numeric(x._gobj)` but apparently that fails, as does the constant, so it thinks we are looking at evaluating `sgn(cos(x))` instead of `sgn(cos(3/2))`. Hopefully Burcin will see this and magically know the answer :) But otherwise it's SD 35.5 fodder!Tue, 06 Dec 2011 20:37:42 +0100https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20742#post-id-20742Comment by kcrisman for <p>I have an urgent problem with the sign function. I have done a symbolic calculation and want to evaluate the result numerically. The symbolic terms have a sgn() function within, which gives me an error when I try to evaluate the expression numerically. Please find the error below. I do not have the slightest ideas why sage can not evaluate that (simple) expression: </p>
<p>sign(1050*cos(61075634/181449129) + 900).n()</p>
<p>How can i solve that problem?</p>
<p>Thanks a lot in advance,</p>
<p>Best Markus</p>
<p>Error:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_60.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + .....
execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmp4W3s9l/___code___.py", line 4, in <module>
exec compile(u'qwer.n()
File "", line 1, in <module>
File "expression.pyx", line 4053, in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:17894)
TypeError: cannot evaluate symbolic expression numerically
</code></pre>
<p>edit by kcrisman: Here's a minimal example:</p>
<pre><code>sage: M = sgn(cos(3/2))
sage: M.n()
</code></pre>
<p>It doesn't suffice to do <code>sgn(cos(1))</code>, because that turns out to be <code>1</code>.</p>
https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20637#post-id-20637@benjaminfjones: did you ever file a report on this? Just curious.Fri, 23 Dec 2011 23:36:27 +0100https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20637#post-id-20637Comment by benjaminfjones for <p>I have an urgent problem with the sign function. I have done a symbolic calculation and want to evaluate the result numerically. The symbolic terms have a sgn() function within, which gives me an error when I try to evaluate the expression numerically. Please find the error below. I do not have the slightest ideas why sage can not evaluate that (simple) expression: </p>
<p>sign(1050*cos(61075634/181449129) + 900).n()</p>
<p>How can i solve that problem?</p>
<p>Thanks a lot in advance,</p>
<p>Best Markus</p>
<p>Error:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_60.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + .....
execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmp4W3s9l/___code___.py", line 4, in <module>
exec compile(u'qwer.n()
File "", line 1, in <module>
File "expression.pyx", line 4053, in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:17894)
TypeError: cannot evaluate symbolic expression numerically
</code></pre>
<p>edit by kcrisman: Here's a minimal example:</p>
<pre><code>sage: M = sgn(cos(3/2))
sage: M.n()
</code></pre>
<p>It doesn't suffice to do <code>sgn(cos(1))</code>, because that turns out to be <code>1</code>.</p>
https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20743#post-id-20743That looks like a bug to me. I'll see if I can track it down and file a bug report. Tue, 06 Dec 2011 18:57:17 +0100https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20743#post-id-20743Comment by DSM for <p>I have an urgent problem with the sign function. I have done a symbolic calculation and want to evaluate the result numerically. The symbolic terms have a sgn() function within, which gives me an error when I try to evaluate the expression numerically. Please find the error below. I do not have the slightest ideas why sage can not evaluate that (simple) expression: </p>
<p>sign(1050*cos(61075634/181449129) + 900).n()</p>
<p>How can i solve that problem?</p>
<p>Thanks a lot in advance,</p>
<p>Best Markus</p>
<p>Error:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_60.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + .....
execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmp4W3s9l/___code___.py", line 4, in <module>
exec compile(u'qwer.n()
File "", line 1, in <module>
File "expression.pyx", line 4053, in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:17894)
TypeError: cannot evaluate symbolic expression numerically
</code></pre>
<p>edit by kcrisman: Here's a minimal example:</p>
<pre><code>sage: M = sgn(cos(3/2))
sage: M.n()
</code></pre>
<p>It doesn't suffice to do <code>sgn(cos(1))</code>, because that turns out to be <code>1</code>.</p>
https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20651#post-id-20651@Louis Cypher: "SD" stands for Sage Days, workshops at which Sage development is done. Fodder is food for animals, or in this context "something to do at the workshop". See http://wiki.sagemath.org/days35.5Thu, 22 Dec 2011 15:57:54 +0100https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?comment=20651#post-id-20651Answer by rws for <p>I have an urgent problem with the sign function. I have done a symbolic calculation and want to evaluate the result numerically. The symbolic terms have a sgn() function within, which gives me an error when I try to evaluate the expression numerically. Please find the error below. I do not have the slightest ideas why sage can not evaluate that (simple) expression: </p>
<p>sign(1050*cos(61075634/181449129) + 900).n()</p>
<p>How can i solve that problem?</p>
<p>Thanks a lot in advance,</p>
<p>Best Markus</p>
<p>Error:</p>
<pre><code>Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_60.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + .....
execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmp4W3s9l/___code___.py", line 4, in <module>
exec compile(u'qwer.n()
File "", line 1, in <module>
File "expression.pyx", line 4053, in sage.symbolic.expression.Expression._numerical_approx (sage/symbolic/expression.cpp:17894)
TypeError: cannot evaluate symbolic expression numerically
</code></pre>
<p>edit by kcrisman: Here's a minimal example:</p>
<pre><code>sage: M = sgn(cos(3/2))
sage: M.n()
</code></pre>
<p>It doesn't suffice to do <code>sgn(cos(1))</code>, because that turns out to be <code>1</code>.</p>
https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?answer=23130#post-id-23130I have reported this as http://trac.sagemath.org/ticket/16587Sun, 29 Jun 2014 18:17:39 +0200https://ask.sagemath.org/question/8535/problem-with-sign-sgn-and-n/?answer=23130#post-id-23130