# Solving equations bounded by a region

Straight to the point

I have a function

DiracPoint[{theta_, phi_}] :=

Module[{c1, c2, c3, x, y, cond1, cond2, cond3, cond4},
(*Define c_j*)
{c1, c2, c3} = 1 - 3 Sin[theta]^2 Cos[phi - 2 Pi (# - 1)/3]^2 & /@ {1,2,3};
(*excludes points with no solution*)
If[0 <= ((c2 + c3)^2 - c1^2)/(4 c2 c3) <= 1,
cond1 = (c2 + c3) Cos[Sqrt x/2] == -c1 Cos[3 y/2];(*Re[f]=0*)
cond2 = (c2 - c3) Sin[Sqrt x/2] == c1 Sin[3 y/2];(*Im[f]=0*)
cond3 = Abs[y] <= 2 Pi/3;(*Bound x within hexagon*)
cond4 = Abs[x] <= (4 Pi/3 - Abs[y])/Sqrt;(*Bound y within hexagon*)
{x, y}/.Solve[cond1 && cond2 && cond3 && cond4, {x, y}]
, Null]
]


which needs modifying to run successfully and quickly for all angles in the range 0<=theta<=Pi and 0<=phi<=2Pi. Non-exact and numerical solutions are absolutely fine. At the minute this function only works for a few values of exact input. Otherwise Solve fails to work, or it takes forever to run. Any suggestions? The function should (I believe) return two sets of coordinates {{x1,y1},{x2,y2}}, or Null, or for a few special angles more than 2 sets of coordinates.

Extra details if needed

I'm trying to develop a Mathematica function which finds the $(x,y)$ solutions to the equation $f=0$ in a region of space bounded by a hexagon centered at the origin, with side length $4\pi/3\sqrt{3}$ as shown below. The function is

$f=\mathcal{C}_1 \exp(-iy)+\mathcal{C}_2 \exp(-\sqrt{3}ix/2) + \mathcal{C}_3 \exp(-\sqrt{3}ix/2)$

where $\mathcal{C}_j = 1-3\sin^2\theta\cos^2(\phi-2\pi(j-1)/3)$ and the bounding region of space is As $f=0$ implies we also need $Re[f]=0$ and $Im[f]=0$, satisfying $f=0$ is equivalent to satisfying the two equations:

$(\mathcal{C}_2 + \mathcal{C}_3)\cos(\sqrt{3}x/2)=-\mathcal{C}_1\cos(3y/2)$

$(\mathcal{C}_2 - \mathcal{C}_3)\sin(\sqrt{3}x/2)=\mathcal{C}_1\cos(3y/2)$

So I desire a function DiracPoint[{theta_,phi_}] which (quickly) returns the set of coordinates {x,y} that satisfy the above requirements. I have tried various approaches, but I keep running into problems of wrong or incomplete solutions, or exact methods taking forever to compute. Successful development of this function will aid with research that develops on this paper here (should be publicly available). It's possible to find analytical solution for a given $(\theta,\phi)$ but a numerical solution will help greatly with visualisation.

Many thanks for any and all help.

• cc = {c1, c2, c3} = 1 - 3 Sin[theta]^2 Cos[phi - 2 Pi (# - 1)/3]^2 & /@ {1, 2, 3}; v = {E^(-I y), E^(-Sqrt@3/2 I x), E^(-Sqrt@3/2 I x)}; f = cc.v; llr = Re[TrigExpand@f // ExpToTrig] /. __ + Re[x_] :> x; lli = Im[TrigExpand@f // ExpToTrig] /. Im[__] + x_ :> x /. Re -> Identity; Reduce[{lli == 0 && llr == 0}, {x, y}] Apr 14, 2015 at 17:01
• Thanks for the contribution. Although I copied and pasted this into Mathematica 10 and it delivered the result 'False' so doesn't quite seem to be working for me.
– Tom
Apr 14, 2015 at 18:16
• Have you tried starting a fresh Mma session? Apr 14, 2015 at 19:13
• Yes, it finds some kind of solution when theta and phi are undefined, but choosing a value for these parameters Reduce gives False. The code provided also doesn't take into account the requirement that solutions are bounded by the hexagon, but one task at a time I guess :)
– Tom
Apr 14, 2015 at 21:47

One approach is to Solve using cond1 and cond2 only, then keep only those answers that satisfy cond3 and cond4. For instance,

DiracPoint[{theta_, phi_}] := Module[{c1, c2, c3, x, y, cond1, cond2},
{c1, c2, c3} = 1 - 3 Sin[theta]^2 Cos[phi - 2 Pi (# - 1)/3]^2 & /@ {1, 2, 3};
Cases[If[0 <= ((c2 + c3)^2 - c1^2)/(4 c2 c3) <= 1,
cond1 = (c2 + c3) Cos[Sqrt x/2] == -c1 Cos[3 y/2];
cond2 = (c2 - c3) Sin[Sqrt x/2] == c1 Sin[3 y/2];
{x, y} /. Solve[cond1 && cond2 , {x, y}], Null], {z1_, z2_} /;
Abs[z2] <= 2 Pi/3 && Abs[z1] <= (4 Pi/3 - Abs[z2])/Sqrt, Infinity]]


Sample results are

DiracPoint[{.1, .8}]
(* {{-1.20893, -2.07923}, {1.20893, 2.07923}} *)

DiracPoint[{1, 1}]
(* {} *)

• Thank you very much! This appears to be working a treat. Will report back after more tinkling.
– Tom
Apr 15, 2015 at 22:48