Re: Re: Help with Root function
- To: mathgroup at smc.vnet.net
- Subject: [mg79500] Re: [mg79483] Re: [mg79407] Help with Root function
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Sat, 28 Jul 2007 05:26:51 -0400 (EDT)
- References: <14196226.1185458345477.JavaMail.root@m35> <200707271004.GAA03476@smc.vnet.net>
I think this is somewhat understating the superiority of Root objects over radicals. More accurately, Root objects will do for you anything that Radicals will do, but they will do it faster and with greater accuracy. I have written about this far too often already so I don't want to add more to that but I will just give some examples. Define two functions which solve the OP's problem in terms of Root objects and Radicals as follows: f[a_, b_, c_] = Eigenvalues[{{a, 1, 1}, {1, b, 1}, {1, 1, c}}]; g[a_, b_, c_] = ToRadicals[Eigenvalues[{{a, 1, 1}, {1, b, 1}, {1, 1, c}}]]; These are of course equivalent. First, let's compare the numerical performance of both functions. We will compute the values of f[1,2,3] and g[1,2,3] to 100 decimals places: N[f[1, 2, 3], 100] // Timing {0.004565, \ {0.324869129433353929110378201849939519191967472322627267387846130158557 957009\ 5006802577938999683472230, 1.4608111271891108834741240973014799919001128904578732982807715533323139 9655\ 7233044946234849689688425, 4.2143197433775351874154977008485804889079196372194994343313823165091280 4643\ 3266274795971250341964352}} Timing[N[g[1, 2, 3], 100]] {0.026791999999999705, {4.2143197433775351874154977008\ 485804889079196372194994343313823165091280464332662747\ 959712503419643519340032200894195`100.15051499783199 + 0``99.52578751508469*I, 0.324869129433353929110378\ 201849939519191967472322627267387846130158557957009500\ 6802577938999683472230423386742795525`100.150514997831\ 99 + 0``100.6388065531959*I, 1.46081112718911088347412\ 409730147999190011289045787329828077155333231399655723\ 30449462348496896884250236581056310278`100.15051499783\ 199 + 0``99.98592092955138*I}} First, note the difference in timing, on my slow PowerBook the first calculation is almost 6 times faster than the second. Note also the small imaginary parts present in the second answer (they can be got rid of using Chop) and also, observe that the order in which the roots appear is not the same. Now let's compare symbolic performance. What I will do is square both all the roots, FullSimplify and express the answer in radicals. The Root object case is easy: Timing[ToRadicals[FullSimplify[f[1, 2, 3]^2]]] {1.825155, {20/3 - (70*2^(2/3)*(1 + I*Sqrt[3]))/ (3*(2227 + 69*I*Sqrt[111])^(1/3)) - ((1 - I*Sqrt[3])*(2227 + 69*I*Sqrt[111])^(1/3))/ (3*2^(2/3)), 20/3 - (70*2^(2/3)*(1 - I*Sqrt[3]))/ (3*(2227 + 69*I*Sqrt[111])^(1/3)) - ((1 + I*Sqrt[3])*(2227 + 69*I*Sqrt[111])^(1/3))/ (3*2^(2/3)), 20/3 + (140*2^(2/3))/ (3*(2227 + 69*I*Sqrt[111])^(1/3)) + (1/3)*(2*(2227 + 69*I*Sqrt[111]))^(1/3)}} In the second case we do not need to use ToRadicals but ... my computer is too slow or my patience too easily exhausted for me to wait for the result of: FullSimplify[g[1, 2, 3]^2] // Timing Andrzej Kozlowski On 27 Jul 2007, at 11:04, DrMajorBob wrote: > The Root object will do anything for you that a form in terms of > radicals > can do... except LOOK like a radical form. That being said, you can > SOMETIMES get the radical form as follows: > > ToRadicals@Eigenvalues@{{a, 1, 1}, {1, b, 1}, {1, 1, c}} > > {1/3 (a + b + c) - (2^( > 1/3) (-9 - a^2 + a b - b^2 + a c + b c - c^2))/(3 (54 + 2 a^3 - > 3 a^2 b - 3 a b^2 + 2 b^3 - 3 a^2 c + 12 a b c - 3 b^2 c - > 3 a c^2 - 3 b c^2 + > 2 c^3 + \[Sqrt](4 (-9 - a^2 + a b - b^2 + a c + b c - > c^2)^3 + (54 + 2 a^3 - 3 a^2 b - 3 a b^2 + 2 b^3 - > 3 a^2 c + 12 a b c - 3 b^2 c - 3 a c^2 - 3 b c^2 + > 2 c^3)^2))^(1/3)) + (1/( > 3 2^(1/3)))((54 + 2 a^3 - 3 a^2 b - 3 a b^2 + 2 b^3 - 3 a^2 c + > 12 a b c - 3 b^2 c - 3 a c^2 - 3 b c^2 + > 2 c^3 + \[Sqrt](4 (-9 - a^2 + a b - b^2 + a c + b c - > c^2)^3 + (54 + 2 a^3 - 3 a^2 b - 3 a b^2 + 2 b^3 - > 3 a^2 c + 12 a b c - 3 b^2 c - 3 a c^2 - 3 b c^2 + > 2 c^3)^2))^(1/3)), > 1/3 (a + b + > c) + ((1 + \[ImaginaryI] Sqrt[3]) (-9 - a^2 + a b - b^2 + a c + > b c - c^2))/(3 2^( > 2/3) (54 + 2 a^3 - 3 a^2 b - 3 a b^2 + 2 b^3 - 3 a^2 c + > 12 a b c - 3 b^2 c - 3 a c^2 - 3 b c^2 + > 2 c^3 + \[Sqrt](4 (-9 - a^2 + a b - b^2 + a c + b c - > c^2)^3 + (54 + 2 a^3 - 3 a^2 b - 3 a b^2 + 2 b^3 - > 3 a^2 c + 12 a b c - 3 b^2 c - 3 a c^2 - 3 b c^2 + > 2 c^3)^2))^(1/3)) - (1/( > 6 2^(1/3)))(1 - \[ImaginaryI] Sqrt[3]) (54 + 2 a^3 - 3 a^2 b - > 3 a b^2 + 2 b^3 - 3 a^2 c + 12 a b c - 3 b^2 c - 3 a c^2 - > 3 b c^2 + > 2 c^3 + \[Sqrt](4 (-9 - a^2 + a b - b^2 + a c + b c - > c^2)^3 + (54 + 2 a^3 - 3 a^2 b - 3 a b^2 + 2 b^3 - > 3 a^2 c + 12 a b c - 3 b^2 c - 3 a c^2 - 3 b c^2 + > 2 c^3)^2))^(1/3), > 1/3 (a + b + > c) + ((1 - \[ImaginaryI] Sqrt[3]) (-9 - a^2 + a b - b^2 + a c + > b c - c^2))/(3 2^( > 2/3) (54 + 2 a^3 - 3 a^2 b - 3 a b^2 + 2 b^3 - 3 a^2 c + > 12 a b c - 3 b^2 c - 3 a c^2 - 3 b c^2 + > 2 c^3 + \[Sqrt](4 (-9 - a^2 + a b - b^2 + a c + b c - > c^2)^3 + (54 + 2 a^3 - 3 a^2 b - 3 a b^2 + 2 b^3 - > 3 a^2 c + 12 a b c - 3 b^2 c - 3 a c^2 - 3 b c^2 + > 2 c^3)^2))^(1/3)) - (1/( > 6 2^(1/3)))(1 + \[ImaginaryI] Sqrt[3]) (54 + 2 a^3 - 3 a^2 b - > 3 a b^2 + 2 b^3 - 3 a^2 c + 12 a b c - 3 b^2 c - 3 a c^2 - > 3 b c^2 + > 2 c^3 + \[Sqrt](4 (-9 - a^2 + a b - b^2 + a c + b c - > c^2)^3 + (54 + 2 a^3 - 3 a^2 b - 3 a b^2 + 2 b^3 - > 3 a^2 c + 12 a b c - 3 b^2 c - 3 a c^2 - 3 b c^2 + > 2 c^3)^2))^(1/3)} > > Bobby > > On Thu, 26 Jul 2007 04:28:38 -0500, jeremito <jeremit0 at gmail.com> > wrote: > >> I am trying to find the eigenvalues of a 3x3 matrix with non-numeric >> elements. This requires finding the roots of cubic polynomials. >> Mathematica can do this, but I know how to interpret its output. For >> example >> >> In[1]:= B = {{a, 1, 1}, {1, b, 1}, {1, 1, c}} >> >> Out[1]= {{a, 1, 1}, {1, b, 1}, {1, 1, c}} >> >> In[2]:= Eigenvalues[B] >> >> Out[2]= {Root[-2 + a + b + c - >> a b c + (-3 + a b + a c + b c) #1 + (-a - b - c) #1^2 + #1^3 &, >> 1], Root[-2 + a + b + c - >> a b c + (-3 + a b + a c + b c) #1 + (-a - b - c) #1^2 + #1^3 &, >> 2], Root[-2 + a + b + c - >> a b c + (-3 + a b + a c + b c) #1 + (-a - b - c) #1^2 + #1^3 &, >> 3]} >> >> >> How can I get Mathematica to give me the full answer? I know it is >> long and ugly, but at least I can do something with it. I can't do >> anything with what it gives me now. Does that make sense? >> Thanks, >> Jeremy >> >> >> > > > > -- > > DrMajorBob at bigfoot.com >
- References:
- Re: Help with Root function
- From: DrMajorBob <drmajorbob@bigfoot.com>
- Re: Help with Root function