Problem with Maxima interface?

78 views
Skip to first unread message

Nathan Dunfield

unread,
Apr 14, 2010, 3:17:26 PM4/14/10
to sage-devel
I'm having the following problem with basic symbolics in Sage 4.3.2.
I create some variables with "var", combine them into rational
functions, then take their numerator and denominator and coerce them
into a PolynomialRing. This works fine most of the time, but very
occasionally (every few 10000 usages) it chokes with following error
message:

TypeError: unable to make sense of Maxima expression
'"__SAGE_SYNCHRO_MARKER_202188656"' in Sage

If I use "pdb" to go up to frame at the top of the traceback, and
rerun the offending line, it works, as you can see below.

Sometimes it dies with other message complaining about the syntax of
seeming correct expressions, e.g.

TypeError: Error executing code in Maxima
CODE:
_tmp_ : -(a0-1)*a1^2*a3$
Maxima ERROR:

_tmp_ : -(a0-1)*a1^2*a3$
stdin:57338284:Incorrect syntax: Illegal use of delimiter )
(%i832002)
stdin:57338357:Incorrect syntax: Premature termination of input at ;.
(%i832003)

Any ideas of what's going on here?

Thanks,

Nathan

----------------------------------------------------------------------
| Sage Version 4.3.2, Release Date: 2010-02-06 |
| Type notebook() for the GUI, and license() for information. |
----------------------------------------------------------------------
sage: attach stavros/__init__.py
sage: %pdb
Automatic pdb calling has been turned ON
sage: test()
---------------------------------------------------------------------------
TypeError Traceback (most recent call
last)

/Users/dunfield/work/stavros3/<ipython console> in <module>()

/Users/dunfield/work/stavros3/stavros/__init__.py in test()
226 N = OneCuspedManifold(M)
227 for S in N.NormalSurfaces:
--> 228 info = N.vertex_surface_info(S)
229 if info [:-3] == (True, False, False):
230 print M, N.NormalSurfaces.index(S), info

/Users/dunfield/work/stavros3/stavros/__init__.py in
vertex_surface_info(self, surface)
132 n = len(surface.Coefficients)
133 is_kabaya = min(surface.Coefficients) > 0
--> 134 is_ideal = self.comes_from_an_ideal_point(surface)
135 is_isolated = self.vertex_surface_is_isolated(surface)
136 return surface.BoundarySlope, is_isolated, is_kabaya,
is_ideal

/Users/dunfield/work/stavros3/stavros/__init__.py in
comes_from_an_ideal_point(self, surface)
121 R = PolynomialRing(QQ, ['a%d' % i for i in range(0,n)]
+ ['b%d' % i for i in range(0,n)])
122 eqns = self.first_order_equations(surface)
--> 123 poly_eqns = [ R(e.numerator() - e.denominator()) for e
in eqns]
124 gens = R.gens_dict()
125 blow_up_eqns = [ gens["a%d" % i] * gens["b%d" % i] - 1
for i in range(0, n)]

/pkgs/sage-4.3.2/local/lib/python2.6/site-packages/sage/symbolic/
expression.so in sage.symbolic.expression.Expression.denominator (sage/
symbolic/expression.cpp:20432)()

/pkgs/sage-4.3.2/local/lib/python2.6/site-packages/sage/structure/
parent.so in sage.structure.parent.Parent.__call__ (sage/structure/
parent.c:6206)()

/pkgs/sage-4.3.2/local/lib/python2.6/site-packages/sage/structure/
coerce_maps.so in sage.structure.coerce_maps.NamedConvertMap._call_
(sage/structure/coerce_maps.c:4098)()

