On Jan 15, 9:37 am, William Stein <wst...@gmail.com> wrote:
> On Thu, Jan 14, 2010 at 10:43 PM, andrejv <andrej.vodopi...@gmail.com> wrote:
>
> > On Jan 15, 6:14 am, Craig Citro <craigci...@gmail.com> wrote:
> >> Yeah, this is wacky. I can tell you why it's happening, though someone
> >> who's ever used Maxima before should really think about the right fix.
> >> Here's the issue: in sage.calculus.calculus, there's an instance of
> >> Maxima that gets created and passed the argument 'load(simplify_sum)'.
> >> This causes the expression 'd2' to get simplified to
> >> (3*n+k-1)!/(6*n+2*k)!. Here's a sample session illustrating the issue:
>
> >> sage: maxima("d2")
> >> d2
> >> sage: sage.calculus.calculus.maxima("d2")
> >> (3*n+k-1)!/(6*n+2*k)!
> >> sage: Maxima(init_code=['load(simplify_sum)', 'display2d:false'])("d2")
> >> (3*n+k-1)!/(6*n+2*k)!
>
> >> Maybe someone who knows Maxima better could point us in the right 
> >> direction?
>
> > d2 is defined in the testsuite for the Zeilberger algorithm. It is not
> > necessary to load the tests, in share/contrib/Zeilberger/
> > zeilberger.mac remove the last line which loads them.
>
> > Andrej
>
> Wow, that's pretty annoying.  So we have:
>
> sage: d2 = var('d2')
> sage: d2.simplify()
> factorial(k + 3*n - 1)/factorial(2*k + 6*n)
>
> and even worse things like:
>
> sage: factorial = var('factorial')
> sage: factorial^3 + factorial/7 - 1
> factorial^3 + 1/7*factorial - 1
> sage: (factorial^3 + factorial/7 - 1).simplify()
> BOOM!
>
> --
>
> This could all be avoided if before changing a variable to maxima we
> prepended it with _sage_var_ (say), and stripped those off when moving
> from maxima back to Sage.  This is worth considering...
>
> Basically, right now, any time that one makes a symbolic variables
> that just *happens* to be the same as the name of a function defined
> in maxima's large global namespace, any symbolic calls to maxima
> involving that variable break.   One could imagine e.g., writing code
> that works and uses an innocent sounding variable like x2 (say),
> upgrading maxima in a few months, and finding that the code suddenly
> doesn't work in arbitrarily confusing ways (since x2 could be defined
> in Maxima to be something entirely weird/crazy like "factorial(k + 3*n
> - 1)/factorial(2*k + 6*n)").

I think this is because factorial is a function in Sage. There is no
problem for ratsimp:

sage: ratsimp=var('ratsimp')
sage: (ratsimp^4+ratsimp^2+ratsimp+1).simplify()
ratsimp^4 + ratsimp^2 + ratsimp + 1

Prepending something to variable names probably does not fix the
problem for factorial.

Andrej
-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to