SetDirectory["/www/user/fdahl/papers/Conjugation/"];
<<kappaLib.m
<<Petrov.m

V=(({{ lam1, 1, 0, 0, 0, 0}, {0, lam1, 0, 0, 0, 0}, {0, 0, lam2, 1, 0, 0}, {0, 0, 0, lam2, 0, 0}, {0, 0, 0, 0,  lam3, 0}, {0, 0, 0, 0, 0,  lam4}}));

B=(({{0, 0, 0, 1, 0, 0}, {0, 0, 0, 0, 1, 0}, {0, 0, 0, 0, 0, 1}, {1, 0, 0, 0, 0, 0}, {0, 1, 0, 0, 0, 0}, {0, 0, 1, 0, 0, 0}}));
W=(({{0, eps1, 0, 0, 0, 0}, {eps1, 0, 0, 0, 0, 0}, {0, 0, 0, eps2, 0, 0}, {0, 0, eps2, 0, 0, 0}, {0, 0, 0, 0, eps3, 0}, {0, 0, 0, 0, 0, eps4}}))/.{eps3->-1, eps4->1};

Solve S starting from expression in SWW

(* First find matrix that gives matrix in the SWW paper *)
Petrov[(({{lam1, 0, 0, 0, 0, 0}, {0, lam2, 0, 0, eps2, 0}, {0, 0, (1/2) (-lam3+lam4), 0, 0, ((lam3+lam4)/2)}, {eps1, 0, 0, lam1, 0, 0}, {0, 0, 0, 0, lam2, 0}, {0, 0, ((lam3+lam4)/2), 0, 0, (1/2) (-lam3+lam4)}}))]

S=Table[ToExpression["s"<>ToString[i]<>ToString[j]],{i,1,6},{j,1,6}];j1=Flatten[Transpose[S].B.S-W];
j2=Flatten[(({{xx1, 0, 0, 0, 0, 0}, {0, xx2, 0, 0, eps2, 0}, {0, 0, xx3, 0, 0, xx4}, {eps1, 0, 0, xx1, 0, 0}, {0, 0, 0, 0, xx2, 0}, {0, 0, xx4, 0, 0, xx3}})).S-S.V];
exp=Union[Join[j2,j1]]/.{eps1->1,eps2->1};

Simplify[exp]//MatrixForm

sub={s11->0,s13->0,s15->0,s16->0,s51->0,s53->0,s55->0,s56->0,s12->s41,s14->s43,s52->s21,s54->s23,s61->0,s63->0,s31->0,s33->0,(* revert here *)s21->1,s41->0 ,xx2->lam1,s23->0,s43->1,xx1->lam2,s24->0,s25->0,s26->0,s45->0,s46->0,s42->0, (* rev *) s22->0, (* compute Groebner basis below *) xx3-> (lam3+lam4)/2,s32->0,s34->0,s62->0,s64->0,s44->0,s66->1/Sqrt[2],s36->1/Sqrt[2],s35->-s65,s65->1/Sqrt[2],xx4->(lam4-lam3)/2};
Simplify[Sort[Union[exp//.sub],emSize[#1]≤ emSize[#2]&]]//MatrixForm
S//.sub //MatrixForm

(* see above *)GroebnerBasis[Simplify[Sort[Union[exp//.sub],emSize[#1]≤ emSize[#2]&]],Variables[S]]

Put in eps_i

Sx=(({{0, 0, 0, a1, 0, 0}, {a2, 0, 0, 0, 0, 0}, {0, 0, 0, 0, -(a7/(Sqrt[2])), (a8/(Sqrt[2]))}, {0, 0, a3, 0, 0, 0}, {0, a4, 0, 0, 0, 0}, {0, 0, 0, 0, (a5/(Sqrt[2])), (a6/(Sqrt[2]))}}))/.{a5->1,a6->1,a7->1,a8->1,a1->1,a2->1,a3->eps2,a4->eps1};
Union[Flatten[Transpose[Sx].B.Sx-W]]

Sx//MatrixForm

(* export .pdf *)
NotebookPrint[SelectedNotebook[],"/www/user/fdahl/papers/Conjugation/notebooks/ClassXV_Solve.pdf"]