1 Introduction

The problem of enumerating chambers of hyperplane arrangements is a challenge in computational discrete geometry [20, 29, 34, 42]. A well-known approach to this problem is through the computation of characteristic polynomials [1, 21, 30, 38, 43, 47]. We develop a novel for computing characteristic polynomials which takes advantage of the combinatorial symmetries of an arrangement. While most arrangements admit few combinatorial symmetries [39], most arrangements of interest do [19, 40, 48].

We implemented our algorithm in julia [3] and published it as the package CountingChambers.jl.Footnote 1 Our implementation relies heavily on the cornerstones of the new computer algebra system OSCAR [51] for group theory computations (GAP [50]) and the ability to work over number fields (Hecke and Nemo [17]).

While other algorithms and pieces of software exist for studying hyperplane arrangements (see, for instance, [10, 15, 29, 33, 44]), either their chamber-enumeration computations appear as byproducts of more difficult calculations, the code does not use symmetry, or it only pertains to very specific types of arrangements. For example, reference [29] computes the associated zonotope, whose vertices are in bijection with the chambers of the arrangement, containing much more information than the characteristic polynomial. A similar approach is suggested in [15] involving a search algorithm relying upon linear programming. An example of an approach which computes the number of chambers via a much more difficult computation is via the computation of the so-called broken circuit complex of the arrangement (see [7]): a simplicial complex which has the same number of faces as the number of chambers of the arrangement.

As demonstrated in Table 1, the fastest algorithms we know of for counting chambers in hyperplane arrangements (including the one discussed in this article) also compute the characteristic polynomial of the arrangement as a byproduct. In this sense, we do not know of an algorithm which illustrates that counting the chambers of an arrangement is an easier computation than computing its characteristic polynomial. To the best of our knowledge, our implementation is the first publicly available software for counting chambers which uses symmetry.

Table 1 Our timings on examples from Sect. 6

We showcase our algorithm and its implementation on a number of well-known examples, such as the resonance and discriminantal arrangements. Additionally, we study sequences of hyperplane arrangements which come from the problem of linearly separating vertices of regular polytopes. In particular, we investigate one corresponding to the hypercube \([0,1]^d\) whose chambers are in bijection with linearly separable Boolean functions.

In the presence of symmetry, our implementation outperforms the existing software by several orders of magnitude (cf. Table 1). Moreover, its output is guaranteed to be correct since we compute symbolically over the integers or exact number fields and avoid overflow errors thanks to the package SaferIntegers.jl [41].

The ninth resonance arrangement (511 hyperplanes in \({{\mathbb {R}}}^{9}\)) approaches the limit of what is possible with our implementation: the computation of its characteristic polynomial took ten days on 42 processors. Our computation confirms that its chamber-count is 1955230985997140 as independently and concurrently computed by Chroman and Singhar with different methods [10].

We first give background on hyperplane arrangements in Sect. 2. The ideas outlined in Sect. 3, regarding deletion and restriction algorithms, form the basic structure of our algorithm. We explain the relevant results regarding symmetries of arrangements in Sect. 4. The algorithm and its implementation details reside in Sect. 5. In Sect. 6 we construct and discuss examples of arrangements exhibiting large symmetry groups. We conclude in Sect. 7 with timings and comparisons to other software.

2 Hyperplane Arrangements

We begin by discussing background on the theory of hyperplane arrangements related to the problem of enumerating chambers: the main goal of this article and the associated software. Our notation will mostly follow the textbook by Orlik and Terao [38].

For any field \({{\mathbb {K}}}\), a hyperplane in \({{\mathbb {K}}}^d\) is an affine linear space of codimension one. Throughout this article, we denote by \({\mathcal {A}}=\{H_1,\dots ,H_n\}\) a (hyperplane) arrangement where \(H_i\) is a hyperplane in \({{\mathbb {K}}}^d\).

Definition 2.1

Suppose \({\mathcal {A}}\) is an arrangement in \({{\mathbb {R}}}^d\). The connected components of the complement \({{\mathbb {R}}}^d\setminus \bigcup _{H\in {\mathcal {A}}}H\) are called chambers of \({\mathcal {A}}\) and the set of chambers of \({\mathcal {A}}\) is denoted by \({{\,\textrm{ch}\,}}({\mathcal {A}})\).

Example 2.2

We use the arrangement

$$\begin{aligned} \bigl \{\underbrace{\{y-x=1\}}_{H_1},\underbrace{\{x=0\}}_{H_2}, \underbrace{\{x+y=1\}}_{H_3},\underbrace{\{y=0\}}_{H_4}\bigr \} \end{aligned}$$

in \({{\mathbb {R}}}^2\) as a running example. This arrangement is depicted in Fig. 1. It has ten chambers: two bounded and eight unbounded.

