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.Mon, 18 Feb 2019 11:57:56 +0100long traceback when calling solve()https://ask.sagemath.org/question/45473/long-traceback-when-calling-solve/After https://ask.sagemath.org/question/45463/solvex-does-not-fully-isolate-x-how-can-i-help-along/ I substituted variables with numbers (in RIF format) so that sage might have an easier time solving for d_k. I got this:
0 == -v_ges + 1/(sqrt(4*d_k^2 + 0.57?)*d_k*((3.?e-11)/(d_k - 0.1?) + 1.?e-8)) - 1/(sqrt(4*d_k^2 + 0.0625000000000000)*d_k*((3.?e-11)/(d_k - 0.1?) + 1.?e-8)) + 3.7?e9
But now, when I try to solve the above for d_k, I get this long traceback, which is above my sage skills. How can I solve this? The worksheet is https://cocalc.com/share/f7766c5e-2f4d-4916-bb0d-74a7182e5fd5/2019-02-09-203517.sagews?viewer=share
*** 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 42-42
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 "sage/symbolic/expression.pyx", line 11568, in sage.symbolic.expression.Expression.solve (build/cythonized/sage/symbolic/expression.cpp:59905)
return solve(self, x, multiplicities=multiplicities,
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/relation.py", line 1044, in solve
return _solve_expression(f, x, explicit_solutions, multiplicities, to_poly_solve, solution_dict, algorithm, domain)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/relation.py", line 1282, in _solve_expression
m = ex._maxima_()
File "sage/symbolic/expression.pyx", line 817, in sage.symbolic.expression.Expression._maxima_ (build/cythonized/sage/symbolic/expression.cpp:7898)
return super(Expression, self)._interface_(maxima)
File "sage/structure/sage_object.pyx", line 663, in sage.structure.sage_object.SageObject._interface_ (build/cythonized/sage/structure/sage_object.c:5290)
s = init_func()
File "sage/structure/sage_object.pyx", line 769, in sage.structure.sage_object.SageObject._maxima_lib_init_ (build/cythonized/sage/structure/sage_object.c:7971)
return self._maxima_init_()
File "sage/structure/sage_object.pyx", line 762, in sage.structure.sage_object.SageObject._maxima_init_ (build/cythonized/sage/structure/sage_object.c:7742)
return self._interface_init_(I)
File "sage/symbolic/expression.pyx", line 854, in sage.symbolic.expression.Expression._interface_init_ (build/cythonized/sage/symbolic/expression.cpp:8069)
return InterfaceInit(I)(self)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 219, in __call__
return self.relation(ex, operator)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 471, in relation
self(ex.rhs()))
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
return self.arithmetic(ex, operator)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 624, in arithmetic
args = ["(%s)"%self(op) for op in ex.operands()]
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
return self.arithmetic(ex, operator)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 624, in arithmetic
args = ["(%s)"%self(op) for op in ex.operands()]
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
return self.arithmetic(ex, operator)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 624, in arithmetic
args = ["(%s)"%self(op) for op in ex.operands()]
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
return self.arithmetic(ex, operator)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 624, in arithmetic
args = ["(%s)"%self(op) for op in ex.operands()]
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 207, in __call__
raise err
TypeError
Fri, 15 Feb 2019 23:30:38 +0100https://ask.sagemath.org/question/45473/long-traceback-when-calling-solve/Answer by rburing for <p>After <a href="https://ask.sagemath.org/question/45463/solvex-does-not-fully-isolate-x-how-can-i-help-along/">https://ask.sagemath.org/question/454...</a> I substituted variables with numbers (in RIF format) so that sage might have an easier time solving for d_k. I got this:</p>
<pre><code>0 == -v_ges + 1/(sqrt(4*d_k^2 + 0.57?)*d_k*((3.?e-11)/(d_k - 0.1?) + 1.?e-8)) - 1/(sqrt(4*d_k^2 + 0.0625000000000000)*d_k*((3.?e-11)/(d_k - 0.1?) + 1.?e-8)) + 3.7?e9
</code></pre>
<p>But now, when I try to solve the above for d_k, I get this long traceback, which is above my sage skills. How can I solve this? The worksheet is <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>
<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 42-42
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 "sage/symbolic/expression.pyx", line 11568, in sage.symbolic.expression.Expression.solve (build/cythonized/sage/symbolic/expression.cpp:59905)
return solve(self, x, multiplicities=multiplicities,
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/relation.py", line 1044, in solve
return _solve_expression(f, x, explicit_solutions, multiplicities, to_poly_solve, solution_dict, algorithm, domain)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/relation.py", line 1282, in _solve_expression
m = ex._maxima_()
File "sage/symbolic/expression.pyx", line 817, in sage.symbolic.expression.Expression._maxima_ (build/cythonized/sage/symbolic/expression.cpp:7898)
return super(Expression, self)._interface_(maxima)
File "sage/structure/sage_object.pyx", line 663, in sage.structure.sage_object.SageObject._interface_ (build/cythonized/sage/structure/sage_object.c:5290)
s = init_func()
File "sage/structure/sage_object.pyx", line 769, in sage.structure.sage_object.SageObject._maxima_lib_init_ (build/cythonized/sage/structure/sage_object.c:7971)
return self._maxima_init_()
File "sage/structure/sage_object.pyx", line 762, in sage.structure.sage_object.SageObject._maxima_init_ (build/cythonized/sage/structure/sage_object.c:7742)
return self._interface_init_(I)
File "sage/symbolic/expression.pyx", line 854, in sage.symbolic.expression.Expression._interface_init_ (build/cythonized/sage/symbolic/expression.cpp:8069)
return InterfaceInit(I)(self)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 219, in __call__
return self.relation(ex, operator)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 471, in relation
self(ex.rhs()))
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
return self.arithmetic(ex, operator)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 624, in arithmetic
args = ["(%s)"%self(op) for op in ex.operands()]
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
return self.arithmetic(ex, operator)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 624, in arithmetic
args = ["(%s)"%self(op) for op in ex.operands()]
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
return self.arithmetic(ex, operator)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 624, in arithmetic
args = ["(%s)"%self(op) for op in ex.operands()]
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 217, in __call__
return self.arithmetic(ex, operator)
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 624, in arithmetic
args = ["(%s)"%self(op) for op in ex.operands()]
File "/ext/sage/sage-8.6_1804/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.py", line 207, in __call__
raise err
TypeError
</code></pre>
https://ask.sagemath.org/question/45473/long-traceback-when-calling-solve/?answer=45489#post-id-45489Apparently substituting variables with RIF numbers does not give Sage an easier time solving equations.
The trouble is that Sage uses Maxima for solving equations (by default).
The traceback shows that Sage has a problem converting RIF numbers into Maxima objects.
Here is a more self-contained example:
sage: var('x')
sage: solve(x + RIF(0.999,1.001) == 0, x)
I reported this as [trac ticket #27314](https://trac.sagemath.org/ticket/27314).Mon, 18 Feb 2019 11:57:08 +0100https://ask.sagemath.org/question/45473/long-traceback-when-calling-solve/?answer=45489#post-id-45489Comment by Iguananaut for <p>Apparently substituting variables with RIF numbers does not give Sage an easier time solving equations.</p>
<p>The trouble is that Sage uses Maxima for solving equations (by default).</p>
<p>The traceback shows that Sage has a problem converting RIF numbers into Maxima objects.</p>
<p>Here is a more self-contained example:</p>
<pre><code>sage: var('x')
sage: solve(x + RIF(0.999,1.001) == 0, x)
</code></pre>
<p>I reported this as <a href="https://trac.sagemath.org/ticket/27314">trac ticket #27314</a>.</p>
https://ask.sagemath.org/question/45473/long-traceback-when-calling-solve/?comment=45490#post-id-45490Thank you for reporting the issue!Mon, 18 Feb 2019 11:57:56 +0100https://ask.sagemath.org/question/45473/long-traceback-when-calling-solve/?comment=45490#post-id-45490