Ask Your Question
4

Factorial simplification error

asked 2011-06-23 16:17:42 +0200

garret gravatar image

updated 2011-06-23 16:49:53 +0200

I've run into an issue when running simplify on an equation containing a factorial:

sage: var('n')
sage: z1 =  (-1)^(1/2*(n - 1))*factorial(n) == 0
sage: z2 = 0 == (-1)^(1/2*(n - 1))*factorial(n)
sage: z1.simplify()
n*(-1)^(1/2*n - 1/2) != 0
sage: z2.simplify()
0 == (-1)^(1/2*n - 1/2)*factorial(n)

My best guess is when sage sends the equation down to maxima for simplification it's interpreting

(-1)^(1/2*(n - 1))*n!  =  0

as

(-1)^(1/2*(n - 1))*n   !=   0

Any ideas on how I can work around this?

edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
2

answered 2011-06-23 19:49:53 +0200

Mike Hansen gravatar image

I made this ticket 11539. As a temporary workaround, you can run the following commands which should fix things.

sage.calculus.calculus.maxima.eval(r":lisp (defun msize-factorial (x l r) (setq l (msize (cadr x) (revappend '(#\f #\a #\c #\t #\o #\r #\i #\a #\l #\() l) nil 'mparen 'mparen) r (list 1 #\) ) ) (list (+ (car l) (car r)) l r)) ")
sage.calculus.calculus.maxima.eval(r":lisp (defprop mfactorial msize-factorial grind)")

This changes things in Maxima so that factorial(x) is printed as factorial(x) instead of x!.

edit flag offensive delete link more

Comments

Wow, that's quite a workaround!

kcrisman gravatar imagekcrisman ( 2011-06-23 21:17:47 +0200 )edit
0

answered 2011-06-23 17:49:48 +0200

parzan gravatar image

Here is one option (not the most elegant):

sage: z1.lhs().simplify() == z1.rhs().simplify()
(-1)^(1/2*n - 1/2)*factorial(n) == 0
edit flag offensive delete link more

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-06-23 16:17:42 +0200

Seen: 535 times

Last updated: Jun 23 '11