Given a subset \(I\subseteq [n]:=\{1,\dots ,n\}\), we write the set \(\{H_i\}_{i\in I}\) as \(H_I\) and its intersection as \(L_I=\bigcap _{i\in I}H_i\). The collection of these intersections form the set \(L({\mathcal {A}})=\{L_I\mid I\subseteq [n],\,L_I\ne \emptyset \}\), a combinatorial shadow of \({\mathcal {A}}\) known as its intersection poset. This poset is ordered by reverse inclusion and graded by the rank function, \(r:L({\mathcal {A}})\rightarrow {{\mathbb {Z}}}_{\ge 0}\), where \(r(L_I)={{\,\textrm{codim}\,}}\hspace{0.33325pt}(L_I)\). As a notational convention, we set \(r(I)=r(L_I)\) for \(I\subseteq [n]\) whenever \(L_I\ne \emptyset \).

2.1 The Characteristic Polynomial

Our algorithm counts chambers of an arrangement by computing a more refined count, namely the characteristic polynomial. The coefficients of this polynomial are known as the unsigned Whitney numbers of the first kind of the intersection poset \(L({\mathcal {A}})\), which we simply refer to as the Whitney numbers of the arrangement.

Fig. 1
figure 1

The arrangement introduced in Example 2.2

Definition 2.3

The characteristic polynomial of an arrangement \({\mathcal {A}}\) in \({{\mathbb {K}}}^d\) is the polynomial

$$\begin{aligned} \chi _{{\mathcal {A}}}(t)=\sum _{\begin{array}{c} I\subseteq [n]\\ L_I\ne \emptyset \end{array}}\!(-1)^{|I|}t^{d-r(I)} =\sum _{i=0}^d(-1)^i b_i({\mathcal {A}}) t^{d-i}. \end{aligned}$$
(1)

The integers \(b_i({\mathcal {A}})\), defined via (1), are non-negative and are called the Whitney numbers of \({\mathcal {A}}\). We denote the vector of Whitney numbers by \(b({\mathcal {A}})\).

The characteristic polynomial and Whitney numbers of an arrangement \({\mathcal {A}}\) depend only on the intersection poset \(L({\mathcal {A}})\) and have various interpretations depending on the field \({{\mathbb {K}}}\) as detailed below.

  • Real: For an arrangement \({\mathcal {A}}\) in \({{\mathbb {R}}}^d\), Zaslavsky [47] proved that

    $$\begin{aligned} |{{{\,\textrm{ch}\,}}({\mathcal {A}})}|=(-1)^d\chi _{{\mathcal {A}}}(-1)=\sum _{i=0}^db_i({\mathcal {A}}). \end{aligned}$$

    Thus, the Whitney numbers are a refined count of the chambers of \({\mathcal {A}}\). They have the following geometric interpretation. Given a generic flag \({\mathcal {F}}_\bullet :F_0\subset F_1\subset \ldots \subset F_d={{\mathbb {R}}}^d\) of affine linear subspaces \(F_i\) [where \(\dim \hspace{0.33325pt}(F_i)=i\)] the number of chambers of \({\mathcal {A}}\) which meet \(F_i\) but do not meet \(F_{i-1}\) is equal to \(b_i({\mathcal {A}})\) [45, Proposition 2.3.2].

  • Complex: If \({\mathcal {A}}\) is an arrangement in \({{\mathbb {C}}}^d\) where all hyperplanes contain the origin, then \(b_i({\mathcal {A}})\) is the ith topological Betti number of the complement \({{\mathbb {C}}}^d\setminus \bigcup _{H\in {\mathcal {A}}}H\) with rational coefficients [37]. Because of this, some papers refer to the Whitney numbers \(b_i({\mathcal {A}})\) as the Betti numbers of the arrangement \({\mathcal {A}}\) [46].

  • Finite: When \({\mathcal {A}}\) is an arrangement over a finite field \({{\mathbb {F}}}_q\), Crapo and Rota proved that \(\chi _{{\mathcal {A}}}(q)=\bigl |{{\mathbb {F}}}_q^d\setminus \bigcup _{H\in {\mathcal {A}}}H\bigr |\) [12]. Moreover, if \({\mathcal {A}}\) is a hyperplane arrangement in \({{\mathbb {Q}}}^d\) one may consider its reduction modulo q: \({\mathcal {A}}\otimes {{\mathbb {F}}}_q=\{H_1\otimes {{\mathbb {F}}}_q,\dots ,H_n\otimes {{\mathbb {F}}}_q\}\). When q is sufficiently large, we have that \(L({\mathcal {A}})=L({\mathcal {A}}\otimes {{\mathbb {F}}}_q)\) and thus computing \(\chi _{{\mathcal {A}}}(t)\) for rational arrangements also yields the number of points in the complement after reducing modulo large primes.

Example 2.4

Let \({\mathcal {A}}\) be the arrangement introduced in Example 2.2. Its characteristic polynomial is \(\chi _{{\mathcal {A}}}(t)=t^2-4t+5\). Figure 2 shows a generic flag \({\mathcal {F}}_\bullet \) intersecting this arrangement verifying that \(b({\mathcal {A}})=(1,4,5)\).

