I have the following equation:


Where $$f(x,y):=2 \cos(\sqrt{3}y)+4\cos(\frac{3}{2}x)\cos(\frac{\sqrt{3}}{2}y)$$

My goal is to solve the first equation, i.e. find the points (x,y) such that $f(x,y)=-3$.

I already know that there are infinite solutions periodically repeated. In particular the points in the xy plane that satisfy the equation are located on the vertices of a honeycomb structure (many hexagons repeated, like in graphene). For example the following points are possible solutions: $$(x,y)=(\frac{2\pi}{3},\frac{2\pi}{3 \sqrt{3}})$$ or

$$(x,y)=(\frac{2\pi}{3},-\frac{2\pi}{3 \sqrt{3}})$$

or also

$$(x,y)=(0,\frac{4\pi}{3 \sqrt{3}})$$

However when I try to obtain this in Mathematica by

Solve[f[x, y] + 3 == 0, {x, y}]

I get a very complicated expression, where y is expressed in terms of x. So how can I obtain with Mathematica the nice solutions I wrote above?


2 Answers 2

  • Reduce work.
f[x_, y_] = 2 Cos[Sqrt[3] y] + 4 Cos[3/2 x] Cos[Sqrt[3]/2 y];
Reduce[f[x, y] == -3, {x, y}, Reals]
Solve[f[x, y] + 3 == 0, {x, y}, Reals, Method -> Reduce]
Reduce[{f[x, y] + 3 == 0, -5 <= x <= 5, -5 <= y <= 5}, {x, y}, Reals]

enter image description here

  • We can also find some solutions by FindInstance.
f[x_, y_] = 2 Cos[Sqrt[3] y] + 4 Cos[3/2 x] Cos[Sqrt[3]/2 y];
FindInstance[f[x, y] + 3 == 0, {x, y}, Reals, 5]
f[x_, y_] = 2 Cos[Sqrt[3] y] + 4 Cos[3/2 x] Cos[Sqrt[3]/2 y];
pts = {x, y} /. 
  FindInstance[{f[x, y] + 3 == 0, -5 <= x <= 5, -5 <= y <= 5}, {x,
     y}, Reals, 10]

enter image description here

We can view the solution: the points is the intersection points of z=f[x,y] and z=-3,in fact, the tangent point of the z=f[x,y] and z=-3.

Show[Plot3D[{f[x, y], -3}, {x, -5, 5}, {y, -5, 5}, Mesh -> None, 
  Boxed -> False, PlotStyle -> {Opacity[.2]}, Axes -> False], 
 Graphics3D[{Red, AbsolutePointSize[10], 
   Point[PadRight[#, 3, -3] & /@ pts]}]]

enter image description here

  • $\begingroup$ Thanks this is great! I was wondering, how does the procedure change if now the f function contains also other parameters, and I want to find the (x,y) solutions as a function of those parameters as well? Because if I try the same way I either get an error, or Mathematica gives a solution for the parameters as well (so it treats them as new variables). $\endgroup$
    – Mathew
    Aug 25, 2022 at 14:09

f[x_, y_] = 2 Cos[Sqrt[3] y] + 4 Cos[3/2 x] Cos[Sqrt[3]/2 y];

The function is periodic in both x and y

fp = FunctionPeriod[f[x, y], {x, y}]

(* {(4 π)/3, (4 π)/Sqrt[3]} *)

Restrict the range of interest by adding constraints, and Solve is more capable when given the option Method -> Reduce.

sol = Solve[{f[x, y] + 3 == 0, -fp[[1]]/2 <= x <= fp[[1]]/2, 
  -fp[[2]]/2 <= y <= fp[[2]]/2}, {x, y}, Method -> Reduce]

enter image description here

 Plot3D[f[x, y] + 3,
  {x, -fp[[1]]/2, fp[[1]]/2}, {y, -fp[[2]]/2, fp[[2]]/2},
  PlotStyle -> Opacity[0.67]],
 Graphics3D[{Red, AbsolutePointSize[6], Point[{x, y, 0} /. sol]}]]

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.