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, 17 Jan 2011 23:19:32 +0100Failure on symbolic solvehttps://ask.sagemath.org/question/7882/failure-on-symbolic-solve/Trying to learn manipulation of symbolic expressions. However when I try this one I get a traceback. Is this a bug, limitation, or user error?
x,y,z = var('x y z')
assume(x>0)
assume(y>0)
assume(z>0)
eqn = (x == y**z)
solve(eqn, y)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_68.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("eCx5LHogPSB2YXIoJ3ggeSB6JykKYXNzdW1lKHg+MCkKYXNzdW1lKHk+MCkKYXNzdW1lKHo+MCkKZXFuID0gKHggPT0geSoqeikKc29sdmUoZXFuLCB5KQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpgB4hFo/___code___.py", line 8, in <module>
exec compile(u'solve(eqn, y)
File "", line 1, in <module>
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/symbolic/relation.py", line 619, in solve
ans = f.solve(*args,**kwds)
File "expression.pyx", line 7518, in sage.symbolic.expression.Expression.solve (sage/symbolic/expression.cpp:27206)
File "expression.pyx", line 7511, in sage.symbolic.expression.Expression.solve (sage/symbolic/expression.cpp:27084)
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1474, in __call__
return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1373, in function_call
return self.new(s)
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1154, in new
return self(code)
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1090, in __call__
return cls(self, x, name=name)
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1517, in __init__
raise TypeError, x
TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(>0)' before integral or limit evaluation, for example):
Is z an integer?Mon, 17 Jan 2011 17:34:10 +0100https://ask.sagemath.org/question/7882/failure-on-symbolic-solve/Answer by kcrisman for <p>Trying to learn manipulation of symbolic expressions. However when I try this one I get a traceback. Is this a bug, limitation, or user error?</p>
<pre><code>x,y,z = var('x y z')
assume(x>0)
assume(y>0)
assume(z>0)
eqn = (x == y**z)
solve(eqn, y)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "_sage_input_68.py", line 10, in <module>
exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("eCx5LHogPSB2YXIoJ3ggeSB6JykKYXNzdW1lKHg+MCkKYXNzdW1lKHk+MCkKYXNzdW1lKHo+MCkKZXFuID0gKHggPT0geSoqeikKc29sdmUoZXFuLCB5KQ=="),globals())+"\\n"); execfile(os.path.abspath("___code___.py"))
File "", line 1, in <module>
File "/tmp/tmpgB4hFo/___code___.py", line 8, in <module>
exec compile(u'solve(eqn, y)
File "", line 1, in <module>
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/symbolic/relation.py", line 619, in solve
ans = f.solve(*args,**kwds)
File "expression.pyx", line 7518, in sage.symbolic.expression.Expression.solve (sage/symbolic/expression.cpp:27206)
File "expression.pyx", line 7511, in sage.symbolic.expression.Expression.solve (sage/symbolic/expression.cpp:27084)
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1474, in __call__
return self._obj.parent().function_call(self._name, [self._obj] + list(args), kwds)
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1373, in function_call
return self.new(s)
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1154, in new
return self(code)
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1090, in __call__
return cls(self, x, name=name)
File "/home/sage/sage/local/lib/python2.6/site-packages/sage/interfaces/expect.py", line 1517, in __init__
raise TypeError, x
TypeError: Computation failed since Maxima requested additional constraints (try the command 'assume(>0)' before integral or limit evaluation, for example):
Is z an integer?
</code></pre>
https://ask.sagemath.org/question/7882/failure-on-symbolic-solve/?answer=11987#post-id-11987Here is a longish answer that will show you a few ways to get what you want... but won't exactly answer your question.
Apparently this is what Maxima is looking for (Sage uses Maxima for its assumptions and solving).
sage: x,y,z = var('x y z')
sage: assume(x>0)
sage: assume(y>0)
sage: assume(z>0)
sage: eqn = (x == y**z)
sage: eqn
x == y^z
sage: assume(z,'integer')
sage: solve(eqn,y)
[y == x^(1/z)]
I should point out that Maxima doesn't use its assumptions that much in its solving.
But Maxima then apparently doesn't care what the answer is, as long as `x>0`.
Maxima 5.22.1 http://maxima.sourceforge.net
using Lisp ECL 10.4.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) assume(y>0,z>0,x>0);
(%o1) [y > 0, z > 0, x > 0]
(%i2) eqn:x=y^z;
z
(%o2) x = y
(%i3) solve(eqn,y);
Is z an integer?
n;
1/z
(%o3) [y = x ]
So this could be a bug - or feature - in Maxima. Of course, such functions are in general multivalued, so depending on your context this might not really be a good answer anyway. You might instead like
(%i5) load(to_poly_solver);
Loading maxima-grobner $Revision: 1.6 $ $Date: 2009/06/02 07:49:49 $
define: warning: redefining the built-in function prog1
define: warning: redefining the built-in function symbolcheck
define: warning: redefining the built-in function push
define: warning: redefining the built-in function pop
define: warning: redefining the built-in function tr_ev
(%o5) /Users/.../sage-4.6.2.alpha0/local/share/maxima\
/5.22.1/share/contrib/to_poly_solver.mac
(%i6) to_poly_solve(eqn,y);
2 %i %pi %z5
------------
1/z z
(%o6) %union([y = x %e ])
where `%z5` is an arbitrary integer. Normally this would come from `solve(eqn,y,to_poly_solve=True)` but the exception takes precedence in our current implementation.Mon, 17 Jan 2011 21:21:31 +0100https://ask.sagemath.org/question/7882/failure-on-symbolic-solve/?answer=11987#post-id-11987Comment by mouse for <p>Here is a longish answer that will show you a few ways to get what you want... but won't exactly answer your question.</p>
<p>Apparently this is what Maxima is looking for (Sage uses Maxima for its assumptions and solving).</p>
<pre><code>sage: x,y,z = var('x y z')
sage: assume(x>0)
sage: assume(y>0)
sage: assume(z>0)
sage: eqn = (x == y**z)
sage: eqn
x == y^z
sage: assume(z,'integer')
sage: solve(eqn,y)
[y == x^(1/z)]
</code></pre>
<p>I should point out that Maxima doesn't use its assumptions that much in its solving. </p>
<p>But Maxima then apparently doesn't care what the answer is, as long as <code>x>0</code>.</p>
<pre><code>Maxima 5.22.1 http://maxima.sourceforge.net
using Lisp ECL 10.4.1
Distributed under the GNU Public License. See the file COPYING.
Dedicated to the memory of William Schelter.
The function bug_report() provides bug reporting information.
(%i1) assume(y>0,z>0,x>0);
(%o1) [y > 0, z > 0, x > 0]
(%i2) eqn:x=y^z;
z
(%o2) x = y
(%i3) solve(eqn,y);
Is z an integer?
n;
1/z
(%o3) [y = x ]
</code></pre>
<p>So this could be a bug - or feature - in Maxima. Of course, such functions are in general multivalued, so depending on your context this might not really be a good answer anyway. You might instead like</p>
<pre><code>(%i5) load(to_poly_solver);
Loading maxima-grobner $Revision: 1.6 $ $Date: 2009/06/02 07:49:49 $
define: warning: redefining the built-in function prog1
define: warning: redefining the built-in function symbolcheck
define: warning: redefining the built-in function push
define: warning: redefining the built-in function pop
define: warning: redefining the built-in function tr_ev
(%o5) /Users/.../sage-4.6.2.alpha0/local/share/maxima\
/5.22.1/share/contrib/to_poly_solver.mac
(%i6) to_poly_solve(eqn,y);
2 %i %pi %z5
------------
1/z z
(%o6) %union([y = x %e ])
</code></pre>
<p>where <code>%z5</code> is an arbitrary integer. Normally this would come from <code>solve(eqn,y,to_poly_solve=True)</code> but the exception takes precedence in our current implementation.</p>
https://ask.sagemath.org/question/7882/failure-on-symbolic-solve/?comment=22268#post-id-22268Hey Thanks. Other work is pounding on me today but I'll find some time to digest the answer. Appreciate the time you put into this. regards.Mon, 17 Jan 2011 23:19:32 +0100https://ask.sagemath.org/question/7882/failure-on-symbolic-solve/?comment=22268#post-id-22268