Here is a more robust version of what I was doing before. ConsiderConsider your expression,
ThisBut as OP points out, this will break up a term intonot combine terms where the largest number of fractionsdenominator is the same except for a constant factor, without repeating denominatorslike a/(2*b)
and c/b
. Here it is This function should be able to simplify an rational expression like desired in functional formthe OP (if you come up with a way to break the function, please let me know).
fractionExpand[expr_] :=
Replace[Expand@expr,
expr2_Plus :> (Together@*Plus @@@
GatherBy[List @@ Expand[expr]expr2, Denominator]Variables@*Denominator] //
Total)]
Here is anotherThis will break up a term into the largest number of fractions, longer testwithout repeating denominators. Here are a few tests,
expr2 = (1 + m)/b + (1 + n)/a + (1 + o)/c + (d + e + f g)/(
a b) + (h + i + j k)/(b c) + (l + p q)/(a b c) // Together
(* (a b + a c + b c + c d + c e + c f g + a h + a i + a j k + l + a c m +
fractionExpand@expr2
b c n
You get back the original input.
expr3 += a b o + p q)/(a2 b c) *)
fractionExpand@expr2
(* (d + e + f g)c/(a b) + (h + i + j k)d/(b c) + (1e + m)f/b + (
1g + nz)/a + (1a +- oc)/c + (l + p q)/(am b c) *)// Together
You get back the original input.
fractionExpand@expr3