# FullSimplify issue in Mathematica 8.0.1

GROUPS:
 Input: FullSimplify[5916 + 5 Sqrt[606] >= Sqrt[6 (5835701 + 9860 Sqrt[606])]] Output: {} <= 5916 + 5 Sqrt[606] 
6 months ago
9 Replies
 Szabolcs Horvat 1 Vote It is generally a good idea to upgrade to the latest bugfix release of whichever version you have ... with Mathematica 8.0.4 I get True with the warning that N::meprec: "Internal precision limit \$MaxExtraPrecision = 50. reached while evaluating 5916+5\ Sqrt[606]-Sqrt[6\(5835701+9860\Sqrt[606])]." 5916 + 5 Sqrt[606] - Sqrt[6 (5835701 + 9860 Sqrt[606])] // FullSimplify gives 0.
6 months ago
 Jim Baldwin 1 Vote I get the correct answer (True) in both 9.0.1.0 and 10.0.0.0 (Windows 7) with the same warning as above.
6 months ago
 That's interesting. I restarted the kernel and now I also get the correct result. I will try to reproduce the error.
6 months ago
 Mario Weitzer 1 Vote I was able to reproduce the bug. Just restart your kernel and evaluate the following commands exactly as they are (will take a minute or two). The problem seems to be related to my usage of the protected symbol E as a local variable in a Block because if I replace all ocurrences of E in the definition of fSailIntersection with, say F, I get correct results. FullSimplify seems to have some sort of cache where it stores previous results and this gets corrupted by the evaluation of the code below. Still a serious bug imo. fOmega[d_] := If[MemberQ[{1, 2}, d], {0, Sqrt[d]}, {1/2, Sqrt[d]/2}]; fSailTestLessEqual[d_,S_,T_,{x_,y_}]:=Block[{},Off[N::meprec];Return[FullSimplify[(x((S[[1]]+S[[2]]fOmega[d][[1]])^2+(S[[2]]fOmega[d][[2]])^2)+(S[[1]]+S[[2]]fOmega[d][[1]])(T[[1]]+T[[2]]fOmega[d][[1]])+S[[2]]T[[2]]fOmega[d][[2]]^2)^2+(y((S[[1]]+S[[2]]fOmega[d][[1]])^2+(S[[2]]fOmega[d][[2]])^2)+(S[[1]]+S[[2]]fOmega[d][[1]])T[[2]]fOmega[d][[2]]-(T[[1]]+T[[2]]fOmega[d][[1]])S[[2]]fOmega[d][[2]])^2<=(S[[1]]+S[[2]]fOmega[d][[1]])^2+(S[[2]]fOmega[d][[2]])^2<=(x((S[[1]]+S[[2]]fOmega[d][[1]])^2+(S[[2]]fOmega[d][[2]])^2)+(S[[1]]+S[[2]]fOmega[d][[1]])(T[[1]]+T[[2]]fOmega[d][[1]]+1)+S[[2]]T[[2]]fOmega[d][[2]]^2)^2+(y((S[[1]]+S[[2]]fOmega[d][[1]])^2+(S[[2]]fOmega[d][[2]])^2)+(S[[1]]+S[[2]]fOmega[d][[1]])T[[2]]fOmega[d][[2]]-(T[[1]]+T[[2]]fOmega[d][[1]]+1)S[[2]]fOmega[d][[2]])^2&&-fOmega[d][[2]]/2<=S[[2]]fOmega[d][[2]]x+(S[[1]]+S[[2]]fOmega[d][[1]])y+T[[2]]fOmega[d][[2]]<=fOmega[d][[2]]/2]];On[N::meprec];]; fSailEdges[d_,S_,T_]:={(x-(-(S[[1]]+S[[2]]fOmega[d][[1]])(T[[1]]+T[[2]]fOmega[d][[1]])-S[[2]]T[[2]]fOmega[d][[2]]^2)/((S[[1]]+S[[2]]fOmega[d][[1]])^2+(S[[2]]fOmega[d][[2]])^2))^2+(y-(-(S[[1]]+S[[2]]fOmega[d][[1]])T[[2]]fOmega[d][[2]]+(T[[1]]+T[[2]]fOmega[d][[1]])S[[2]]fOmega[d][[2]])/((S[[1]]+S[[2]]fOmega[d][[1]])^2+(S[[2]]fOmega[d][[2]])^2))^2==1/((S[[1]]+S[[2]]fOmega[d][[1]])^2+(S[[2]]fOmega[d][[2]])^2),(x-(-(S[[1]]+S[[2]]fOmega[d][[1]])(T[[1]]+T[[2]]fOmega[d][[1]]+1)-S[[2]]T[[2]]fOmega[d][[2]]^2)/((S[[1]]+S[[2]]fOmega[d][[1]])^2+(S[[2]]fOmega[d][[2]])^2))^2+(y-(-(S[[1]]+S[[2]]fOmega[d][[1]])T[[2]]fOmega[d][[2]]+(T[[1]]+T[[2]]fOmega[d][[1]]+1)S[[2]]fOmega[d][[2]])/((S[[1]]+S[[2]]fOmega[d][[1]])^2+(S[[2]]fOmega[d][[2]])^2))^2==1/((S[[1]]+S[[2]]fOmega[d][[1]])^2+(S[[2]]fOmega[d][[2]])^2),-S[[2]]fOmega[d][[2]]x-(S[[1]]+S[[2]]fOmega[d][[1]])y-T[[2]]fOmega[d][[2]]==fOmega[d][[2]]/2,S[[2]]fOmega[d][[2]]x+(S[[1]]+S[[2]]fOmega[d][[1]])y+T[[2]]fOmega[d][[2]]==fOmega[d][[2]]/2}; fEqualities[d_,C_]:=Flatten[Table[Map[{{#[[1]],#[[1]]/.{Equal->Less}},{#[[2]],#[[2]]/.{Equal->GreaterEqual}},{#[[3]],#[[3]]/.{Equal->LessEqual}},{#[[4]],#[[4]]/.{Equal->Less}}}&,{fSailEdges[d,C[[i]],C[[Mod[i,Length[C]]+1]]]}][[1]],{i,1,Length[C]}],1]; fVerticesSelected[d_,C_]:=Block[{V,VT,VS,a,b},V=Select[fVertices[fEqualities[d,C]],Apply[And,Table[fSailTestLessEqual[d,C[[i]],C[[Mod[i,Length[C]]+1]],#[[1]]],{i,1,Length[C]}]]&];VT=DeleteDuplicates[Union[Map[#[[1]]&,V]],FullSimplify[#1==#2]&];VS=Table[{},{a,1,Length[VT]}];For[a=1,a<=Length[VT],{For[b=1,b<=Length[V],{If[FullSimplify[VT[[a]]==V[[b]][[1]]],VS[[a]]=Union[VS[[a]],V[[b]][[2;;3]]]],b++}],VS[[a]]=Sort[VS[[a]],MemberQ[{Less,Greater},Head[#1[[2]]]]&&MemberQ[{LessEqual,GreaterEqual},Head[#2[[2]]]]&],VS[[a]]=DeleteDuplicates[VS[[a]],FindInstance[Not[Implies[#1[[2]],#2[[2]]]],{x,y},Reals]==={}||FindInstance[Not[Implies[#2[[2]],#1[[2]]]],{x,y},Reals]==={}&],VS[[a]]={VT[[a]],VS[[a]]},a++}];Return[VS];]; fSailIntersection[d_,C_]:=Block[{a=0,V={},E={},P={},PF={},A={},S={},T=0,S2={},R={}},V=fVerticesSelected[d,C];E=Table[If[i!=j,Intersection[V[[i]][[2]],V[[j]][[2]]],{}],{i,1,Length[V]},{j,1,Length[V]}];If[Complement[Union[Flatten[Map[Length[#]&,E,{2}]]],{1,0}]==={},{P=Select[Position[Map[Length[#]==1&,E,{2}],True],#[[1]]<#[[2]]&];R=Table[{V[[P[[i]][[1]]]][[1]],V[[P[[i]][[2]]]][[1]],E[[P[[i]][[1]]]][[P[[i]][[2]]]][[1]][[2]]},{i,1,Length[P]}];}];Return[R];]; Z={{-5,0},{4,2},{-1,-3},{-2,3},{5,-1},{-4,-2},{1,3},{2,-3},{-4,1},{4,1},{-2,-3},{-1,3},{4,-2}}; ZI = fSailIntersection[2, Z] ZI = fSailIntersection[2, Z] fSailTestLessEqual[2,{-4,-2},{1,3},{5065/6232-(17 Sqrt[101/6])/1558,(12 Sqrt[2])/19-1/19 Sqrt[-206+570 (5065/6232-(17 Sqrt[101/6])/1558)-361 (5065/6232-(17 Sqrt[101/6])/1558)^2]}] FullSimplify[24<=(-20+24 (5065/6232-(17 Sqrt[101/6])/1558))^2+(-8 Sqrt[2]+24 ((12 Sqrt[2])/19-1/19 Sqrt[-206+570 (5065/6232-(17 Sqrt[101/6])/1558)-361 (5065/6232-(17 Sqrt[101/6])/1558)^2]))^2] Simplify[24<=(-20+24 (5065/6232-(17 Sqrt[101/6])/1558))^2+(-8 Sqrt[2]+24 ((12 Sqrt[2])/19-1/19 Sqrt[-206+570 (5065/6232-(17 Sqrt[101/6])/1558)-361 (5065/6232-(17 Sqrt[101/6])/1558)^2]))^2] FullSimplify[5916+5 Sqrt[606]>=Sqrt[6 (5835701+9860 Sqrt[606])]]  Attachments:
6 months ago
 Szabolcs Horvat 2 Votes It looks like you are running several symbolic processing functions, such as FullSimplify and FindInstance, within Block[{E = ...}, ...]. These functions could easily use E internally. They also cache partial symbolic results.So ultimately it is not surprising that doing this breaks the system.Just don't try to use builtins such as E or C as Block variables. Also, use Module unless you know you need Block.I would not call this a bug.
 Szabolcs Horvat 1 Vote Consider In[4]:= f[x_] := D[x a, a] In[5]:= f[b] Out[5]= b In[6]:= f[a] Out[6]= 2 a which is just one simple example of why Block doesn't localize the "usual way" (it uses dynamic scoping).Block does have its uses. If we were to implement something similar to Table and localize the iterator, Block would be the choice.Choose between Module and Block` depending on what they do, not performance. They are quite different.