a bug in Solve

*To*: mathgroup at smc.vnet.net*Subject*: [mg30892] a bug in Solve*From*: Andrzej Kozlowski <andrzej at tuins.ac.jp>*Date*: Sun, 23 Sep 2001 02:16:32 -0400 (EDT)*Sender*: owner-wri-mathgroup at wolfram.com

It seems to me that I have come across a rather devious bug in Solve which causes it to fail to solve systems of trigonometric equations which in fact it ought to be (or "is") able to solve. Here is an example: Consider the system of equations: eqs = {Cos[x] == -Sqrt[(2/85)*(19 + Sqrt[21])], Sin[x] == (1/4)*(-Sqrt[(2/85)*(19 + Sqrt[21])] + Sqrt[(42/85)*(19 + Sqrt[21])]), Cos[y] == (1/21)*(7 + 3*Sqrt[21]), Sin[y] == (1/84)*(77*Sqrt[(2/85)*(19 + Sqrt[21])] - 13*Sqrt[(42/85)*(19 + Sqrt[21])]), Cos[z] == (1/4)*(Sqrt[(2/85)*(19 + Sqrt[21])] - Sqrt[(42/85)*(19 + Sqrt[21])]), Sin[z] == -Sqrt[(2/85)*(19 + Sqrt[21])]} Trying to solve this directly leads to a misleading answer: In[37]:= Solve[eqs, {x, y, z}] From In[37]:= Solve::ifun:Inverse functions are being used by Solve, so some solutions may \ not be found. Out[37]= {} However, if we break up the system into three systems of equations in a single variable Mathematica solves them correctly: eqs1 = Partition[eqs, 2]; In[39]:= MapThread[Solve, {eqs1, {x, y, z}}] From In[39]:= Solve::ifun:Inverse functions are being used by Solve, so some solutions may \ not be found. From In[39]:= Solve::ifun:Inverse functions are being used by Solve, so some solutions may \ not be found. From In[39]:= Solve::ifun:Inverse functions are being used by Solve, so some solutions may \ not be found. From In[39]:= General::stop:Further output of Solve::ifun will be suppressed during this \ calculation. Out[39]= {{{x -> ArcCos[-Sqrt[(2/85)*(19 + Sqrt[21])]]}}, {{y -> ArcCos[(1/21)*(7 + 3*Sqrt[21])]}}, {{z -> -ArcCos[(1/340)*(Sqrt[170*(19 + Sqrt[21])] - Sqrt[3570*(19 + Sqrt[21])])]}}} Finally, let me explain how I came across this. Consider the matrix: In[40]:= Z = {{1/3 + Sqrt[3/7], -(1/3) + 2/Sqrt[21], -(1/3) + 1/Sqrt[21]}, {-(1/3) + 1/Sqrt[21], 1/3 + Sqrt[3/7], 1/3 - 2/Sqrt[21]}, {-(1/3) + 2/Sqrt[21], 1/3 - 1/Sqrt[21], 1/3 + Sqrt[3/7]}}; It is easy to check that it belongs to SO(3) In[41]:= Z.Transpose[Z]//Simplify Out[41]= {{1,0,0},{0,1,0},{0,0,1}} In[42]:= Det[Z] Out[42]= 1 Now load the Geometry`Rotations` package: << Geometry`Rotations` Since Z is in SO(3) we should be able to find the Euler angles of Z but using Solve produces: In[44]:= Solve[Thread[Flatten[RotationMatrix3D[a,b,c]]==Flatten[Z]],{a,b,c}] From In[44]:= Solve::ifun: Inverse functions are being used by Solve, so some solutions may \ not be found. Out[44]= {} However, In[45]:= Reduce[Thread[Flatten[RotationMatrix3D[a,b,c]]==Flatten[Z]],{Cos[a], Cos[b],Cos[c]}] Out[45]= Cos[a] == -Sqrt[(2/85)*(19 + Sqrt[21])] && Cos[b] == (1/21)*(7 + 3*Sqrt[21]) && Cos[c] == (1/4)*(Sqrt[(2/85)*(19 + Sqrt[21])] - Sqrt[(42/85)*(19 + Sqrt[21])]) && Sin[a] == (1/4)*(-Sqrt[(2/85)*(19 + Sqrt[21])] + Sqrt[(42/85)*(19 + Sqrt[21])]) && Sin[b] == (1/84)*(77*Sqrt[(2/85)*(19 + Sqrt[21])] - 13*Sqrt[(42/85)*(19 + Sqrt[21])]) && Sin[c] == -Sqrt[(2/85)*(19 + Sqrt[21])] || Cos[a] == Sqrt[(2/85)*(19 + Sqrt[21])] && Cos[b] == (1/21)*(7 + 3*Sqrt[21]) && Cos[c] == (1/4)*(-Sqrt[(2/85)*(19 + Sqrt[21])] + Sqrt[(42/85)*(19 + Sqrt[21])]) && Sin[a] == (1/4)*(Sqrt[(2/85)*(19 + Sqrt[21])] - Sqrt[(42/85)*(19 + Sqrt[21])]) && Sin[b] == (1/84)*(-77*Sqrt[(2/85)*(19 + Sqrt[21])] + 13*Sqrt[(42/85)*(19 + Sqrt[21])]) && Sin[c] == Sqrt[(2/85)*(19 + Sqrt[21])] This seems to suggest that the reason why Mathematica can't make the final step and return a solution for a,b and c is probably related to the problem I begun with. Andrzej Kozlowski Toyama International University JAPAN http://platon.c.u-tokyo.ac.jp/andrzej/