/pkgs/sage-4.3.2/local/lib/python2.6/site-packages/sage/interfaces/
maxima.pyc in _symbolic_(self, R)
1792 sqrt(2)
1793 """
-> 1794 return R(self._sage_())
1795
1796 def __complex__(self):

/pkgs/sage-4.3.2/local/lib/python2.6/site-packages/sage/interfaces/
maxima.pyc in _sage_(self)
1773 from sage.calculus.calculus import
symbolic_expression_from_maxima_string
1774 #return
symbolic_expression_from_maxima_string(self.name(),
maxima=self.parent())

-> 1775 return
symbolic_expression_from_maxima_string(repr(self))
1776
1777 def _symbolic_(self, R):

/pkgs/sage-4.3.2/local/lib/python2.6/site-packages/sage/calculus/
calculus.pyc in symbolic_expression_from_maxima_string(x, equals_sub,
maxima)
1964 return symbolic_expression_from_string(s, syms,
accept_sequence=True)
1965 except SyntaxError:
-> 1966 raise TypeError, "unable to make sense of Maxima
expression '%s' in Sage"%s
1967 finally:
1968 is_simplified = False

TypeError: unable to make sense of Maxima expression
'"__SAGE_SYNCHRO_MARKER_202188656"' in Sage
> /pkgs/sage-4.3.2/local/lib/python2.6/site-packages/sage/calculus/calculus.py(1968)symbolic_expression_from_maxima_string()
1967 finally:
-> 1968 is_simplified = False
1969

ipdb> up
> /pkgs/sage-4.3.2/local/lib/python2.6/site-packages/sage/interfaces/maxima.py(1775)_sage_()
1774 #return
symbolic_expression_from_maxima_string(self.name(),
maxima=self.parent())

-> 1775 return
symbolic_expression_from_maxima_string(repr(self))
1776

ipdb> up
> /pkgs/sage-4.3.2/local/lib/python2.6/site-packages/sage/interfaces/maxima.py(1794)_symbolic_()
1793 """
-> 1794 return R(self._sage_())
1795

ipdb> up
> /Users/dunfield/work/stavros3/stavros/__init__.py(123)comes_from_an_ideal_point()
122 eqns = self.first_order_equations(surface)
--> 123 poly_eqns = [ R(e.numerator() - e.denominator()) for e
in eqns]
124 gens = R.gens_dict()

ipdb> eqns
[-(a2 - 1)*(a1 - 1)*(a0 - 1)^2*a3/(a0^2*a1*a2*a5), a0*a4/(a1 - 1)^2, -
(a2 - 1)*a1^2*a3*a4/((a4 - 1)^2*(a0 - 1)^2*a5), a0*a5^2/((a2 -
1)^2*a3^2), (a4 - 1)^2*(a1 - 1)/(a1*a4^2), a2]
ipdb> [ R(e.numerator() - e.denominator()) for e in eqns]
[-a0^2*a1*a2*a3 - a0^2*a1*a2*a5 + a0^2*a1*a3 + a0^2*a2*a3 +
2*a0*a1*a2*a3 - a0^2*a3 - 2*a0*a1*a3 - 2*a0*a2*a3 - a1*a2*a3 + 2*a0*a3
+ a1*a3 + a2*a3 - a3, -a1^2 + a0*a4 + 2*a1 - 1, -a1^2*a2*a3*a4 -
a0^2*a4^2*a5 + a1^2*a3*a4 + 2*a0^2*a4*a5 + 2*a0*a4^2*a5 - a0^2*a5 -
4*a0*a4*a5 - a4^2*a5 + 2*a0*a5 + 2*a4*a5 - a5, -a2^2*a3^2 + 2*a2*a3^2
+ a0*a5^2 - a3^2, -2*a1*a4 - a4^2 + a1 + 2*a4 - 1, a2 - 1]
ipdb>

William Stein

