Nice!
This code can be extended to handle cases like
2*gamma(x)*gamma(1-x)
gamma(x)^2*gamma(1-x)
(1-gamma(x))*(1+gamma(1-x))
by using ratsubst instead of subst (though of course that may also expand
subexpressions unnecessarily):
reduce_product_gamma(e) := block([l],
l : map('first, gatherargs(e,'gamma)),
l : sublist(l, lambda([s], not integerp(s))), /* can't happen unless
simp : false ? */
l : sort(l, lambda([a,b], orderlessp(b,a))), /* try to guess which sub
gives simplest result */
eratsubst(map(lambda([s], gamma(s)*gamma(1-s)=%pi/sin(%pi*s)),l),e))$
/* ratsubst with multiple equation input -- warning: does no error checking
on input */
eratsubst(eqs,val) := (while eqs # [] do (val:
ratsubst(rhs(first(eqs)),lhs(first(eqs)),val), eqs: rest(eqs)), val)$
-s
On Mon, Mar 25, 2013 at 10:57 PM, Barton Willis <willisb at unk.edu> wrote:
> reduce_product_gamma(e) := block([l],
> l : map('first, gatherargs(e,'gamma)),
> l : sublist(l, lambda([s], not integerp(s))), /* can't happen unless
> simp : false ? */
> l : sort(l, lambda([a,b], orderlessp(b,a))), /* try to guess which sub
> gives simplest result */
> subst(map(lambda([s], gamma(s)*gamma(1-s)=%pi/sin(%pi*s)),l),e))$