8
$\begingroup$

Bug introduced in 9.0 and fixed in 11.3.0


Consider the following symbolic expression (all the c's are undefined)

exp = (-4*I)*(-1 + c22)*Pi*c1[c7[c12], c7[Glu5], c7[c9[c1312][0]]]*
c13[{c7[Glu5], c7[c9[c1312][0]]}, c10[c25], c10[c24]]*
c8[c11[c15, c6], c5[l, c6]]*
c4[c5[p2, c6], c6].c4[c5[l, c6], c6].c4[c5[p1, c6], c6]*c40[c15]*
c40[c20] - (4*I)*(-1 + c22)*Pi*
c1[c7[c12], c7[Glu5], c7[c9[c1312][0]]]*
c13[{c7[Glu5], c7[c9[c1312][0]]}, c10[c25], c10[c24]]*
c8[c11[c15, c6], c5[p2, c6]]*
c4[c5[p1, c6], c6].c4[c5[p2, c6], c6]*c40[c14]*c40[c15]*
c40[c20] - (4*I)*(-1 + c22)*Pi*
c1[c7[c12], c7[Glu5], c7[c9[c1312][0]]]*
c13[{c7[Glu5], c7[c9[c1312][0]]}, c10[c25], 
 c10[c24]]*(c8[c5[p1, c6], c5[p1, c6]] - 
  2*c8[c5[p1, c6], c5[p2, c6]] + 
  c8[c5[p2, c6], 
   c5[p2, c6]])*(c4[c5[p1, c6], c6].c4[c5[p1, c6], c6].c4[
    c11[c15, c6], c6] - 
  c4[c5[p2, c6], c6].c4[c5[p1, c6], c6].c4[c11[c15, c6], c6] + 
  c4[c5[p1, c6], c6].c4[c11[c15, c6], c6]*c40[c14] - 
  c4[c5[p2, c6], c6].c4[c11[c15, c6], c6]*c40[c14])*c40[c15]*
c40[c20] + (4*I)*(-1 + c22)*Pi*
c1[c7[c12], c7[Glu5], c7[c9[c1312][0]]]*
c13[{c7[Glu5], c7[c9[c1312][0]]}, c10[c25], c10[c24]]*
c8[c11[c15, c6], 
 c5[p1, c6]]*(c4[c5[p1, c6], c6].c4[c5[p1, c6], c6].c4[c5[p1, c6],
     c6] - c4[c5[p1, c6], c6].c4[c5[p1, c6], c6].c4[c5[p2, c6], 
    c6] - c4[c5[p2, c6], c6].c4[c5[p1, c6], c6].c4[c5[p1, c6], 
    c6] + c4[c5[p2, c6], c6].c4[c5[p1, c6], c6].c4[c5[p2, c6], 
    c6] + c4[c5[p1, c6], c6].c4[c5[p1, c6], c6]*c40[c14] - 
  c4[c5[p1, c6], c6].c4[c5[p2, c6], c6]*c40[c14] - 
  c4[c5[p2, c6], c6].c4[c5[p1, c6], c6]*c40[c14] + 
  c4[c5[p2, c6], c6].c4[c5[p2, c6], c6]*c40[c14])*c40[c15]*
c40[c20];

Now try to evaluate the following code

AbsoluteTiming[res1 = Simplify[exp];]
AbsoluteTiming[res2 = Factor[exp];]
Simplify[res1 - res2]

On Mathematica 8 (Linux version) both Simplify and Factor finish in less than 0.1 seconds. However, with all newer versions (9, 10.3, 11.0) that I have, Factor never finishes, while Simplify is still very fast.

To me this looks like a bug/regression, but may be someone has a sensible explanation for this behavior. I have not reported this to WRI so far, but I'm planning to do so.

Edit:

res1 is

(-4*I)*(-1 + c22)*Pi*c1[c7[c12], c7[Glu5], c7[c9[c1312][0]]]*
 c13[{c7[Glu5], c7[c9[c1312][0]]}, c10[c25], c10[c24]]*c40[c15]*c40[c20]*
 (c40[c14]*c8[c11[c15, c6], c5[p2, c6]]*c4[c5[p1, c6], c6] . 
    c4[c5[p2, c6], c6] + c8[c11[c15, c6], c5[l, c6]]*
   c4[c5[p2, c6], c6] . c4[c5[l, c6], c6] . c4[c5[p1, c6], c6] + 
  (c8[c5[p1, c6], c5[p1, c6]] - 2*c8[c5[p1, c6], c5[p2, c6]] + 
    c8[c5[p2, c6], c5[p2, c6]])*
   (c40[c14]*(c4[c5[p1, c6], c6] . c4[c11[c15, c6], c6] - 
      c4[c5[p2, c6], c6] . c4[c11[c15, c6], c6]) + 
    c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] . c4[c11[c15, c6], c6] - 
    c4[c5[p2, c6], c6] . c4[c5[p1, c6], c6] . c4[c11[c15, c6], c6]) - 
  c8[c11[c15, c6], c5[p1, c6]]*
   (c40[c14]*(c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] - 
      c4[c5[p1, c6], c6] . c4[c5[p2, c6], c6] - c4[c5[p2, c6], c6] . 
       c4[c5[p1, c6], c6] + c4[c5[p2, c6], c6] . c4[c5[p2, c6], c6]) + 
    c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] - 
    c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] . c4[c5[p2, c6], c6] - 
    c4[c5[p2, c6], c6] . c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] + 
    c4[c5[p2, c6], c6] . c4[c5[p1, c6], c6] . c4[c5[p2, c6], c6]))