unread,
Apr 14, 2010, 3:57:12 PM4/14/10
to sage-...@googlegroups.com
On Wed, Apr 14, 2010 at 12:17 PM, Nathan Dunfield <nat...@dunfield.info> wrote:
> I'm having the following problem with basic symbolics in Sage 4.3.2.
> I create some variables with "var", combine them into rational
> functions, then take their numerator and denominator and coerce them
> into a PolynomialRing.   This works fine most of the time, but very
> occasionally (every few 10000 usages) it chokes with following error
> message:
>
> TypeError: unable to make sense of Maxima expression
> '"__SAGE_SYNCHRO_MARKER_202188656"' in Sage
>
> If I use "pdb" to go up to frame at the top of the traceback, and
> rerun the offending line, it works, as you can see below.
>
> Sometimes it dies with other message complaining about the syntax of
> seeming correct expressions, e.g.
>
> TypeError: Error executing code in Maxima
> CODE:
>        _tmp_ : -(a0-1)*a1^2*a3$
> Maxima ERROR:
>
> _tmp_ : -(a0-1)*a1^2*a3$
> stdin:57338284:Incorrect syntax: Illegal use of delimiter )
> (%i832002)
> stdin:57338357:Incorrect syntax: Premature termination of input at ;.
> (%i832003)
>
> Any ideas of what's going on here?


You should post exact code so that we can replicate your problem.

William

> --
> To post to this group, send an email to sage-...@googlegroups.com
> To unsubscribe from this group, send an email to sage-devel+...@googlegroups.com
> For more options, visit this group at http://groups.google.com/group/sage-devel
> URL: http://www.sagemath.org
>
> To unsubscribe, reply using "remove me" as the subject.
>

--
William Stein
Professor of Mathematics
University of Washington
http://wstein.org

Nathan Dunfield

unread,
Apr 14, 2010, 5:19:08 PM4/14/10
to sage-devel
On Apr 14, 2:57 pm, William Stein <wst...@gmail.com> wrote:
> You should post exact code so that we can replicate your problem.

I've boiled down the problem into the example below. Just attach and
then run "prob()".

One thing to note is that's just doing the exact same thing again and
again, but eventually it up and crashes. On my system, which is
detailed below, it dies after about 10-20 minutes at the 4000ish
iteration.

System details: MacPro3,1 with 2 Quad-Core Xeon Processors @ 2.8 Ghz,
running 10.5.8.
Sage 4.3.2 self-compiled with i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1
(Apple Inc. build 5493)

Thanks,

Nathan

------begin code-----


datum = ([0, 1, 0, 2, 0, 2], [([-1, -2, -1, 1, -1, 0], [1, 2, 1, 0, 1,
0], -1), ([2, 0, 0, 0, 0, 0], [0, -1, 0, 0, 0, 0], 1), ([-1, 2, 0, -1,
0, 0], [-1, 0, -1, 1, 0, 0], 1), ([0, 0, 1, 1, 0, -1], [0, -1, 1, -2,
-2, 2], -1), ([0, 0, 0, -1, 2, 1], [0, 0, -1, 1, 0, 0], -1), ([0, 0,
0, 0, -1, 0], [0, 0, 0, 0, 1, -2], -1)])

class Surface():
def __init__(self, datum):
self.Coefficients, self.RawEquations = datum

def eval_eqn( (a,b,c), z):
ans = c
for i, z in enumerate(z):
ans *= z**a[i] * (1 - z) ** b[i]
return ans

class OneCuspedManifold():
def raw_natural_gluing_equations(self, surface):
return surface.RawEquations

def natural_gluing_equations(self, surface):
n = len(surface.Coefficients)
z = var(" ".join(["z%d" % i for i in range(n)]))
return [eval_eqn(eqn, z) for eqn in
self.raw_natural_gluing_equations(surface)]

def first_order_equations(self, surface):
V = [int(e) for e in list(surface.Coefficients)]
n = len(V)
a_vars = var(" ".join(["a%d" % i for i in range(n)]))
t = var('t')
base_eqns = self.raw_natural_gluing_equations(surface)
z = [ a * t ** e for a, e in zip(a_vars, V) ]
eqns = [eval_eqn(eqn, z).subs(t=0) for eqn in base_eqns]
return eqns

def comes_from_an_ideal_point(self, surface):
n = len(surface.Coefficients)


