## #920 minfactorial doesn't look inside "!"

closed
nobody
3
2009-01-04
2006-05-11
No

The minfactorial function doesn't look inside the
factorial function. So it misses some simplifications
that it could do:

(%i1) (n!/(n-1)!)!;
(%o1) (n!/(n-1)!)!
(%i2) minfactorial(%);
(%o2) (n!/(n-1)!)! <-- could be n!

(%i3) build_info();
Maxima version: 5.9.3
Maxima build date: 0:52 3/20/2006
host type: i686-pc-mingw32
lisp-implementation-type: GNU Common Lisp (GCL)
lisp-implementation-version: GCL 2.6.7

Barton

## Discussion

• Robert Dodier - 2006-08-24
• labels: 460522 --> Lisp Core - Simplification

• Dieter Kaiser - 2008-09-27

When we implement the simplification of expressions like factorial(n+m) and factorial (n-m) with integer m, the factorials simplifies immediatly. The simplification depends on the Maxima User flag \$factoriol_expand.

This could be the implementation of the expansion:

((and \$factorial_expand
(mplusp y)
(integerp (cadr y)))
;; factorial(z+m) and m integer. Expand.
(let ((m (cadr y))
(n (simplify (cons '(mplus) (cddr y)))))
(cond ((>= m 0)
(mul
(simplify (list '(\$pochhammer) (add n 1) m))
(simplify (list '(mfactorial) n))))
((< m 0)
(setq m (- m))
(div
(mul (power -1 m) (simplify (list '(mfactorial) n)))
(simplify (list '(\$pochhammer) (mul -1 n) m)))))))

This is the result without simplification and minfactorial:
(%i15) (n!/(n-1)!)!;
(%o15) (n!/(n-1)!)!
(%i16) minfactorial(%);
(%o16) (n!/(n-1)!)!

Now we set the flag to expand the Factorials:
(%i18) factorial_expand:true\$

(%i20) factorial(n+2);
(%o20) (n+1)*(n+2)*n!

(%i21) factorial(n-2);
(%o21) -n!/((1-n)*n)

The epression of this bug report simplifies:
(%i22) (n!/(n-1)!)!;
(%o22) n!

Because the simplification is done by the simplifier we have no problems with nested expressions. This mechanism of simplification has already be implemented for Double factorial, the Gamma function and the Incomplete Gamma function.

Dieter Kaiser

• Dieter Kaiser - 2009-01-04

The code of the factorial function has changed. The proposed simplification for factorials is implemented. minfactorial is not improved, but the alternative code sucessfully does the desired simplifications.

Closing the bug report as fixed.

Dieter Kaiser

• Dieter Kaiser - 2009-01-04
• status: open --> closed

## Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

No, thanks