res2 is

(-4*I)*(-1 + c22)*Pi*c1[c7[c12], c7[Glu5], c7[c9[c1312][0]]]*
 c13[{c7[Glu5], c7[c9[c1312][0]]}, c10[c25], c10[c24]]*c40[c15]*c40[c20]*
 (c40[c14]*c8[c5[p1, c6], c5[p1, c6]]*c4[c5[p1, c6], c6] . 
    c4[c11[c15, c6], c6] - 2*c40[c14]*c8[c5[p1, c6], c5[p2, c6]]*
   c4[c5[p1, c6], c6] . c4[c11[c15, c6], c6] + 
  c40[c14]*c8[c5[p2, c6], c5[p2, c6]]*c4[c5[p1, c6], c6] . 
    c4[c11[c15, c6], c6] - c40[c14]*c8[c11[c15, c6], c5[p1, c6]]*
   c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] + 
  c40[c14]*c8[c11[c15, c6], c5[p1, c6]]*c4[c5[p1, c6], c6] . 
    c4[c5[p2, c6], c6] + c40[c14]*c8[c11[c15, c6], c5[p2, c6]]*
   c4[c5[p1, c6], c6] . c4[c5[p2, c6], c6] - 
  c40[c14]*c8[c5[p1, c6], c5[p1, c6]]*c4[c5[p2, c6], c6] . 
    c4[c11[c15, c6], c6] + 2*c40[c14]*c8[c5[p1, c6], c5[p2, c6]]*
   c4[c5[p2, c6], c6] . c4[c11[c15, c6], c6] - 
  c40[c14]*c8[c5[p2, c6], c5[p2, c6]]*c4[c5[p2, c6], c6] . 
    c4[c11[c15, c6], c6] + c40[c14]*c8[c11[c15, c6], c5[p1, c6]]*
   c4[c5[p2, c6], c6] . c4[c5[p1, c6], c6] - 
  c40[c14]*c8[c11[c15, c6], c5[p1, c6]]*c4[c5[p2, c6], c6] . 
    c4[c5[p2, c6], c6] + c8[c5[p1, c6], c5[p1, c6]]*
   c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] . c4[c11[c15, c6], c6] - 
  2*c8[c5[p1, c6], c5[p2, c6]]*c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] . 
    c4[c11[c15, c6], c6] + c8[c5[p2, c6], c5[p2, c6]]*
   c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] . c4[c11[c15, c6], c6] - 
  c8[c11[c15, c6], c5[p1, c6]]*c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] . 
    c4[c5[p1, c6], c6] + c8[c11[c15, c6], c5[p1, c6]]*
   c4[c5[p1, c6], c6] . c4[c5[p1, c6], c6] . c4[c5[p2, c6], c6] + 
  c8[c11[c15, c6], c5[l, c6]]*c4[c5[p2, c6], c6] . c4[c5[l, c6], c6] . 
    c4[c5[p1, c6], c6] - c8[c5[p1, c6], c5[p1, c6]]*
   c4[c5[p2, c6], c6] . c4[c5[p1, c6], c6] . c4[c11[c15, c6], c6] + 
  2*c8[c5[p1, c6], c5[p2, c6]]*c4[c5[p2, c6], c6] . c4[c5[p1, c6], c6] . 
    c4[c11[c15, c6], c6] - c8[c5[p2, c6], c5[p2, c6]]*
   c4[c5[p2, c6], c6] . c4[c5[p1, c6], c6] . c4[c11[c15, c6], c6] + 
  c8[c11[c15, c6], c5[p1, c6]]*c4[c5[p2, c6], c6] . c4[c5[p1, c6], c6] . 
    c4[c5[p1, c6], c6] - c8[c11[c15, c6], c5[p1, c6]]*
   c4[c5[p2, c6], c6] . c4[c5[p1, c6], c6] . c4[c5[p2, c6], c6])
