MathGroup Archive 2009

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Significant slow-down with Mathematica 7 (vs 6).

  • To: mathgroup at smc.vnet.net
  • Subject: [mg95913] Re: [mg95826] Significant slow-down with Mathematica 7 (vs 6).
  • From: Adam Strzebonski <adams at wolfram.com>
  • Date: Thu, 29 Jan 2009 05:59:39 -0500 (EST)
  • Reply-to: adams at wolfram.com

In Mathematica 7 RootReduce has a choice of two methods.

Method->"Recursive" recursively performs algebraic number arithmetic,
in a very similar way to what Mathematica 6 RootReduce was doing

Method->"NumberField" first converts algebraic numbers in the input
to AlgebraicNumber objects with the same generator and then performs
the arithmetic within the algebraic number field.

For each of the two methods there are examples where the method
is significantly (by more than a factor of 1000) faster than
the other one. With the default setting Method->Automatic, RootReduce
attempts to heuristically pick the faster method. Unfortunately,
there is no way to tell a priori which method will be faster and
for some examples the heuristic makes the wrong choice.

For your example the automatic method selection picks the "NumberField"
method, but the "Recursive" method is much faster.

In[3]:= RootReduce[x, Method->"Recursive"]//Timing

                                                  2         4
Out[3]= {1.36009, Root[-2769706384 - 370035819 #1  + 324 #1  & , 2]}

For comparison, Mathematica 6 run on the same machine gives

In[3]:= RootReduce[x]//Timing

                                                  2         4
Out[3]= {2.85218, Root[-2769706384 - 370035819 #1  + 324 #1  & , 2]}

so Mathematica 7, with the "Recursive" method is even somewhat faster
than Mathematica 6.

If you see that Mathematica 7 RootReduce is slower than Mathematica 6
on a significant portion of examples that appear in your calculations,
you should probably use SetOptions[RootReduce, Method->"Recursive"].

I would be grateful if you could send me a few more of the examples,
so that I could use them to better tune the automatic method selection.

Best Regards,

Adam Strzebonski
Wolfram Research

Scott Morrison wrote:
 > I use RootReduce extremely heavily (subfactor/planar algebra
 > calculations). I've recently discovered that in many cases RootReduce
 > in Mathematica 7 runs significantly slower than in Mathematica 6. (Of 
course, I've
 > checked on the same machine.)
 >
 > As an example, try RootReduce[x] with
 >
 > x =
 > (Sqrt[(-1 + Sqrt[17])*(1 + Sqrt[17])]*
 >       Root[-2 - 3*#1^2 + #1^4 & , 2, 0]*
 >       Root[128 - 8055*#1^2 + 81*#1^4 & , 4, 0])/
 >     2 + (Sqrt[
 >        5 + Sqrt[17]]*(Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-32 - 5*#1^2 + #1^4 & , 2, 0]*
 >          Root[32768 - 78588*#1^2 + 81*#1^4 & , 4, 0] -
 >         2*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-16384 - 36144*#1^2 + 81*#1^4 & , 1, 0] +
 >         Sqrt[2*(5 - Sqrt[17])]*Root[-2 - 3*#1^2 + #1^4 & , 2, 0]*
 >          Root[128 - 8055*#1^2 + 81*#1^4 & , 4, 0]))/
 >     2 + (Sqrt[
 >        5 + Sqrt[17]]*(4*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-32 - 5*#1^2 + #1^4 & , 2, 0]*
 >          Root[32768 - 78588*#1^2 + 81*#1^4 & , 4, 0] +
 >         4*Sqrt[2*(5 - Sqrt[17])]*Root[32 - 23*#1^2 + 4*#1^4 & , 1, 0]*
 >          Root[-8192 - 30645*#1^2 + 81*#1^4 & , 1, 0] +
 >         9*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-16384 - 13347*#1^2 + 81*#1^4 & , 2, 0] -
 >         Sqrt[34*(5 - Sqrt[17])]*
 >          Root[-16384 - 13347*#1^2 + 81*#1^4 & , 2, 0] +
 >         4*Sqrt[2*(5 - Sqrt[17])]*Root[-8 + 11*#1^2 + #1^4 & , 1, 0]*
 >          Root[8192 - 6300*#1^2 + 81*#1^4 & , 1, 0] +
 >         Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-1024 - 5499*#1^2 + 81*#1^4 & , 2, 0] -
 >         Sqrt[34*(5 - Sqrt[17])]*
 >          Root[-1024 - 5499*#1^2 + 81*#1^4 & , 2, 0]))/
 >     8 + (Sqrt[
 >        5 + Sqrt[17]]*(38*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-4 + #1^2 + #1^4 & , 2, 0] +
 >         10*Sqrt[34*(5 - Sqrt[17])]*Root[-4 + #1^2 + #1^4 & , 2, 0] -
 >         12*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-16384 - 36144*#1^2 + 81*#1^4 & , 1, 0] +
 >         6*Sqrt[2*(5 - Sqrt[17])]*Root[-8 + 11*#1^2 + #1^4 & , 1, 0]*
 >          Root[8192 - 6300*#1^2 + 81*#1^4 & , 1, 0] -
 >         9*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-4096 - 2736*#1^2 + 81*#1^4 & , 2, 0] +
 >         3*Sqrt[34*(5 - Sqrt[17])]*
 >          Root[-4096 - 2736*#1^2 + 81*#1^4 & , 2, 0] +
 >         6*Sqrt[2*(5 - Sqrt[17])]*Root[-1 + 3*#1^2 + 2*#1^4 & , 2, 0]*
 >          Root[512 - 2556*#1^2 + 81*#1^4 & , 1, 0]))/
 >     12 + (Sqrt[
 >        5 + Sqrt[17]]*(Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-16 - 251*#1^2 + 4*#1^4 & , 1, 0] +
 >         2*Sqrt[2*(5 - Sqrt[17])]*Root[-1 + 3*#1^2 + 2*#1^4 & , 1, 0]*
 >          Root[512 - 2556*#1^2 + 81*#1^4 & , 4, 0]))/
 >     4 + (Sqrt[
 >        5 + Sqrt[17]]*(2*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-1 + 3*#1^2 + 2*#1^4 & , 1, 0]*
 >          Root[512 - 2556*#1^2 + 81*#1^4 & , 4, 0] -
 >         3*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-256 - 684*#1^2 + 81*#1^4 & , 1, 0] +
 >         Sqrt[34*(5 - Sqrt[17])]*
 >          Root[-256 - 684*#1^2 + 81*#1^4 & , 1, 0]))/
 >     4 + (Sqrt[(-1 + Sqrt[17])*(1 + Sqrt[17])]*
 >       Root[-1 + 3*#1^2 + 2*#1^4 & , 1, 0]*
 >       Root[32 - 639*#1^2 + 81*#1^4 & , 1, 0])/
 >     2 + (Sqrt[
 >        5 + Sqrt[17]]*(2*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-8 + 11*#1^2 + #1^4 & , 1, 0]*
 >          Root[8192 - 6300*#1^2 + 81*#1^4 & , 1, 0] -
 >         3*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-4096 - 2736*#1^2 + 81*#1^4 & , 2, 0] +
 >         Sqrt[34*(5 - Sqrt[17])]*
 >          Root[-4096 - 2736*#1^2 + 81*#1^4 & , 2, 0] +
 >         2*Sqrt[2*(5 - Sqrt[17])]*Root[-1 + 3*#1^2 + 2*#1^4 & , 1, 0]*
 >          Root[32 - 639*#1^2 + 81*#1^4 & , 1, 0]))/
 >     4 + (Sqrt[(-1 + Sqrt[17])*(1 + Sqrt[17])]*
 >       Root[2 - 7*#1^2 + 4*#1^4 & , 1, 0]*
 >       Root[-128 - 12573*#1^2 + 324*#1^4 & , 1, 0])/
 >     2 + (Sqrt[
 >        5 + Sqrt[17]]*(19*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-4 + #1^2 + #1^4 & , 2, 0] +
 >         5*Sqrt[34*(5 - Sqrt[17])]*Root[-4 + #1^2 + #1^4 & , 2, 0] +
 >         3*Sqrt[2*(5 - Sqrt[17])]*Root[32 - 23*#1^2 + 4*#1^4 & , 1, 0]*
 >          Root[-8192 - 30645*#1^2 + 81*#1^4 & , 1, 0] +
 >         3*Sqrt[2*(5 - Sqrt[17])]*Root[2 - 7*#1^2 + 4*#1^4 & , 1, 0]*
 >          Root[-128 - 12573*#1^2 + 324*#1^4 & , 1, 0]))/
 >     6 + ((-1 + Sqrt[17])^(3/2)*Sqrt[1 + Sqrt[17]]*
 >       Root[-256 - 5499*#1^2 + 324*#1^4 & , 2, 0])/
 >     8 + (Sqrt[
 >        5 + Sqrt[17]]*(9*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-16384 - 13347*#1^2 + 81*#1^4 & , 2, 0] -
 >         Sqrt[34*(5 - Sqrt[17])]*
 >          Root[-16384 - 13347*#1^2 + 81*#1^4 & , 2, 0] +
 >         4*Sqrt[2*(5 - Sqrt[17])]*Root[-8 + 11*#1^2 + #1^4 & , 1, 0]*
 >          Root[8192 - 6300*#1^2 + 81*#1^4 & , 1, 0] -
 >         Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-256 - 5499*#1^2 + 324*#1^4 & , 2, 0] +
 >         Sqrt[34*(5 - Sqrt[17])]*
 >          Root[-256 - 5499*#1^2 + 324*#1^4 & , 2, 0]))/
 >     8 + (Sqrt[
 >        5 + Sqrt[17]]*(4*Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-2 - 3*#1^2 + #1^4 & , 2, 0]*
 >          Root[128 - 8055*#1^2 + 81*#1^4 & , 4, 0] +
 >         Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-1024 - 5499*#1^2 + 81*#1^4 & , 2, 0] -
 >         Sqrt[34*(5 - Sqrt[17])]*
 >          Root[-1024 - 5499*#1^2 + 81*#1^4 & , 2, 0] +
 >         4*Sqrt[2*(5 - Sqrt[17])]*Root[-1 + 3*#1^2 + 2*#1^4 & , 2, 0]*
 >          Root[512 - 2556*#1^2 + 81*#1^4 & , 1, 0] +
 >         4*Sqrt[2*(5 - Sqrt[17])]*Root[-1 + 3*#1^2 + 2*#1^4 & , 1, 0]*
 >          Root[32 - 639*#1^2 + 81*#1^4 & , 1, 0] +
 >         4*Sqrt[2*(5 - Sqrt[17])]*Root[2 - 7*#1^2 + 4*#1^4 & , 1, 0]*
 >          Root[-128 - 12573*#1^2 + 324*#1^4 & , 1, 0] -
 >         Sqrt[2*(5 - Sqrt[17])]*
 >          Root[-256 - 5499*#1^2 + 324*#1^4 & , 2, 0] +
 >         Sqrt[34*(5 - Sqrt[17])]*
 >          Root[-256 - 5499*#1^2 + 324*#1^4 & , 2, 0]))/
 >     8 + (Sqrt[(1 + Sqrt[17])/
 >         2]*(4*Sqrt[2*(-1 + Sqrt[17])]*
 >          Root[-2 - 3*#1^2 + #1^4 & , 2, 0]*
 >          Root[128 - 8055*#1^2 + 81*#1^4 & , 4, 0] +
 >         4*Sqrt[2*(-1 + Sqrt[17])]*Root[-1 + 3*#1^2 + 2*#1^4 & , 1, 0]*
 >          Root[32 - 639*#1^2 + 81*#1^4 & , 1, 0] +
 >         4*Sqrt[2*(-1 + Sqrt[17])]*Root[-1 + 3*#1^2 + 2*#1^4 & , 2, 0]*
 >          Root[32 - 639*#1^2 + 81*#1^4 & , 4, 0] +
 >         4*Sqrt[2*(-1 + Sqrt[17])]*Root[2 - 7*#1^2 + 4*#1^4 & , 1, 0]*
 >          Root[-128 - 12573*#1^2 + 324*#1^4 & , 1, 0] -
 >         Sqrt[2*(-1 + Sqrt[17])]*
 >          Root[-256 - 5499*#1^2 + 324*#1^4 & , 2, 0] +
 >         Sqrt[34*(-1 + Sqrt[17])]*
 >          Root[-256 - 5499*#1^2 + 324*#1^4 & , 2, 0]))/8;
 >
 > this runs in <2s in Mathematica 6 on my machine, and >30s in 
Mathematica7.
 > I have other examples where the difference is even worse.
 >
 > Thanks,
 > Scott Morrison



  • Prev by Date: Re: Mathematica having trouble with simple calculation...
  • Next by Date: Book mathematica 6
  • Previous by thread: Significant slow-down with Mathematica 7 (vs 6).
  • Next by thread: Re: Re: Significant slow-down with Mathematica 7 (vs 6).