m[ks_,μx_,μy_]:=(({{1, 0, 0, 0}, {0, 1, ks, 0}, {0, 0, 1, 0}, {ks, 0, 0, 1}})).(({{Cos[μx], βx Sin[μx], 0, 0}, {-(1/(βx)) Sin[μx], Cos[μx], 0, 0}, {0, 0, Cos[μy], βy Sin[μy]}, {0, 0, -(1/(βy))Sin[μy], Cos[μy]}}))
m0=m[0.03,0.45,0.35];

m0=m[ks,μx,μy];

m0//MatrixForm

Take[m0,2,2]//MatrixForm
Drop[m0,2,2]//MatrixForm
mS=Drop[Take[m0,2],0,2];mS//MatrixForm
nS=Take[Drop[m0,2],2,2];nS//MatrixForm
nSc=cross[nS];nSc//MatrixForm
hS=mS+nSc;hS//MatrixForm
Det[hS]

J=(({{0, 1, 0, 0}, {-1, 0, 0, 0}, {0, 0, 0, 1}, {0, 0, -1, 0}}));Simplify[m0.J.Transpose[m0]]//MatrixForm

cross[nS_]:={{nS[[2,2]],-nS[[1,2]]},{-nS[[2,1]],nS[[1,1]]}};

γ[m0_]:=Module[{mL,nL,mS,nS,nSc,hS,γS},mL=Take[m0,2,2];
nL=Drop[m0,2,2];
mS=Drop[Take[m0,2],0,2];
nS=Take[Drop[m0,2],2,2];nSc=cross[nS];hS=mS+nSc;(Sqrt[(1/2)+(1/2)(Sqrt[(((Tr[mL-nL])^2)/(((Tr[mL-nL])^2)+4Det[hS]))])])]

c[m0_]:=Module[{mL,nL,mS,nS,nSc,hS,γS},mL=Take[m0,2,2];
nL=Drop[m0,2,2];
mS=Drop[Take[m0,2],0,2];
nS=Take[Drop[m0,2],2,2];nSc=cross[nS];hS=mS+nSc;γS=γ[m0];-hS ((Tr[mL-nL])/(γS(Sqrt[((Tr[mL-nL])^2)(((Tr[mL-nL])^2)+4Det[hS])])))]

A[m0_]:=Module[{mL,nL,mS,nS,nSc,hS,γS,cL,cLc},mL=Take[m0,2,2];
nL=Drop[m0,2,2];
mS=Drop[Take[m0,2],0,2];
nS=Take[Drop[m0,2],2,2];nSc=cross[nS];hS=mS+nSc;γS=γ[m0];cL=c[m0];cLc=cross[cL];
((γS)^2)mL-γS(cL.nS+mS.cLc)+cL.nL.cLc]

B[m0_]:=Module[{mL,nL,mS,nS,nSc,hS,γS,cL,cLc},mL=Take[m0,2,2];
nL=Drop[m0,2,2];
mS=Drop[Take[m0,2],0,2];
nS=Take[Drop[m0,2],2,2];nSc=cross[nS];hS=mS+nSc;γS=γ[m0];cL=c[m0];cLc=cross[cL];
((γS)^2)nL+γS(nS.cL+cLc.mS)+cLc.mL.cL]

γS=Normal[Series[γ[m0],{ks,0,2}]]

cL=Normal[Series[c[m0],{ks,0,2}]]

AL=Normal[Series[A[m0],{ks,0,2}]]

BL=Normal[Series[B[m0],{ks,0,2}]]

Δμx = (1/(Sin[μx]))(Cos[μx]-Simplify[(1/2)Tr[AL]/.{(Sqrt[(((Cos[μx]-Cos[μy]))^4)])->(((Cos[μx]-Cos[μy]))^2),1/(Sqrt[(((Cos[μx]-Cos[μy]))^4)])->1/(((Cos[μx]-Cos[μy]))^2)}])//Simplify

Simplify[Tr[BL]]/.{(Sqrt[(((Cos[μx]-Cos[μy]))^4)])->(((Cos[μx]-Cos[μy]))^2),1/(Sqrt[(((Cos[μx]-Cos[μy]))^4)])->1/(((Cos[μx]-Cos[μy]))^2)}//Simplify

Δμy= (1/(Sin[μy]))(Cos[μy]-Simplify[(1/2)Tr[BL]/.{(Sqrt[(((Cos[μx]-Cos[μy]))^4)])->(((Cos[μx]-Cos[μy]))^2),1/(Sqrt[(((Cos[μx]-Cos[μy]))^4)])->1/(((Cos[μx]-Cos[μy]))^2)}])//Simplify

uL=(({{AL[[1,1]], AL[[1,2]], 0, 0}, {AL[[2,1]], AL[[2,2]], 0, 0}, {0, 0, BL[[1,1]], BL[[1,2]]}, {0, 0, BL[[2,1]], BL[[2,2]]}}))//Simplify
vL=(({{γS, 0, cL[[1,1]], cL[[1,2]]}, {0, γS, cL[[2,1]], cL[[2,2]]}, {-cL[[2,2]], cL[[1,2]], γS, 0}, {cL[[2,1]], -cL[[1,1]], 0, γS}}))//Simplify

m0//MatrixForm

Simplify[Simplify[Normal[Series[vL.uL.Inverse[vL],{ks,0,2}]]]/.{(Sqrt[(((Cos[μx]-Cos[μy]))^4)])->(((Cos[μx]-Cos[μy]))^2),1/(Sqrt[(((Cos[μx]-Cos[μy]))^4)])->1/(((Cos[μx]-Cos[μy]))^2)}]//MatrixForm

m0-vL.uL.Inverse[vL]//MatrixForm

Plot[{Tr[A[m[0.03,μx,0.35]]],Tr[B[m[0.03,μx,0.35]]]},{μx,0.3,0.4}]

Plot[Tr[A[m[ks,μx,0.35]]]/.{μx->0.345},{ks,0.,0.03},Frame->True]