Ask Your Question
2

long traceback when calling solve()

asked 2019-02-15 23:30:38 +0100

stockh0lm gravatar image

updated 2023-01-09 23:59:50 +0100

tmonteil gravatar image

After https://ask.sagemath.org/question/454... 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-2f4...

*** 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
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
1

answered 2019-02-18 11:57:08 +0100

rburing gravatar image

Apparently 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.

edit flag offensive delete link more

Comments

Thank you for reporting the issue!

Iguananaut gravatar imageIguananaut ( 2019-02-18 11:57:56 +0100 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2019-02-15 23:30:38 +0100

Seen: 679 times

Last updated: Feb 18 '19