simplify() blows up on ratio of binomial coefficients

42 views
Skip to first unread message

Dan Drake

unread,
Jul 8, 2009, 10:43:34 PM7/8/09
to sage-...@googlegroups.com
I'm using 4.0.2 and get the following when I try to simplify a fraction
with symbolic binomial coefficients:

sage: t, n = var('t n')
sage: expr = binomial((t+1)*(n+1), n+1)/binomial((t+1)*n, n)
sage: expr.simplify()
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (927, 0))

[traceback snipped]

/opt/sage-4.0.2-x86_64-Linux/local/lib/python2.5/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.operator (sage/symbolic/expression.cpp:15127)()

RuntimeError: cannot find SFunction in table

I get the same error with 4.1.rc1. This seems similar to #6421, but
perhaps the bigger issue is that it blows up at all. I'm not sure what
the exact issue is here.

Dan

--
--- Dan Drake <dr...@kaist.edu>
----- KAIST Department of Mathematical Sciences
------- http://mathsci.kaist.ac.kr/~drake

signature.asc

William Stein

unread,
Jul 8, 2009, 10:52:45 PM7/8/09
to sage-...@googlegroups.com
On Wed, Jul 8, 2009 at 7:43 PM, Dan Drake<dr...@kaist.edu> wrote:
> I'm using 4.0.2 and get the following when I try to simplify a fraction
> with symbolic binomial coefficients:
>
>  sage: t, n = var('t n')
>  sage: expr = binomial((t+1)*(n+1), n+1)/binomial((t+1)*n, n)
>  sage: expr.simplify()
>  ERROR: An unexpected error occurred while tokenizing input
>  The following traceback may be corrupted or invalid
>  The error message is: ('EOF in multi-line statement', (927, 0))
>
>  [traceback snipped]
>
>  /opt/sage-4.0.2-x86_64-Linux/local/lib/python2.5/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.operator (sage/symbolic/expression.cpp:15127)()
>
>  RuntimeError: cannot find SFunction in table
>
> I get the same error with 4.1.rc1. This seems similar to #6421, but
> perhaps the bigger issue is that it blows up at all. I'm not sure what
> the exact issue is here.
>
> Dan
>

Some comments:

(1) in the new pynac based symbolics, everything is always
"automatically simplified" as much as it's going to be simplified by
pynac.

(2) The simplify command converts your expression to maxima and back.
Here's the source code:
return self._parent(self._maxima_())
In the long run this is a crazy thing to do, since more and more of
the symbolic expression Sage/pynac can represent will not have an
analogue in maxima.

(3) The command should probably be called "simplify_maxima()". And it
should probably have a try/except -- if things blow up it just returns
the original expression with no further simplification.

For the record, Maxima would not have done anything to simplify your
expression further.

sage: maxima(str(expr))
binomial((n+1)*(t+1),n+1)/binomial(n*(t+1),n)


Anyway, this is *definitely* a bug, and I hope the above 3 points will
start a little discussion, so we can decide what to do. My instinct
is to eliminate the simplify command completely, since I think it's
very misleading. Short of that, have it do nothing for now, but add a
new command "simplify_maxima()" that uses Maxima to try to simplify an
expression. Alternatively, have simplify(algorithm="maxima"), which
would do the same thing. We could also have
simplify(algorithm="sympy"), and even someday
simplify(algorithm="mathematica").

William

Tim Lahey

unread,
Jul 8, 2009, 11:00:02 PM7/8/09
to sage-...@googlegroups.com

On Jul 8, 2009, at 10:52 PM, William Stein wrote:

> Short of that, have it do nothing for now, but add a
> new command "simplify_maxima()" that uses Maxima to try to simplify an
> expression. Alternatively, have simplify(algorithm="maxima"), which
> would do the same thing. We could also have
> simplify(algorithm="sympy"), and even someday
> simplify(algorithm="mathematica").

I like the idea of identifying the algorithm. It fits with the approach
for integration.


---
Tim Lahey
PhD Candidate, Systems Design Engineering
University of Waterloo
http://www.linkedin.com/in/timlahey

Reply all
Reply to author
Forward
0 new messages