ASKSAGE: Sage Q&A Forum - Individual question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Mon, 18 Feb 2019 10:27:21 -0600Unable to calculate numeric output of calculation with RIFs? Bug?http://ask.sagemath.org/question/45464/unable-to-calculate-numeric-output-of-calculation-with-rifs-bug/reworked question, same worksheet in cocalc.
this is my code:
g=solve(e_Ersatz/(2*d_k)==e_s/d_e, d_k)
print g
show(g[0].subs({
d_e: RIF(.999,1.001),
d_m: RIF(.25,.1),
e_m: e_0 * RIF(80.5,81.5),
e_s: e_0 * RIF(3,4)
}))
f=g[0].subs({
d_e: RIF(.999,1.001),
d_m: RIF(.25,.1),
e_m: e_0 * RIF(80.5,81.5),
e_s: e_0 * RIF(3,4)
})
#show( n(f) )
this is g:
[
d_k == (d_e*d_m*e_m - (d_e*d_m + 2*d_m^2)*e_s)/(d_e*e_m - 2*d_m*e_s)
]
So its not really complicated, a little summation, some factors, a square. Nothing I could not do manually, even with the error propagtion.
But when trying to get the RIF equvalent I get
*** WARNING: Code contains possible implicit multiplication ***
*** Check if any of [ 5e, 5e ] need a "*" sign for multiplication, e.g. 5x should be 5*x ! ***
Error in lines 82-82
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
flags=compile_flags) in namespace, locals
File "", line 1, in <module>
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/misc/functional.py", line 1419, in numerical_approx
return n(prec, algorithm=algorithm)
File "sage/symbolic/expression.pyx", line 5981, in sage.symbolic.expression.Expression.numerical_approx (build/cythonized/sage/symbolic/expression.cpp:34636)
raise TypeError("cannot evaluate symbolic expression numerically")
TypeError: cannot evaluate symbolic expression numerically
Hu? Am I missing something fundamental? Is this a bug?
================
old question:
This is my worksheet:
https://cocalc.com/share/f7766c5e-2f4d-4916-bb0d-74a7182e5fd5/2019-02-09-203517.sagews?viewer=share
I have an equation that I insert some numeric values into. Because I need to estimate the range of uncertainty, I specify the values as RIF numbers:
d[0].subs(
d_e == RIF(.999,1.001),
x ==.25,
d_m == RIF(.05,.15),
U == RIF(10^-9,1.02*10^-9),
e_m == e_0 * RIF(80.5,81.5),
e_s == e_0 * RIF(3,4)
)
However, in the output that range is not expressed. Is that becaues there are remaining symbolic parameters?Thu, 14 Feb 2019 11:09:01 -0600http://ask.sagemath.org/question/45464/unable-to-calculate-numeric-output-of-calculation-with-rifs-bug/Comment by dan_fulea for <p>reworked question, same worksheet in cocalc.</p>
<p>this is my code:</p>
<pre><code>g=solve(e_Ersatz/(2*d_k)==e_s/d_e, d_k)
print g
show(g[0].subs({
d_e: RIF(.999,1.001),
d_m: RIF(.25,.1),
e_m: e_0 * RIF(80.5,81.5),
e_s: e_0 * RIF(3,4)
}))
f=g[0].subs({
d_e: RIF(.999,1.001),
d_m: RIF(.25,.1),
e_m: e_0 * RIF(80.5,81.5),
e_s: e_0 * RIF(3,4)
})
#show( n(f) )
</code></pre>
<p>this is g:</p>
<pre><code>[
d_k == (d_e*d_m*e_m - (d_e*d_m + 2*d_m^2)*e_s)/(d_e*e_m - 2*d_m*e_s)
]
</code></pre>
<p>So its not really complicated, a little summation, some factors, a square. Nothing I could not do manually, even with the error propagtion. </p>
<p>But when trying to get the RIF equvalent I get </p>
<pre><code>*** WARNING: Code contains possible implicit multiplication ***
*** Check if any of [ 5e, 5e ] need a "*" sign for multiplication, e.g. 5x should be 5*x ! ***
Error in lines 82-82
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
flags=compile_flags) in namespace, locals
File "", line 1, in <module>
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/misc/functional.py", line 1419, in numerical_approx
return n(prec, algorithm=algorithm)
File "sage/symbolic/expression.pyx", line 5981, in sage.symbolic.expression.Expression.numerical_approx (build/cythonized/sage/symbolic/expression.cpp:34636)
raise TypeError("cannot evaluate symbolic expression numerically")
TypeError: cannot evaluate symbolic expression numerically
</code></pre>
<p>Hu? Am I missing something fundamental? Is this a bug?</p>
<p>================
old question:</p>
<p>This is my worksheet:
<a href="https://cocalc.com/share/f7766c5e-2f4d-4916-bb0d-74a7182e5fd5/2019-02-09-203517.sagews?viewer=share">https://cocalc.com/share/f7766c5e-2f4...</a></p>
<p>I have an equation that I insert some numeric values into. Because I need to estimate the range of uncertainty, I specify the values as RIF numbers:</p>
<pre><code>d[0].subs(
d_e == RIF(.999,1.001),
x ==.25,
d_m == RIF(.05,.15),
U == RIF(10^-9,1.02*10^-9),
e_m == e_0 * RIF(80.5,81.5),
e_s == e_0 * RIF(3,4)
)
</code></pre>
<p>However, in the output that range is not expressed. Is that becaues there are remaining symbolic parameters?</p>
http://ask.sagemath.org/question/45464/unable-to-calculate-numeric-output-of-calculation-with-rifs-bug/?comment=45500#post-id-45500The following works for me:
var('d_e d_m e_m e_s U x');
g = \
[
d_k == (d_e*d_m*e_m - (d_e*d_m + 2*d_m^2)*e_s)/(d_e*e_m - 2*d_m*e_s)
]
d = g
d[0].subs(
d_e == RIF(.999,1.001),
x ==.25,
d_m == RIF(.05,.15),
U == RIF(10^-9,1.02*10^-9),
e_m == e_0 * RIF(80.5,81.5),
e_s == e_0 * RIF(3,4)
)
This gives `d_k == 0.1?` .Mon, 18 Feb 2019 10:27:21 -0600http://ask.sagemath.org/question/45464/unable-to-calculate-numeric-output-of-calculation-with-rifs-bug/?comment=45500#post-id-45500Comment by dan_fulea for <p>reworked question, same worksheet in cocalc.</p>
<p>this is my code:</p>
<pre><code>g=solve(e_Ersatz/(2*d_k)==e_s/d_e, d_k)
print g
show(g[0].subs({
d_e: RIF(.999,1.001),
d_m: RIF(.25,.1),
e_m: e_0 * RIF(80.5,81.5),
e_s: e_0 * RIF(3,4)
}))
f=g[0].subs({
d_e: RIF(.999,1.001),
d_m: RIF(.25,.1),
e_m: e_0 * RIF(80.5,81.5),
e_s: e_0 * RIF(3,4)
})
#show( n(f) )
</code></pre>
<p>this is g:</p>
<pre><code>[
d_k == (d_e*d_m*e_m - (d_e*d_m + 2*d_m^2)*e_s)/(d_e*e_m - 2*d_m*e_s)
]
</code></pre>
<p>So its not really complicated, a little summation, some factors, a square. Nothing I could not do manually, even with the error propagtion. </p>
<p>But when trying to get the RIF equvalent I get </p>
<pre><code>*** WARNING: Code contains possible implicit multiplication ***
*** Check if any of [ 5e, 5e ] need a "*" sign for multiplication, e.g. 5x should be 5*x ! ***
Error in lines 82-82
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
flags=compile_flags) in namespace, locals
File "", line 1, in <module>
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/misc/functional.py", line 1419, in numerical_approx
return n(prec, algorithm=algorithm)
File "sage/symbolic/expression.pyx", line 5981, in sage.symbolic.expression.Expression.numerical_approx (build/cythonized/sage/symbolic/expression.cpp:34636)
raise TypeError("cannot evaluate symbolic expression numerically")
TypeError: cannot evaluate symbolic expression numerically
</code></pre>
<p>Hu? Am I missing something fundamental? Is this a bug?</p>
<p>================
old question:</p>
<p>This is my worksheet:
<a href="https://cocalc.com/share/f7766c5e-2f4d-4916-bb0d-74a7182e5fd5/2019-02-09-203517.sagews?viewer=share">https://cocalc.com/share/f7766c5e-2f4...</a></p>
<p>I have an equation that I insert some numeric values into. Because I need to estimate the range of uncertainty, I specify the values as RIF numbers:</p>
<pre><code>d[0].subs(
d_e == RIF(.999,1.001),
x ==.25,
d_m == RIF(.05,.15),
U == RIF(10^-9,1.02*10^-9),
e_m == e_0 * RIF(80.5,81.5),
e_s == e_0 * RIF(3,4)
)
</code></pre>
<p>However, in the output that range is not expressed. Is that becaues there are remaining symbolic parameters?</p>
http://ask.sagemath.org/question/45464/unable-to-calculate-numeric-output-of-calculation-with-rifs-bug/?comment=45499#post-id-45499pointing to a *well documented* cocalc sheet may be ok, in this case, people try to copy+paste the code into the own debugger to get closer to the error. They further try to get closer to the error by setting some values or cutting them, try to inspect the types of the variables, and so on. To get a fair share of the effort, it would be in my view easier for a potential helper to already get the question at the point, without needing to get rid of the irrelevant python objects landscape. In our case it is really hard to get to the point. What is for instance `e_Ersatz` in the new post? (I will still try to put an answer in here below.)Mon, 18 Feb 2019 09:23:10 -0600http://ask.sagemath.org/question/45464/unable-to-calculate-numeric-output-of-calculation-with-rifs-bug/?comment=45499#post-id-45499Comment by stockh0lm for <p>reworked question, same worksheet in cocalc.</p>
<p>this is my code:</p>
<pre><code>g=solve(e_Ersatz/(2*d_k)==e_s/d_e, d_k)
print g
show(g[0].subs({
d_e: RIF(.999,1.001),
d_m: RIF(.25,.1),
e_m: e_0 * RIF(80.5,81.5),
e_s: e_0 * RIF(3,4)
}))
f=g[0].subs({
d_e: RIF(.999,1.001),
d_m: RIF(.25,.1),
e_m: e_0 * RIF(80.5,81.5),
e_s: e_0 * RIF(3,4)
})
#show( n(f) )
</code></pre>
<p>this is g:</p>
<pre><code>[
d_k == (d_e*d_m*e_m - (d_e*d_m + 2*d_m^2)*e_s)/(d_e*e_m - 2*d_m*e_s)
]
</code></pre>
<p>So its not really complicated, a little summation, some factors, a square. Nothing I could not do manually, even with the error propagtion. </p>
<p>But when trying to get the RIF equvalent I get </p>
<pre><code>*** WARNING: Code contains possible implicit multiplication ***
*** Check if any of [ 5e, 5e ] need a "*" sign for multiplication, e.g. 5x should be 5*x ! ***
Error in lines 82-82
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
flags=compile_flags) in namespace, locals
File "", line 1, in <module>
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/misc/functional.py", line 1419, in numerical_approx
return n(prec, algorithm=algorithm)
File "sage/symbolic/expression.pyx", line 5981, in sage.symbolic.expression.Expression.numerical_approx (build/cythonized/sage/symbolic/expression.cpp:34636)
raise TypeError("cannot evaluate symbolic expression numerically")
TypeError: cannot evaluate symbolic expression numerically
</code></pre>
<p>Hu? Am I missing something fundamental? Is this a bug?</p>
<p>================
old question:</p>
<p>This is my worksheet:
<a href="https://cocalc.com/share/f7766c5e-2f4d-4916-bb0d-74a7182e5fd5/2019-02-09-203517.sagews?viewer=share">https://cocalc.com/share/f7766c5e-2f4...</a></p>
<p>I have an equation that I insert some numeric values into. Because I need to estimate the range of uncertainty, I specify the values as RIF numbers:</p>
<pre><code>d[0].subs(
d_e == RIF(.999,1.001),
x ==.25,
d_m == RIF(.05,.15),
U == RIF(10^-9,1.02*10^-9),
e_m == e_0 * RIF(80.5,81.5),
e_s == e_0 * RIF(3,4)
)
</code></pre>
<p>However, in the output that range is not expressed. Is that becaues there are remaining symbolic parameters?</p>
http://ask.sagemath.org/question/45464/unable-to-calculate-numeric-output-of-calculation-with-rifs-bug/?comment=45472#post-id-45472ah, i was under the impression that it was customary to point to the cocalc worksheets. I dont feel confident explaining what d[0] is as a python object or otherwise - i know nothing about the inner workings of sage. Also i thought subs would be the common way to insert values into code in a temporary way. I will fiddle a little and rephrase the question.Fri, 15 Feb 2019 11:13:11 -0600http://ask.sagemath.org/question/45464/unable-to-calculate-numeric-output-of-calculation-with-rifs-bug/?comment=45472#post-id-45472Comment by dan_fulea for <p>reworked question, same worksheet in cocalc.</p>
<p>this is my code:</p>
<pre><code>g=solve(e_Ersatz/(2*d_k)==e_s/d_e, d_k)
print g
show(g[0].subs({
d_e: RIF(.999,1.001),
d_m: RIF(.25,.1),
e_m: e_0 * RIF(80.5,81.5),
e_s: e_0 * RIF(3,4)
}))
f=g[0].subs({
d_e: RIF(.999,1.001),
d_m: RIF(.25,.1),
e_m: e_0 * RIF(80.5,81.5),
e_s: e_0 * RIF(3,4)
})
#show( n(f) )
</code></pre>
<p>this is g:</p>
<pre><code>[
d_k == (d_e*d_m*e_m - (d_e*d_m + 2*d_m^2)*e_s)/(d_e*e_m - 2*d_m*e_s)
]
</code></pre>
<p>So its not really complicated, a little summation, some factors, a square. Nothing I could not do manually, even with the error propagtion. </p>
<p>But when trying to get the RIF equvalent I get </p>
<pre><code>*** WARNING: Code contains possible implicit multiplication ***
*** Check if any of [ 5e, 5e ] need a "*" sign for multiplication, e.g. 5x should be 5*x ! ***
Error in lines 82-82
Traceback (most recent call last):
File "/cocalc/lib/python2.7/site-packages/smc_sagews/sage_server.py", line 1188, in execute
flags=compile_flags) in namespace, locals
File "", line 1, in <module>
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/misc/functional.py", line 1419, in numerical_approx
return n(prec, algorithm=algorithm)
File "sage/symbolic/expression.pyx", line 5981, in sage.symbolic.expression.Expression.numerical_approx (build/cythonized/sage/symbolic/expression.cpp:34636)
raise TypeError("cannot evaluate symbolic expression numerically")
TypeError: cannot evaluate symbolic expression numerically
</code></pre>
<p>Hu? Am I missing something fundamental? Is this a bug?</p>
<p>================
old question:</p>
<p>This is my worksheet:
<a href="https://cocalc.com/share/f7766c5e-2f4d-4916-bb0d-74a7182e5fd5/2019-02-09-203517.sagews?viewer=share">https://cocalc.com/share/f7766c5e-2f4...</a></p>
<p>I have an equation that I insert some numeric values into. Because I need to estimate the range of uncertainty, I specify the values as RIF numbers:</p>
<pre><code>d[0].subs(
d_e == RIF(.999,1.001),
x ==.25,
d_m == RIF(.05,.15),
U == RIF(10^-9,1.02*10^-9),
e_m == e_0 * RIF(80.5,81.5),
e_s == e_0 * RIF(3,4)
)
</code></pre>
<p>However, in the output that range is not expressed. Is that becaues there are remaining symbolic parameters?</p>
http://ask.sagemath.org/question/45464/unable-to-calculate-numeric-output-of-calculation-with-rifs-bug/?comment=45470#post-id-45470It is very hard to start an answer. Please try to isolate the "same error" in a simpler case. Or simply develop code in a debugger. For instance, explain in words what is `d[0]` (conceptually and as a python object) and why should `subs` work in the given case.Fri, 15 Feb 2019 10:42:42 -0600http://ask.sagemath.org/question/45464/unable-to-calculate-numeric-output-of-calculation-with-rifs-bug/?comment=45470#post-id-45470