Fig. 2
figure 2

The intersections of a generic flag (purple) in \({{\mathbb {R}}}^2\) with the chambers of \({\mathcal {A}}\). The point \(F_0\) intersects one chamber, \(F_1\) intersects four others, and \(F_2\) intersects the remaining five, and so \(b({\mathcal {A}})=(1,4,5)\)

3 A Deletion–Restriction Algorithm

To compute the Whitney numbers of an arrangement \({\mathcal {A}}\) in \({{\mathbb {K}}}^d\), we take advantage of the behavior of \(\chi _{{\mathcal {A}}}(t)\) under the operations of deletion and restriction. These operations reduce computations about \({\mathcal {A}}\) to computations about two smaller arrangements. Thus at its core, our main algorithm is a divide-and-conquer algorithm.

Given a hyperplane \(H\in {\mathcal {A}}\), the deletion of H in \({\mathcal {A}}\) is the arrangement \({\mathcal {A}}\setminus \{H\}\). The restriction of H in \({\mathcal {A}}\) is the arrangement in \(H\cong {{\mathbb {K}}}^{d-1}\) defined by \({\mathcal {A}}^H=\{K\cap H\mid K\in {\mathcal {A}} \setminus \{H\}\}\). The following lemma provides the basic foundation of our algorithm.

Lemma 3.1

[38, Cor. 2.57] Given a hyperplane \(H\in {\mathcal {A}},\) we have that \(\chi _{{\mathcal {A}}}(t)=\chi _{{\mathcal {A}}\setminus \{H\}}(t)-\chi _{{\mathcal {A}}^H}(t)\). In particular, \(b({\mathcal {A}})=b\hspace{0.33325pt}({\mathcal {A}}\setminus \{H\})+0\hspace{0.33325pt}|\hspace{0.33325pt}b({\mathcal {A}}^H)\) where \(0\hspace{0.33325pt}|\hspace{0.33325pt}b\) means prepending the vector b with a zero.

3.1 A Simple Deletion–Restriction Algorithm

Lemma 3.1 along with the fact that the empty arrangement in \({{\mathbb {K}}}^d\) has the vector of Whitney numbers \((1,0,\dots ,0)\in {\mathbb {N}}^{d+1}\) suggests the following well-known recursive algorithm for computing \(b({\mathcal {A}})\).

Fig. 3
figure 3

The tree structure of Algorithm 1 on the hyperplane arrangement from Example 2.2. Hyperplanes are chosen (line 3) according to the ordering \(\{1,2,3,4\}\). In each box, the ambient space of the arrangement is shaded green. Deletions are marked with red edges (left children) and restrictions with blue edges (right children). Each arrangement box has the Whitney numbers above its upper right corner

Algorithm 1:
figure a

Whitney numbers via simple deletion and restriction

Structurally, Algorithm 1 is a depth-first binary tree algorithm on arrangements, rooted at the initial input: one child represents a deletion and the other a restriction, as shown in Fig. 3. The implementation of Algorithm 1 is already nontrivial as it is often the case that some hyperplanes become the same after a restriction. Thus, its proper implementation requires care in representing an arrangement on a computer.

3.2 Computationally Representing Deletions and Restrictions

An arrangement \({\mathcal {B}}\) coming from \({\mathcal {A}}\) via deletions and restrictions may be represented by an encoding of the restricted hyperplanes. To be precise, the pair

$$\begin{aligned} B=(\{H_{i_1},\dots ,H_{i_k}\},\{H_{j_1},\dots ,H_{j_\ell }\})=:(H_I,H_J) \end{aligned}$$

represents the hyperplane arrangement \({\mathcal {B}}\) in \(L_I\cong {{\mathbb {K}}}^{d-r(L_I)}\) given by the hyperplanes in \(\{H_j\cap L_I\}_{j\in J}\). Note that \(H_j\cap L_I\) may be empty for some \(j\in J\), in which case this intersection does not correspond to any hyperplane. We extend notation regarding \({\mathcal {B}}\) to its representation B (i.e., \(\chi _B(t):=\chi _{{\mathcal {B}}}(t)\) and \(b(B):=b({\mathcal {B}})\)).

If \(H_{j_1}\cap L_I\) is a hyperplane which occurs uniquely with respect to the tuple \((H_{j_1}\cap L_I,\dots ,H_{j_\ell }\cap L_I)\), then \({\mathcal {B}}^{H_{j_1}\cap L_I}\) and \({\mathcal {B}}\setminus \{H_{j_1}\cap L_I\}\) are represented by

$$\begin{aligned}&B^{H_{j_1}}:=(\{H_{i_1},\dots ,H_{i_k},H_{j_1}\},\{H_{j_2},\dots ,H_{j_\ell }\}),\\&B\setminus \{H_{j_1}\}:=(\{H_{i_1},\dots ,H_{i_k}\},\{H_{j_2},\dots ,H_{j_\ell }\}),\\ \end{aligned}$$

