I experience difficulties when using custom transformation rules. Below I give two concrete problems. I am interested in fixing each of them and in understanding what is wrong with my attitude to the issue in general.
1) Suppose I try to make symbolic computations involving gamma function $\Gamma(z)$ more effective. Particularly, I want $\it{Mathematica}$ to make use of the property $\frac{\Gamma(z+1)}{\Gamma(z)}=z$ in simplification, which it doesn't do on its own. Evaluation of
Simplify[Gamma[z + 1]/Gamma[z]]
returns
Gamma[1 + z]/Gamma[z]
In order to handle this task let me define the first transformation function
tf1[e_] := e /. Gamma[x_]/Gamma[y_] /; Simplify[x - y] == 1 :> y;
Now evaluation of
Simplify[Gamma[z + 1]/Gamma[z],
TransformationFunctions -> {Automatic, tf1}]
indeed gives
z
However, execution of
Simplify[Gamma[z + 1]^2/Gamma[z]^2,
TransformationFunctions -> {Automatic, tf1}]
results in no real simplification and gives
Gamma[1 + z]^2/Gamma[z]^2
Well, one unwitty way to deal with this problem is to define a separate transformation function for the ratio of squares. But the ratio of the third powers will then require a third transformation function and so on. I would like to handle all these possibilities universally.
I've tried something like
tfUniversal[e_] :=
e /. (Gamma[x_]/Gamma[y_])^n_ /; Simplify[x - y] == 1 :> y^n;
but this didn't work. Is there a way to solve this problem?
2) The second chapter of my adventures includes teaching "Mathematica" identity $\Gamma(z)\Gamma(1-z)=\frac{\pi}{\sin{\pi z}}$. Here problem comes right at the start. I define transformation function
tf2[e_] :=
e /. Gamma[x_] Gamma[y_] /; Simplify[x + y] == 1 :> Pi/Sin[Pi x];
and then evaluate
Simplify[{Gamma[-z] Gamma[1 + z], Gamma[z] Gamma[1 - z]},
TransformationFunctions -> {Automatic, tf2}]
which gives
{-\[Pi] Csc[\[Pi] z], Gamma[1 - z] Gamma[z]}
so that simplification occurs in the first case but not in the second. I wonder what is the problem here.
Overall, I am very often troubled with such issues. Is it possible to find some references in the literature on using custom transformation rules?
Any help is highly appreciated, thanks :)
FullSimplify[Gamma[z + 1]/Gamma[z]]
help ? $\endgroup$Simplify
andFullSimplify
is important here. However, the question basically remains sinceFullSimplify
won't work for some other functions (e.g.BarnesG
which satisfiesBarnesG[z+1]/Barnes[z]=Gamma[z]
). $\endgroup$Developer`GammaSimplify
which will attempt to reduce the number of gamma functions even if the resulting expression is more complex, e.g.Developer`GammaSimplify[Gamma[z+4]/Gamma[z]]
$\endgroup$