3

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.)

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
QuantumDot
  • 19,601
  • 7
  • 45
  • 121
  • expr /. f[x_] :> f[Factor[x]] works for the example provided. – Marius Ladegård Meyer Jun 11 '16 at 10:35
  • 1
    You could use Together[] for this. – J. M.'s missing motivation Jun 11 '16 at 11:43
  • @MariusLadegårdMeyer Thanks, but Factor doesn't work for -(x/(a^2 - x)) and x/(-a^2 + x) – QuantumDot Jun 11 '16 at 14:54
  • @J.M. Thanks, but Together doesn't work for -(x/(a^2 - x)) and x/(-a^2 + x) – QuantumDot Jun 11 '16 at 14:55
  • In that case, try composing like so: Together[Apart[(* stuff *)]], but this might be more effort-intensive than Simplify[] in some cases. BTW: you might be helped by Internal`RationalFunctionQ[]. – J. M.'s missing motivation Jun 11 '16 at 15:01
  • @J.M. Internal`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 all Symbols as variables. – QuantumDot Jun 11 '16 at 15:13
  • Then maybe you can do Reduce`FreeVariables[expr] to get the required symbols. – J. M.'s missing motivation Jun 11 '16 at 15:34
  • You could try to extract the source of Factor2 from FeynCalc, which solves your problem. After loading (any version of) FeynCalc just do Factor2@{-(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:37
  • 2
    @J.M. So here's what I came up with: f[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:25
  • @RolfMertig Yes, I agree it would be nice if a built-in function would do this seemly simple thing. I just now tried Apart2 and it seems to do exactly what I need... I'll have a look at the source; thanks! – QuantumDot Jun 11 '16 at 18:26
  • Well, I'd have done it as f[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:48
  • @RolfMertig silly question -- I can't seem to find the file in the FeynCalc that contains the source of Factor2. Would you let me know which file it's in? – QuantumDot Jun 12 '16 at 08:27
  • 1
    @QuantumDot I think you are looking for the Factor2.m file 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
  • @QuantumDot See here: https://github.com/FeynCalc/feyncalc/blob/master/FeynCalc/Shared/Factor.m – vsht Jun 13 '16 at 11:38
  • This query would benefit from a concrete example, perhaps in an attached nb. – Daniel Lichtblau Aug 01 '16 at 21:41

0 Answers0