respectively. Whereas if \(H_{j_1}\cap L_I\) is either empty or does not occur uniquely, then \(B\setminus \{H_{j_1}\}\) trivially represents the same arrangement as B, namely \({\mathcal {B}}\). The following computational analogue of Lemma 3.1 establishes how such representations behave under deletion and restriction.

Lemma 3.2

Let \(B=(H_I,H_J)\) represent an arrangement \({\mathcal {B}}\) and fix \(H\in H_J\). If \(H\cap L_I\) is a hyperplane which occurs uniquely in the tuple \((H_j\cap L_I)_{j\in J}\) then \(\chi _B(t)=\chi _{B\setminus {\{H\}}}(t)-\chi _{B^H}(t)\) and \(b(B)=b\hspace{0.33325pt}(B\setminus \{H\})+0\hspace{0.33325pt}|\hspace{0.33325pt}b(B^{H})\). Otherwise, we have \(\chi _B(t)=\chi _{B\setminus {\{H\}}}(t)\) and \(b(B)=b\hspace{0.33325pt}(B\setminus \{H\})\).

Proof

The first case follows from Lemma 3.1. In the second case, B and \({B\setminus \{H\}}\) represent the same hyperplane arrangement and the result is trivial. \(\square \)

The following algorithm is equivalent to Algorithm 1.

Algorithm 2:
figure b

Whitney numbers via extended deletion and restriction

Given a hyperplane arrangement \({\mathcal {A}}=\{H_1,\dots ,H_n\}\) in \({{\mathbb {K}}}^d\), Algorithm 2 computes the Whitney numbers \(b_i({\mathcal {A}})\) when given \(A=(\emptyset ,\{H_1,\dots ,H_n\})\) as input. This algorithm traverses a binary tree which is essentially the same as the one from Algorithm 1. The only difference is that some edges are extended with nodes that have only one child and so we say it computes the Whitney numbers via extended deletion and restriction.

Algorithm 2 has the advantage that the representations of the original hyperplanes in \({\mathcal {A}}\) need not be updated upon restriction, and that representations of hyperplanes in \({\mathcal {A}}^H\) need not be unique. As a consequence, structural aspects of \({\mathcal {A}}\) such as its symmetries extend trivially to the representations of the restricted arrangements, as we explain in Sect. 4. Figure 4 displays the tree structure underlying Algorithm 2 on our running example. Note that J is constant amongst nodes in the same depth.

Fig. 4
figure 4

The tree structure of Algorithm 2 on the hyperplane arrangement from Example 2.2. Its nodes are represented by pairs of subsets \(I,J\subset \{1,2,3,4\}\) (top-left) and the Whitney numbers are given (top-right). Grey edges indicate that the condition in line 3 has been violated

4 Automorphisms of Hyperplane Arrangements

Our main contribution is the inclusion of symmetry-reduction in the deletion-restriction algorithm. Many other algorithms in discrete geometry have also been adapted to take advantage of symmetry [5, 6, 25, 26]. For us, the relevant symmetries for an arrangement are the rank-preserving permutations of its hyperplanes.

Let \({\mathfrak {S}}_n\) be the permutation group on [n]. Elements of a subgroup \(G\le {\mathfrak {S}}_n\) act on subsets of [n]. Given \(g\in G\) and \(I\subseteq [n]\), we fix the notation:

  • \(gI=\{g(i)\}_{i\in I}\) for the image of I under g,

  • \(I^G=\{g\in G\mid gI=I\}\) for the stabilizer of I in G,

  • \(G\cdot I=\{gI\mid g\in G\}\) for the orbit of I under G.

Definition 4.1

The automorphism group of \({\mathcal {A}}=\{H_1,\dots ,H_n\}\) is

$$\begin{aligned} {{\,\mathrm{Aut\hspace{0.33325pt}}\,}}({\mathcal {A}})=\{g\in {\mathfrak {S}}_n\mid r(H_I)=r(H_{gI})\text { for all }I\subseteq [n]\}. \end{aligned}$$

Given a representation \(B=(H_I,H_J)\) of an arrangement coming from \({\mathcal {A}}\), the automorphism group \({{\,\mathrm{Aut\hspace{0.33325pt}}\,}}({\mathcal {A}})\) acts as \(gB=(H_{gI},H_{gJ})\).

Remark 4.2

Our definition of the automorphism group of an arrangement is combinatorial, not geometric. This difference can be quite large. For example, a generic hyperplane arrangement \({\mathcal {A}}=\{H_1,\ldots ,H_n\}\) has no geometric symmetries but \({{\,\mathrm{Aut\hspace{0.33325pt}}\,}}({\mathcal {A}})={\mathfrak {S}}_n\).

Lemma 4.3

