I have a complicated expression, which among other things has stuff like functions of rational functions:
expr = f[x/(-x^2 + y)] + f[-(x/(x^2 - y))] (* + ...*)
If you apply Simplify to the whole expression, they combine, which is what I ultimately want to achieve:
Simplify[expr]
(* 2 f[-(x/(x^2 - y))] ... *)
However, my complicated expression is so complicated, I prefer not to apply any top-level functions on the entire thing, since it will take a lot of time.
My solution to this problem is to map these top-level functions to the arguments of f like so,
expr /. f[x_] :> f[Simplify[x]]
in the hopes of making the fractions look the same so that they combine. But it doesn't work. Is there another way to achieve this task? (putting these fractions in canonical form, etc.)
expr /. f[x_] :> f[Factor[x]]works for the example provided. – Marius Ladegård Meyer Jun 11 '16 at 10:35Together[]for this. – J. M.'s missing motivation Jun 11 '16 at 11:43Factordoesn't work for-(x/(a^2 - x))andx/(-a^2 + x)– QuantumDot Jun 11 '16 at 14:54Togetherdoesn't work for-(x/(a^2 - x))andx/(-a^2 + x)– QuantumDot Jun 11 '16 at 14:55Together[Apart[(* stuff *)]], but this might be more effort-intensive thanSimplify[]in some cases. BTW: you might be helped byInternal`RationalFunctionQ[]. – J. M.'s missing motivation Jun 11 '16 at 15:01Internal`RationalFunctionQ[]works provided I give it a list of symbols in the second argument to test the expression with. But I wouldn't know them beforehand. It would be nice if it would test by using allSymbolsas variables. – QuantumDot Jun 11 '16 at 15:13Reduce`FreeVariables[expr]to get the required symbols. – J. M.'s missing motivation Jun 11 '16 at 15:34Factor2@{-(x/(a^2 - x)), x/(-a^2 + x)}and you get{-(x/(a^2 - x)), -(x/(a^2 - x))}. I never really understood why Factor does not do this by default. So I coded Factor2. – Rolf Mertig Jun 11 '16 at 16:37f[x_?(Internal`RationalFunctionQ[#, Reduce`FreeVariables[#]] &)] :> f[Together@Apart@x]Is that what you had in mind. Quite a lot of undocumented functions there... – QuantumDot Jun 11 '16 at 18:25Apart2and it seems to do exactly what I need... I'll have a look at the source; thanks! – QuantumDot Jun 11 '16 at 18:26f[x_ /; Internal`RationalFunctionQ[x, Reduce`FreeVariables[x]]], but that's just my style; you've got it. – J. M.'s missing motivation Jun 11 '16 at 18:48Factor2. Would you let me know which file it's in? – QuantumDot Jun 12 '16 at 08:27Factor2.mfile in the "general" folder of the compressed file you get when you download the latest version of FeynCalc. – MarcoB Jun 12 '16 at 20:07