[RFC] changing output of binomial

21 views
Skip to first unread message

Chris Smith

unread,
Mar 31, 2020, 11:37:24 AM3/31/20
to sympy
Currently, binomial presents results in terms of gamma. And if they evaluate you see a number or with Number real and/or imaginary parts. In #18960 we are experimenting with changing this so the class remains unevaluated unless it evaluates into an expression free of the writing function, `gamma`. So `binomial(nt, Rational(15, 6))` would remain unevaluated instead of becoming `8*gamma(nt + 1)/(15*sqrt(pi)*gamma(nt - Rational(3, 2)))`. This expression can be obtained by using `.rewrite(gamma)` and will evaluate to a numerical value with `evalf`.

/c

Aaron Meurer

unread,
Mar 31, 2020, 3:52:07 PM3/31/20
to sympy
I agree that such rewrites shouldn't happen by default. In this case,
the gamma expression isn't even simpler than the binomial. I would
expect combsimp(), for instance, to go from the gamma form to the
binomial (or beta()), not the other way around.

By the way, there's a related issue
https://github.com/sympy/sympy/issues/14577. We still need to properly
document why the binomial is defined the way it is for negative
arguments.

Aaron Meurer

On Tue, Mar 31, 2020 at 9:37 AM Chris Smith <smi...@gmail.com> wrote:
>
> Currently, binomial presents results in terms of gamma. And if they evaluate you see a number or with Number real and/or imaginary parts. In #18960 we are experimenting with changing this so the class remains unevaluated unless it evaluates into an expression free of the writing function, `gamma`. So `binomial(nt, Rational(15, 6))` would remain unevaluated instead of becoming `8*gamma(nt + 1)/(15*sqrt(pi)*gamma(nt - Rational(3, 2)))`. This expression can be obtained by using `.rewrite(gamma)` and will evaluate to a numerical value with `evalf`.
>
> /c
>
> --
> You received this message because you are subscribed to the Google Groups "sympy" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sympy+un...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sympy/eec37b02-19ae-4803-9cb7-5ba704c47859%40googlegroups.com.
Reply all
Reply to author
Forward
0 new messages