Let \({\mathcal {A}}=\{H_1,\dots ,H_n\}\) be an arrangement in \({{\mathbb {K}}}^d\) and let \(B_1\) and \(B_2\) represent arrangements coming from deletions and restrictions. If \(B_1\) and \(B_2\) are in the same orbit under \({{\,\mathrm{Aut\hspace{0.33325pt}}\,}}({\mathcal {A}})\) then \(b(B_1)=b(B_2)\).

Proof

The conclusion of the lemma is equivalent to showing that the characteristic polynomials of \(B_1\) and \(B_2\) are the same. This follows directly from the fact that the characteristic polynomial depends only on the intersection poset (graded by rank) and that \(B_1\) and \(B_2\) are in the same orbit under \({{\,\mathrm{Aut\hspace{0.33325pt}}\,}}({\mathcal {A}})\) if and only if they are related by a rank-preserving permutation. \(\square \)

Our algorithm relies upon the following corollary of Lemma 4.3.

Corollary 4.4

Let \(B=(H_I,H_J)\) represent a hyperplane arrangement coming from \({\mathcal {A}}=\{H_1,\dots ,H_n\}\). For \(g\in J^{{\text {Aut}}({\mathcal {A}})}\) we have that \(gB=(H_{gI},H_J)\) and B have the same Whitney numbers.

5 Enumeration Algorithm with Symmetry

Our main algorithm augments Algorithm 2, making particular use of Corollary 4.4. It is essentially a breadth-first tree algorithm except that at each level, nodes may be identified up to symmetry and so the algorithmic structure is no longer that of a tree. The output is the vector of Whitney numbers \(b({\mathcal {A}})\) of an arrangement \({\mathcal {A}}\), refining its chamber count. We remark that despite the fact that our algorithm takes advantage of symmetry and counts the number of chambers, it does not reveal any information about the sizes of orbits of chambers under this symmetry group.

Given an arrangement \({\mathcal {A}}=\{H_1,\dots ,H_n\}\) in \({{\mathbb {K}}}^d\), we represent the nodes of the algorithm at depth k by a dictionary \(T_k\). The keys of \(T_k\) are orbits \(G_k\cdot I\) for \(I\subseteq [k]\) where \(G_k\) is a subgroup of the stabilizer of \(\{k+1,\dots ,n\}\) in \({{\,\mathrm{Aut\hspace{0.33325pt}}\,}}({\mathcal {A}})\). The value of \(G_k\cdot I\) in this dictionary is a pair \((B_I,\omega (B_I))\) where \(B_I\) represents the hyperplane arrangement \((H_I,H_{\{k+1,\dots ,n\}})\) and \(\omega (B_I)\) is some multiplicity, tracking how many arrangements indexed by elements of the orbit \(G_k\cdot I\) have appeared. We refer to \(T_k\) as a k-th orbit-node dictionary.

Algorithm 3 presents the breadth-first structure of the algorithm.

Algorithm 3:
figure c

Whitney numbers using symmetry

Moving from depth \(k-1\) to k is performed by Algorithm 4.

Algorithm 4:
figure d

NextGeneration

Example 5.1

The structure underlying Algorithm 3 applied to the arrangement in Example 2.2 is shown in Fig. 5. It is no longer a tree but may be obtained from the tree in Fig. 4 by identifying nodes under the stabilizers of \({{\,\mathrm{Aut\hspace{0.33325pt}}\,}}({\mathcal {A}})\). Each identification accumulates multiplicity in the node and that multiplicity is passed down to its children.

Fig. 5
figure 5

The algorithmic structure underlying Algorithm 3. Starting at the top node, each call of Algorithm 4 produces the next depth of this graph

5.1 Representing Orbits

The computations of orbits in lines 5 and 10 require elaboration; specifically in regards to representing an orbit \(G\cdot I\) on a computer. One option is to use a canonical element of \(G\cdot I\), which can be computed using the MinimalImage or CanonicalImage functions from GAP [23, 24]. An alternative approach is to provide any function \(\varphi :2^{[n]}\rightarrow S\) taking values in an arbitrary set S such that \(\varphi (I)=\varphi (J)\) only if \(G\cdot I=G\cdot J\). Equivalently, \(\varphi \) is any factor of the projection \(\pi :2^{[n]}\rightarrow 2^{[n]}/G\) as a map of sets where \(2^{[n]}/G\) is the set of orbits. In this case, the value of \(\varphi (I)\) may be used to represent the orbit \(G\cdot I\) as a key in the orbit–node dictionaries. While this approach may fail to identify all nodes in the same orbit, nodes in distinct orbits are never identified and so the algorithm remains correct. The benefit is that it may be significantly more efficient to evaluate \(\varphi \) than it is to compute minimal or canonical images.