$\endgroup$
11
  • 3
    $\begingroup$ "Simple" expression? Really? And how could anyone know how "simple" it is when SUNF, SMP, SUNIndes, SUNTF, GaugeXi, LorentzIndex, Momentup, Glu2, and many other terms are not defined? $\endgroup$ Jul 17, 2017 at 18:05
  • 3
    $\begingroup$ In this example all the occurring symbols are undefined. I modified the example to have them just a c a number in the name. However, here it really does not matter what exp means. The point is that this example works perfectly with Mahtematica 8 but not any higher version. I regularly use Factor and Simplify on much more complicated symbolic expressions without any problems. For my standards the given expressions is very simple and it is strange that Factor cannot handle it (although it could in MMA 8). $\endgroup$
    – vsht
    Jul 17, 2017 at 18:52
  • 1
    $\begingroup$ @DanielLichtblau Thanks. I usually prefer Factor over Simplify for performance reasons, so this example got me really surprised. $\endgroup$
    – vsht
    Jul 17, 2017 at 19:01
  • 9
    $\begingroup$ Factor should do better here. This will be treated as a bug. $\endgroup$ Jul 18, 2017 at 0:42
  • 3
    $\begingroup$ @DanielLichtblau By the way, is there already a case number for this issue? Looks like people for some reason do not like this question (already 3 votes to close it). So if that happens I'd like to have something in a hand to be able to follow the issue with Factor. (Sometimes it takes several releases, before a bug is fixed ;) ) $\endgroup$
    – vsht
    Jul 18, 2017 at 20:45

2 Answers 2

5
$\begingroup$

This bug in Factor has been addressed as of version 11.3.0.

While the example may take some seconds to run, it will not hang

AbsoluteTiming[res1 = Simplify[exp];]
AbsoluteTiming[res2 = Factor[exp];]
Simplify[res1 - res2]

(* {0.060817, Null} *)
(* {13.5211, Null} *)
(* 0 *)
$\endgroup$
5
  • 1
    $\begingroup$ Great, many thanks! I guess there is no simple way to make Factor as fast as in version 8 where it also required much less then a second on this expression? $\endgroup$
    – vsht
    Mar 12, 2018 at 1:50
  • $\begingroup$ I have just tried the same example in Mathematica 12.0 on Linux (Fedora 28) and there Factor requires 104 seconds (sic!), while Simplify finishes in less than 0.0002 seconds. Although Factor finishes correctly, the amount of time it spends on this expression as compared to v. 11.3 seems to be way too high. Can this be regarded as a bug? $\endgroup$
    – vsht
    Apr 24, 2019 at 9:07
  • $\begingroup$ @vsht I think an order of magnitude slowdown is definitely worth reporting. It may well be a bug (though it could also be a side effect of fixing a different bug). $\endgroup$
    – ilian
    Apr 24, 2019 at 17:23
  • $\begingroup$ Ok, I've just reported this regression to the WRI support. Let us see what they will reply. $\endgroup$
    – vsht
    Apr 25, 2019 at 8:37
  • $\begingroup$ The performance regression of Factor has been given [CASE:4251515]. Let us hope that it will become fast again in Mathematica 12.1 or so. $\endgroup$
    – vsht
    Apr 26, 2019 at 3:29
3
$\begingroup$
AbsoluteTiming[res2 = exp // FactorTerms // Factor]

gives 0.03 seconds for me using Mathematica 12.0.

$\endgroup$
6
  • $\begingroup$ Thanks, Rolf. I am looking into the slowdown, but this aspect caught me by surprise. $\endgroup$ Jun 1, 2019 at 18:45
  • $\begingroup$ You are welcome. Vlad thought he could get rid of my old Factor2 function from FeynCalc, where several heuristic workarounds for old-time deficencies of Factor are collected, but not quite yet. $\endgroup$ Jun 1, 2019 at 22:47
  • $\begingroup$ Weirdly enough, there may be examples where the reverse is true: multiplying through by a complex-valued constant could make the factorization faster. (I do not have such an example offhand, but the possibility is there.) $\endgroup$ Jun 2, 2019 at 12:09
  • $\begingroup$ Rolf is as always superb in finding workarounds when standard functions don't behave as one would like them to. +1 from me. However, the statement is not quite true. I never intended to get rid of Factor2. In most cases it returns "nicer" results than Factor, so it will definitely remain part of FeynCalc. What I wanted to get rid of at some point is Apart1, but this is also currently not feasible. $\endgroup$
    – vsht
    Jun 3, 2019 at 11:02
  • $\begingroup$ The reason is that Apart still has some performance problems when the expressions contain complex numbers, cf. mathematica.stackexchange.com/questions/112069/… $\endgroup$
    – vsht
    Jun 3, 2019 at 11:03

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.