# Function with same symmetry as planar hexagonal lattice

I'm currently trying to define a function which has the same symmetry as a planar hexagonal lattice. For a quadratic lattice the solution $$f(x,y) = \cos(x) + \cos(y)$$ is quite simple but I wasn't able to modify it to really fulfill the desired properties.

My current "best" solution is $$f(x,y) = \cos(x-\frac{1}{\sqrt{3}}y) + \cos(x+\frac{1}{\sqrt{3}}y)$$. As can be seen in the attached image, this results in function maxima at every lattice point but the function does not have the desired rotation and reflection properties. Does someone know the solution to this problem or if this is even possible? Right now I have the feeling that the approach of combining two cosine functions does not work as the directions necessary are not orthogonal and the function maxima therefore not circular.

PS: The example in the image uses a Radius of $$2\pi$$

My best solution so far

• Just a comment that if you have a function $f(x.y)$, and you want a similar function that is also invariant under some reflection $\sigma : \mathbb R^2 \rightarrow \mathbb R^2$, then $(f(x,y) + f(\sigma(x,y))/2$ will have that invariance, as $\sigma^2 = id$. This easily generalizes to any finite group of symmetries, and might help you get the rotation and reflection properties you want. Commented Apr 13, 2023 at 16:03

A correct answer needs an extra term. Define the function $$\,f:\mathbb{C}\to\mathbb{R}\,$$ by $$f(z) := g(z) + g(\omega\,z) + g(\omega^2\,z)$$ where $$\,z = x + i\,y\,$$ is a complex number, $$\,\omega = (-1+i\sqrt{3})/2\,$$ is a third root of unity and $$\, g(x + i\,y) := h(x)\,$$ where $$\,h(x)\,$$ is an even periodic function of $$\,x.\,$$ For example, cosine. Then I think the function $$\,f(z)\,$$ has the hexagonal lattice symmetry properties that you want.

For a square lattice your symmetric function $$\, f(z) := g(z) + g(i\,z) \,$$ needs only two terms.

Note that the use of complex numbers is only a minor convenience. For real functions, use the following instead: $$f(x,y) := h(x) + h((x+\sqrt{3}y)/2) + h((x-\sqrt{3}y)/2).$$

The following Wolfram Mathematica code plots both functions.

M = 10;
(* Hexagonal lattice *)
f[x_, y_] := h[x] + h[x/2 + Sqrt[3]/2*y] + h[x/2 - Sqrt[3]/2*y];
h[x_] := Cos[x];
ContourPlot[f[x, y], {x, -M, M}, {y, -M, M}]
(* Square lattice *)
f4[x_, y_] := h[x] + h[y];
ContourPlot[f4[x, y], {x, -M, M}, {y, -M, M}]

• Thanks for your answer! I was able to run your code in Mathematica and it seems to be what I'm looking for but since I've never used Mathematica I don't quite know how to translate this into the correct function f(x,y) I can plot with Matplotlib in Python. Is the result of your answer even a real function at the end or is it plotted on the complex plane in Mathematica? Commented Apr 14, 2023 at 8:35
• @MikaR. I have added real version $f(x,y)$ which you can use with Matplotlib. Commented Apr 14, 2023 at 11:23
• Thank you so much! Commented Apr 14, 2023 at 11:38
• As I've now inspected the solution I realized that my problem was basically that I've somehow managed to ignore the third direction with equal spacing and thus just missed the third term. Commented Apr 14, 2023 at 13:01

Check out the book by Frank Farris on Fourier series and wallpaper patterns. It has everything you need to know and beautiful pictures too. The basic mechanism is to average any lattice-periodic function over the finite group of additional symmetries you wish to obtain.

P.S. If you wish to avoid complex numbers, you can represent the symmetry operations on the lattice by unimodular 2x2 matrix operations on a pair of lattice generators, eg. $$(e_1, e_2)\to (e_2, -e_1+e_2)$$ has order 6 and models a rotation through 1/6 of a full revolution. Iterating that operation gives you 6 distinct results. You could apply that directly to $$f(x,y)=\cos x +\cos y$$ for example by

substituting $$(x,y)\to (y, -x+y)$$ into $$f(x,y)$$ and do all iterates as well. Iteration is the same as matrix multiplication.

Creating Symmetry: The Artful Mathematics of Wallpaper Patterns