Our default option for identifying orbits is called pseudo_minimal_image. Given a subset \(I\subseteq [n]\) and a collection of elements \(g_1,\dots ,g_m\in G\le {\mathfrak {S}}_n\), this function sequentially computes \(g_iI\) and recursively calls itself on \(g_iI\) whenever \(g_iI<I\) lexicographically. If no such \(g_i\) produces a smaller subset, I itself is returned. Options are implemented for choosing m to be a proportion of |G| subject to maximum and minimum values. For our computations, we take \(m=n\) random elements of G. Although this greedy procedure does not make all possible identifications in the algorithm, we have found that it is quicker than MinimalImage to evaluate and produces a comparably small algorithmic structure.

Example 5.2

We compare the effect of three choices of identifications in Algorithm 3 (either pseudo_minimal_image, the MinimalImage function in GAP, or no identifications at all) on the resonance arrangement \({\mathcal {R}}_7\) (see Definition 6.3) consisting of 127 hyperplanes in \({\mathbb {R}}^7\). We compare the number of leaves of the algorithm at some depth, as well as the time per depth of the algorithm and display the results in Fig. 6.

As depicted, the cost (in number of leaves) of using pseudo_minimal_image compared to MinimalImage is negligible, while the benefits in terms of speed are significant. Similarly, while the timing of our algorithm with MinimalImage is comparable to the timing without any identifications (Algorithm 2), the memory usage is significantly reduced as conveyed by the number of leaves (a reasonable proxy for memory usage). This difference becomes even more dramatic for larger arrangements.

Fig. 6
figure 6

The leaves per depth and time per depth of Algorithm 3 on the arrangement \({\mathcal {R}}_7\) using pseudo_minimal_image, MinimalImage, and no identifications

5.2 Accumulating the Whitney Numbers and Skipping Levels

Much of the computational burden occurs in line 3 of Algorithm 4 and involves projecting the normal vectors of the hyperplanes in \({\mathcal {A}}\) along those hyperplanes which have been restricted. When implementing Algorithm 4, one may choose whether to save such computations at the cost of memory, or to perform redundant computations throughout the algorithm. We found that, for our benchmark examples, recomputation held the most benefit.

Nonetheless, from the linear algebra involved in the evaluation of line 3, one can read off \(j_{\min }\), the smallest \(j\in J\) for which this uniqueness condition is true. Hence, one may immediately place the left child of the corresponding node in level \(j_{\min }\) rather than k to avoid redundancy in line 3 later on. This comes at the cost of missing some identifications between the layers k and \(j_{\min }\).

Another implementation choice we made was to keep a running count of the Whitney numbers of the arrangement throughout the algorithm. Whenever \(j_{\min }=n\) while computing the children of \((B_I,\omega (B_I))\), we increment \(b_{|I|}\) by \(\omega (B_I)\) and delete the node altogether since no other deletions or restrictions are possible. Similarly, if \({\mathcal {A}}\) is a hyperplane arrangement where each hyperplane contains the origin, \(b_{|I|}\) and \(b_{|I|+1}\) are incremented by \(\omega (B_I)\) whenever \(j_{\min }=n-1\) by a similar reasoning. In this way, we can free memory occupied by nodes throughout the algorithm.

5.3 Relation to OSCAR

The new computer algebra system OSCAR in julia combines the existing systems GAP [50], Singular [14], Polymake [18, 27], and Antic (Hecke, Nemo) [51]. Our software is written in julia and builds heavily on these cornerstones. Specifically, we use the number theory components Nemo [17] and Hecke to work with arrangements defined over algebraic field extensions of \({{\mathbb {Q}}}\). For example the separability arrangement of the vertices of the 600-cell is defined over \({{\mathbb {Q}}}(\sqrt{5})\). Secondly, we use GAP [50] for group theoretic computations in Algorithm 4. Concretely, we compute stabilizers and minimal images using the GAP packages ferret [22] and images [24], respectively.

5.4 Functionality of CountingChambers.jl

The julia package titled CountingChambers.jl contains our implementation and is available at https://mathrepo.mis.mpg.de/CountingChambers. The following code snippet shows some standard functions of our package applied to the arrangement introduced in Example 2.2. A collection of hyperplanes defined by the equations \(\ell _i(x_1,\dots ,x_d)=c_i\) for \(1\le i\le n\) is encoded by a \(d\times n\) matrix A having the coefficients of \(\ell _i\) as columns and a vector c.

figure e

Note that the automorphism group of this arrangement is \({\mathfrak {S}}_3\hookrightarrow {\mathfrak {S}}_4\) consisting of permutations of the first three hyperplanes. This group can be passed to our algorithm via a list of generators in one-line notation:

figure f

As it is easy to run julia on multiple threads, we also implemented our algorithm to take advantage of this. By starting julia via the command julia –threads NUM_THREADS and passing the optional parameter multi_threaded=true to our methods, the for loop in Algorithm 4 is executed in parallel. Table 2 shows how the multithreading scales.

6 Examples and Integer Sequences

We apply our algorithm to a number of examples. Many of these arise from the following construction of separability arrangements.

6.1 Separability Arrangements

