I have the following problem:
I have the following function of 3 parameters A, B, mu: $$ g(A,B,\mu) = \int_{BZ} dk_1 dk_2\sqrt{(\mu+ F (\cos k_1 + \cos k_2 + \cos (k_1+k_2)))^2 - A^2 (\sin k_1 + \sin k_2 - \sin (k_1+k_2))^2} - 1.28 \mu + 3A^2 - 3 F^2 $$ where $BZ$ denotes the regular hexagon
H = Polygon[ 4 \[Pi]/
3 {{1, 0}, {1/2, Sqrt[3]/2}, {-1/2, Sqrt[3]/2}, {-1,
0}, {-1/2, -Sqrt[3]/2}, {1/2, -Sqrt[3]/2}}];
The expression under integral becomes purely imaginary for some choices of $A,F,\mu$. My aim is to find the local maximum of this function (where it has real values). I know, that it should be at the point $(A,F,\mu) = (0.181,-0.0528,0.4025)$. But using
FindMaximum
gives an error (becouse the procedure gets gomplex values of the function). Is it possible to tackle this problem?
My code is the following:
Ns = 100; J = 1 ; kappa = 0.28;
H = Polygon[
4 \[Pi]/
3 {{1, 0}, {1/2, Sqrt[3]/2}, {-1/2, Sqrt[3]/2}, {-1,
0}, {-1/2, -Sqrt[3]/2}, {1/2, -Sqrt[3]/2}}];
pts = RandomPoint[H, Ns^2];
ptsKspace = {#[[1]], -1/2 #[[1]] + (Sqrt[3]/2) #[[2]]} & /@ pts;
f[A_, F_, mu_, k1_, k2_] =
Sqrt[(mu + F (Cos[k1] + Cos[k2] + Cos[k1 + k2]))^2 -
A^2 (Sin[k1] + Sin[k2] - Sin[k1 + k2])^2];
En3 [A_, F_, mu_] := Module[{re, im},
re = Sqrt[3]/(8 \[Pi]^2) Integrate[
Re[f[A, F, mu, k1, -1/2 k1 + Sqrt[3]/2 k2] ], {k1,
k2} \[Element] H] - mu (1 + kappa) + 3 Abs[A]^2 -
3 Abs[F]^2;
im = Sqrt[3]/(8 \[Pi]^2) Integrate[
Im[f[A, F, mu, k1, -1/2 k1 + Sqrt[3]/2 k2] ], {k1,
k2} \[Element] H] ;
Return[re + I im];
];
FindMaximum[En3[x, y, z], {x, 0.181}, {y, -0.05}, {z, 0.45}]
And I ge an error. The firs lines with random points from hexagon are for possible Monte carlo calculation of integral.
FindMaximum
, i.e. post the code by editing the question. $\endgroup$Return[re + I im];
I will recommende + I im
, that is, noReturn
and no semicolon. See if that gets rid of theNull
problem. $\endgroup$