Ask Your Question
0

Failure on symbolic solve

asked 2011-01-17 17:34:10 +0100

mouse gravatar image

updated 2011-01-17 21:01:54 +0100

kcrisman gravatar image

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

1 Answer

Sort by ยป oldest newest most voted
2

answered 2011-01-17 21:21:31 +0100

kcrisman gravatar image

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

edit flag offensive delete link more

Comments

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

mouse gravatar imagemouse ( 2011-01-17 23:19:32 +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

Stats

Asked: 2011-01-17 17:34:10 +0100

Seen: 1,226 times

Last updated: Jan 17 '11