Fix a finite set \({\textbf{V}}\subset {{\mathbb {R}}}^d\). We associate to every \(v\in {\textbf{V}}\) the hyperplane \(H_v\subset ({{\mathbb {R}}}^{d+1})^*\) comprised of linear forms which vanish on (1, v). Equivalently, \(H_v\) represents the affine hyperplanes in \({{\mathbb {R}}}^d\) which contain v. We call the arrangement \({\mathcal {H}}_{{\textbf{V}}}:=\{H_v\,|\,v\in {\textbf{V}}\}\) the separability arrangement of \({\textbf{V}}\). We point out that by increasing the dimension d by one, this construction is distinct from the one which defines real reflection arrangements from root systems. In particular, translating \({\textbf{V}}\) does not change the combinatorics of \({\mathcal {H}}_{{\textbf{V}}}\).

A hyperplane \(H_v\) partitions the points in \(({{\mathbb {R}}}^{d+1})^*\setminus H_v\) into the sets \(H^+_v\) of linear forms which are positive on v and \(H^-_v\) which are negative on v. Consequently, all affine hyperplanes corresponding to points in a chamber of \({\mathcal {H}}_{{\textbf{V}}}\) are positive on some subset \(V_1\subset {\textbf{V}}\) and negative on its complement \(V_2={\textbf{V}}\setminus V_1\). Such a partition \(V_1\sqcup V_2={\textbf{V}}\) is called linearly separable. Hence, chambers of \({\mathcal {H}}_{{\textbf{V}}}\) are in bijection with linearly separable partitions of \({\textbf{V}}\), motivating the terminology for \({\mathcal {H}}_{{\textbf{V}}}\). This point of view, which connects linear separability and hyperplane arrangements, appears in [2, Sect. 2].

One purpose for introducing separability arrangements is that it immediately provides us with a zoo of arrangements admitting considerable symmetry; for example, those \({\textbf{V}}\) which are the vertices of regular polytopes.

6.2 The Threshold Arrangement

The following arrangement appears in the study of neural networks [35, 36, 49] and algebraic statistics [13].

Definition 6.1

The threshold arrangementFootnote 2, \({\mathcal {T}}_d\) is the separability arrangement associated to the vertices of the hypercube \([0,1]^d\). That is,

$$\begin{aligned} {\mathcal {T}}_d:=\{\{x_0+c_1x_1+\cdots +c_dx_d=0\}\ \text {with } c_i\in \{0,1\}\text { for all }c_i\}. \end{aligned}$$

As a consequence of the definition of \({\mathcal {T}}_d\), the linear automorphisms of the hypercube \([0,1]^d\), namely the hyperoctahedral group of order \(d!\hspace{0.44434pt}2^d\), is a subgroup of \({{\,\mathrm{Aut\hspace{0.33325pt}}\,}}({\mathcal {T}}_d)\). The true size of \({{\,\mathrm{Aut\hspace{0.33325pt}}\,}}({\mathcal {T}}_d)\) is \((d+1)!\hspace{0.66666pt}2^d\).

We computed the Whitney numbers of \({\mathcal {T}}_d\) for \(1\le d\le 8\), and thus their number of chambers. The results are collected in Table 3 and the timings appear in Table 1. The values of \(|{{{\,\textrm{ch}\,}}({\mathcal {T}}_d)}|\) for \(1\le d\le 9\) are listed in entry https://oeis.org/A000609 of the Online-Encyclopedia of Integer Sequences (OEIS), whereas the Whitney numbers of \({\mathcal {T}}_d\), to the best of our knowledge, have not been published before. Zuev showed that asymptotically \(|{{{\,\textrm{ch}\,}}({\mathcal {T}}_d)}|\sim 2^{d^2}\) [48].

Remark 6.2

Using similar proof techniques as in [32] one can show that the values of \(b_i({\mathcal {T}}_d)\) for \(1\le d\le 2^i\) determine a formula for \(b_i({\mathcal {T}}_d)\) for all d. Applying this to the case of \(b_2({\mathcal {T}}_d)\) and \(b_3({\mathcal {T}}_d)\) and using the results in Table 3 we obtain \(b_2({\mathcal {T}}_d)=(4^d-2^d)/2\) and \(b_3({\mathcal {T}}_d)=(4\cdot 8^d-3\cdot 6^d-6\cdot 4^d+5\cdot 2^d)/24\). For \(i\ge 4\) this technique requires knowledge of \(b_i({\mathcal {T}}_d)\) for at least \(1\le d\le 16\).

6.3 The Resonance Arrangement

The next arrangement we consider appears as a restriction of the threshold arrangement.

Definition 6.3

The resonance arrangement is the restriction of \({\mathcal {T}}_d\) to the hyperplane \(H_{(0,\dots ,0)}\). Equivalently, for \(d\ge 1\) the resonance arrangement is

$$\begin{aligned} {\mathcal {R}}_d:=\{\{c_1x_1+c_2x_2+\cdots +c_dx_d=0\}\ \text {with } c_i\in \{0,1\}\text { and not all }c_i\text { are zero}\}. \end{aligned}$$

