# Simplify gamma functions to beta functions

I am trying to express an expression containing gamma functions in terms of beta functions:

GammaToBeta = # /. {Gamma[x_]*Gamma[y_]/Gamma[x_+y_]-> Beta[x,y]} &;
FullSimplify[(Gamma[x]*Gamma[y]/Gamma[x+y])*(Gamma[u+v]/Gamma[u]/Gamma[v]),
TransformationFunctions->{Automatic, GammaToBeta}]


With this code, the output is

 (Beta[x, y] Gamma[u + v])/(Gamma[u] Gamma[v])


The second occurrence of a beta function is not detected. How can I make this work?

Simpler patterns are applied in more cases -- well, that perhaps is more a rule of thumb than a general theorem. The following works on the example, but whether it works more generally probably depends on the ComplexityFunction as well.

gammaToBeta = # /. {Gamma[x_ + y_] :> Gamma[x]*Gamma[y]/Beta[x, y]} &;
FullSimplify[
(Gamma[x]*Gamma[y]/Gamma[x + y])*(Gamma[u + v]/Gamma[u]/Gamma[v]),
TransformationFunctions -> {Automatic, gammaToBeta}]
(*  Beta[x, y]/Beta[u, v]  *)


Some observations about finding the right transformations

A more general replacement, which also works:

Gamma[x_ + y__] :> Gamma[x]*Gamma[Plus[y]]/Beta[x, Plus[y]]


A mathematically equivalent replacement, which does not work because the LHS never matches what was intended (matches, e.g., Gamma[u + v] Gamma[x]):

Gamma[x_] Gamma[y_] :> Gamma[x + y] Beta[x, y]


Better, but does not match the Power[Gamma[u], -1] Power[Gamma[v], -1] the OP is after:

Gamma[x : Except[_Plus]] Gamma[y : Except[_Plus]] :> Gamma[x + y] Beta[x, y]


There may be an art to constructing the right set of transformations, but there also appears to be a need for some trial and error. It certainly helps to inspect the FullForm of the expression (or at least the part you're interested in). That's where you'll find Power[Gamma[u], -1] and see why it is not touched by the OP's transformation.

you can do this:

GammaToBeta = # /. {Gamma[x_]*Gamma[y_]/Gamma[x_ + y_] ->
Beta[x, y]} &;
GammaToBetai = # /. {Gamma[x_ + y_]/Gamma[x_]/Gamma[y_] ->
1/Beta[x, y]} &;
FullSimplify[(Gamma[x]*Gamma[y]/Gamma[x + y])*(Gamma[u + v]/Gamma[u]/
Gamma[v]),
TransformationFunctions -> {Automatic, GammaToBeta, GammaToBetai}]


Beta[x, y]/Beta[u, v]

I don't know if there is a more general approach.