R = PolynomialRing(QQ, ['a%d' % i for i in range(0,n)] + ['b
%d' % i for i in range(0,n)])

eqns = self.first_order_equations(surface)


poly_eqns = [ R(e.numerator() - e.denominator()) for e in
eqns]

def prob():
count = 0
while 1:
M = OneCuspedManifold()
S = Surface(datum)
M.comes_from_an_ideal_point(S)
count += 1

Nathan Dunfield

unread,
Apr 14, 2010, 7:26:12 PM4/14/10
to sage-devel
Here is a more concise, but essentially equivalent, code snippet which
exhibits the problem. Just attach and run "prob()" Again, it takes
10-12 minutes to crash on my MacPro3,1 with 2 Quad-Core Xeon
Processors @ 2.8 Ghz, running 10.5.8, with Sage 4.3.2 self-compiled

with i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build
5493).

Best,

Nathan

------- problem code begins -----

datum = ([0, 1, 0, 2, 0, 2], [([-1, -2, -1, 1, -1, 0], [1, 2, 1, 0, 1,

0], -1)])
coefficients, raw_natural_gluing_equations = datum

def eval_eqn( (a,b,c), z):
ans = c
for i, z in enumerate(z):
ans *= z**a[i] * (1 - z) ** b[i]
return ans

def first_order_equations():
n = len(coefficients)


a_vars = var(" ".join(["a%d" % i for i in range(n)]))
t = var('t')

base_eqns = raw_natural_gluing_equations
z = [ a * t ** e for a, e in zip(a_vars, coefficients) ]


eqns = [eval_eqn(eqn, z).subs(t=0) for eqn in base_eqns]

R = PolynomialRing(QQ, ['a%d' % i for i in range(n)])
poly_eqns = [ R(e.numerator()) for e in eqns]

def prob():
for i in xrange(1000000):
first_order_equations()

Nathan Dunfield

unread,
Apr 14, 2010, 8:18:27 PM4/14/10
to sage-devel, wst...@gmail.com
> Here is a more concise, but essentially equivalent, code snippet which
> exhibits the problem.   Just attach and run "prob()"  Again, it takes
> 10-12 minutes to crash on my MacPro3,1 with 2 Quad-Core Xeon
> Processors @ 2.8 Ghz, running 10.5.8, with Sage 4.3.2 self-compiled
> with i686-apple-darwin9-gcc-4.0.1 (GCC) 4.0.1 (Apple Inc. build
> 5493).

To follow up on myself one last time, here's what appears to be the
minimal example exhibiting this problem

def prob():
for i in xrange(1000000):

a = var('a')
eqn = (a - 1)/(a)
eqn.numerator()

Note: If you run it once and it crashes, and then you run it again (w/
o quiting Sage) it crashes much faster.

Best,

Nathan

Dan Drake

unread,
Apr 14, 2010, 10:00:03 PM4/14/10
to sage-...@googlegroups.com

I can confirm that the above function eventually desynchronizes Maxima;
I'm using Sage 4.3.5 with Ubuntu 9.10 on a quad-core Core 2 processor.

This reminds me of a previous Maxima problem that Gonzalo Tornaria
solved -- there, the synchronization with Maxima was getting lost on
certain multi-core CPUs because of something related to switching
between cores. See #5662.

Dan

--
--- Dan Drake
----- http://mathsci.kaist.ac.kr/~drake
-------

signature.asc

Nathan Dunfield

unread,
Apr 15, 2010, 8:53:58 AM4/15/10
to sage-devel
> I can confirm that the above function eventually desynchronizes Maxima;
> I'm using Sage 4.3.5 with Ubuntu 9.10 on a quad-core Core 2 processor.

One more date point: I reproduced the problem on my Mac Book, which
has a dual-core Core 2. Despite the fact that it's a lot slower than
my Mac Pro, it crashes in about half the time...

Nathan

Nathan Dunfield

unread,
Apr 26, 2010, 5:03:47 PM4/26/10
to sage-devel
> To follow up on myself one last time, here's what appears to be the
> minimal example exhibiting thisproblem
>
> def prob():
>     for i in xrange(1000000):
>         a = var('a')
>         eqn = (a - 1)/(a)
>         eqn.numerator()

I've gone ahead and filed this in Trac as

http://trac.sagemath.org/sage_trac/ticket/8772

Best,

Nathan
Reply all
Reply to author
Forward
0 new messages