<<"VariationalMethods`"

fo=(1/2)(r ((η[x])^2)+c ((η'[x])^2)+d ((η''[x])^2))+u ((η[x])^4);
fe=(1/2)(λx ((ϵx[x])^2)+λa1 ((ϵa1[x])^2)+λa2 ((ϵa2[x])^2));
fi=(1/2)(b ϵx[x] η[x]+e1 ((ϵa1[x])^2)η[x]+e2 ((ϵa2[x])^2)η[x]+h1 ϵa1[x]ϵx[x] η[x]+h2 ϵa2[x]ϵx[x] η[x]);
f=fo+fe+fi/.{λa2->0,e2->0,h2->0};

sϵ=Solve[{VariationalD[f,ϵx[x],x]==0,VariationalD[f,ϵa1[x],x]==0,VariationalD[f,ϵa2[x],x]==0},{ϵx[x],ϵa1[x],ϵa2[x]}];

sϵ/.e1->0

fηeff=Expand[f/.sϵ[[1]]];

χ=D[VariationalD[f/.sϵ[[1]],η[x],x]/.{η[x]->η[x][η[xp]]},η[xp]]/.{η[x_][η[xp_]]:>η[x],η[x_]'[η[xp_]]:>DiracDelta[x-xp],Derivative[i_][η][x]:>Derivative[i][DiracDelta][x-xp]};

FourierTransform[χ,x,q]

1/(λ-b/2/(b/(2 λ)+2/b /χt))//Simplify

Fu=(V/2)(r (η^2)+2 u (η^4));
Fm=(V/2)((1/2)(r+c (q^2)+d (q^4))(η^2)+(3/4)u (η^4));

Fm/.{q->(Sqrt[-c/(2d)])}

eq=FullSimplify[(Fm/.{q->Sqrt[-c/(2d)],η->Sqrt[(c^2-4 d r)/(12 d u)]})/(Fu/.η->Sqrt[(c^2-4 d r)/(16 d u)])//Expand,Assumptions->{r<0,c<0,d>0,u>0}]

-T D[Fm/.η->Sqrt[(c^2-4 d r)/(12 d u)]/.r->a(T-Tc),{T,2}]

ss=Solve[eq==1,c];

ss

FullSimplify[c/.ss[[1]],Assumptions->{r<0,c<0,d>0,u>0}]

sp=FiniteGroupData[{"CrystallographicPointGroup", 15},"SpaceRepresentation"]

(sp.{δx,δy,δz})[[All,3]]

pp1=Plot[{Piecewise[{{I,c≥0},{c^2/4,c<0}}],Piecewise[{{0,c≥0},{I,c<0}}],Piecewise[{{ι,c≥0},{-5c^2/4,c<0}}]},{c,-1.2,1.2},PlotRange->{{-1.1,1.1},{-0.3,0.3}},Frame->True,PlotStyle->{ColorData[97][2],ColorData[97][1],{ColorData[97][1],Dashed}},PlotRange->{-0.3,0.3},FrameLabel->{"(Subscript[c, ⊥])","(OverTilde[r]) (Subscript[D, ⊥])"},FrameTicks->{{False,False},{False,False}},FrameTicks->False,ImageSize->150,Epilog->{Inset["Unordered",{0.5,0.16}],Inset["Uniform",{0.5,-0.16}],Inset["Modulated",{-0.67,-0.06}],Inset["(b)",{-0.9,-0.25}]},LabelStyle->Black,Filling->{1->{3},2->Bottom,3->Bottom}]

pp2=Plot[{Piecewise[{{I,c≥0},{c^2/4,c<0}}],Piecewise[{{0,c≥0},{I,c<0}}]},{c,-1.2,1.2},PlotRange->{{-1.1,1.1},{-0.3,0.3}},Frame->True,PlotStyle->{ColorData[97][2],ColorData[97][1]},Filling->Bottom,PlotRange->{-0.3,0.3},FrameLabel->{"(Subscript[c, ⊥])",Style["(OverTilde[r]) (Subscript[D, ⊥])",Opacity[0]]},FrameTicks->{{False,False},{False,False}},Epilog->{{Thickness[0.012],ColorData[97][1],Line[{{0,0},{0,-2}}]},{Inset["Unordered",{0.5,0.16}],Inset["Uniform",{0.5,-0.16}],Inset["Modulated",{-0.55,-0.14}],Inset["(c)",{-0.9,-0.25}]}},ImageSize->150,LabelStyle->{Black}]

Export["~/doc/research/hidden_order/doc/overleaf/phases_scalar.pdf",pp1];

Export["~/doc/research/hidden_order/doc/overleaf/phases_vector.pdf",pp2];

Indexed[x,2]

(λ/(1+c/λ/(1+d Δt)))

(((((b^2/(4λ^2))/(d qs^4+a Δt))+1/λ))^(-1))/λ//FullSimplify

Integrate[ η Cos[qs x],{x,-L,L}