The chambers of the resonance arrangements are in bijection with generalized retarded functions in quantum field theory [16]. An overview of the applications of the resonance arrangement is given in [32, Sect. 1]. A formula for their number of chambers remains elusive, let alone one for their Whitney numbers. Nonetheless, partial formulas and bounds exist [4, 19, 32, 48].

The numbers of chambers of the resonance arrangements are listed in the sequence https://oeis.org/A034997 in the OEIS up to \(d=9\). The Whitney numbers are published in [28] up to \(d=7\). Our software was able to determine the Whitney numbers of \({\mathcal {R}}_8\) and \({\mathcal {R}}_9\) confirming the concurrent computations in [10]. The computation for \({\mathcal {R}}_9\) took ten days, running multithreaded on 42 Intel Xeon E7-8867 v3 CPUs. All Whitney numbers of \({\mathcal {R}}_d\) up to \(d=9\) are given in Table 4 and the timings are listed in Table 1.

6.4 Separability Arrangements of the Cross-Polytopes

The cross-polytope of dimension d is the polytope with the 2d vertices \(\{\pm e_i\}_{i=1}^d\). Its symmetry group is the hyperoctahedral group of order \(d!2^d\). We define the arrangement \({\mathcal {C}}_d\) in \({{\mathbb {R}}}^{d+1}\) to be the separability arrangement of its vertices. Our computations show that \(|{{{\,\textrm{ch}\,}}({\mathcal {C}}_d)}|=2\cdot 3^d-2^d\) for \(d\le 20\), suggesting that \(|{{{\,\textrm{ch}\,}}({\mathcal {C}}_d)}|\) agrees with this sequence (https://oeis.org/A027649 in the OEIS). This can indeed be proven by applying Athanasiadis’ finite field method [1] and seems to be a new result obtained through experiments with our algorithm.

6.5 Separability Arrangements of Permutohedra

The permutohedron of dimension \(d-1\) is the convex hull of the d! points \(\sigma (1,\dots ,d)\) for all \(\sigma \in {\mathfrak {S}}_{d}\). The separability arrangements \({\mathcal {P}}_d\) of these points in \({{\mathbb {R}}}^{d+1}\) consist of d! hyperplanes. We record their Whitney numbers in Table 6 for \(1\le d\le 6\).

6.6 Separability Arrangements of Demicubes

The d-demicube is the convex hull of those vertices of the hypercube \([0,1]^d\) which have an odd number of 1’s. For instance, the 3-demicube is a regular tetrahedron. We denote by \({\mathcal {D}}_d\) the corresponding separability arrangement consisting of \(2^{d-1}\) hyperplanes in \({{\mathbb {R}}}^{d+1}\). Table 5 contains the Whitney numbers of \({\mathcal {D}}_d\) up to \({d=9}\).

6.7 Separability Arrangements of Some Regular Polytopes

In Table 7, we provide the Whitney numbers for the separability arrangements corresponding to the remaining two Platonic solids: the icosahedron and the dodecahedron. This table also contains the Whitney numbers of the separability arrangements of the vertices of the regular 24-cell, 600-cell, and 120-cell. Except for the 24-cell, each of these computations uses irrational realizations.

6.8 Discriminantal Arrangements

Given n points in \({{\mathbb {R}}}^d\) in general position, the discriminantal arrangement \(Disc _{d,n}\) is the hyperplane arrangement in \({{\mathbb {R}}}^d\) consisting of the \({n\atopwithdelims ()d}\) hyperplanes spanned by d-subsets of such points. This arrangement, originally called the “geometry of circuits” was introduced by Crapo [11]. We verify the Whitney numbers of \(\text {Disc}_{4,n}\) for \(5\le n\le 16\) given in [31, Sect. 4.4]. From this data, we recover their formula for the characteristic polynomial of \(Disc _{4,n}\) for all n. A deformation of this arrangement appears in physics [8, 9] and we were able to confirm the chamber counts given in these papers.

7 Timings

While other pieces of software for counting chambers of arrangements exist, they do not take advantage of symmetry and some compute significantly more data than our algorithm does. Consequently, our software outperforms them with respect to the calculation of Whitney numbers as shown below.

The implementation [29] in polymake computes much more information than the Whitney numbers, namely a chamber decomposition of the arrangement. The sage implementation, on the other hand, uses basic deletion and restriction as in Algorithm 2. Similarly, the GAP package alcove [33] computes the Tutte polynomial by simple deletion and restriction and then specializes this to the characteristic polynomial.

To illustrate the performance of our software on the arrangements from Sect. 6, we collect our timings in Table 1. This table also shows the growth in complexity for computing the number of chambers of these arrangements. Based on our profiling, the main bottleneck in our implementation is the identifications of orbits. Thus, improving pseudo_minimal_image would be the most direct method for making our code faster.