For positive integers $D$, I have a function s[D_]
which creates a list of complex numbers, all of the form $a+b\sqrt{-D}$, where $a$ and $b$ are integers. These numbers have a lattice structure which, unless $D=1$, is not square.
I want to understand how s[D_]
is distributed for various $D$, so a 3D histogram is the best way to do this. But, the usual Histogram3D
is not very useful because of how the sampling works out with the distribution of the points.
What I'm trying to do: I want to make a 'hexagonal histogram' which:
For each integer pair $(a,b)$ with $|a|,|b|\leq N$, counts how many times $a+b\sqrt{-D}$ appears in
s[D_]
. (The input variables are $N$ and $D$.)Generates a 3D graph where, at each complex number $a+b\sqrt{-D}$, there is a vertical bar whose height corresponds to the number of times $a+b\sqrt{D}$ appears in
s[D_]
.
This is almost what the normal Histogram function does, but it checks for values in square subregions of the plane, which is not optimal when my set exists in a non-square lattice.
Optional (but would be very neat): Unfortunately, if rectangular bars are constructed at the lattice vertices, they usually won't fill the space in between them. However, if these bars are more generally look like extruded regular $k$-gons where $k$ depends on $D$, then the resulting histogram will tile the space completely. I can figure out that k[D_] := 2*Pi / Arg[Sqrt[-D]]
, but I have no idea how to make Mathematica change the form of the graph's bars.
ListPointPlot3D[ Append[#, Count[s[d], #[[1]] + #[[2]] Sqrt[-d]]] & /@ Tuples[Range[n], 2], Filling -> Bottom]
? $\endgroup$DiscretePlot3D[Count[s[d], a + b Sqrt[-d]], {a, 1, n}, {b, 1, n}, ExtentSize -> Full]
? $\endgroup$ResourceFunction["HextileBins"]
? $\endgroup$HextileBins
. $\endgroup$