def Ish(self, n, K=QQ, names=None): r""" Return the Ish arrangement. INPUT: - ``n`` -- integer - ``K`` -- field (default:``QQ``) - ``names`` -- tuple of strings or ``None`` (default); the variable names for the ambient space OUTPUT: The Ish arrangement, which is the set of `n(n-1)` hyperplanes. .. MATH:: \{ x_i - x_j = 0 : 1 \leq i \leq j \leq n \} \cup \{ x_1 - x_j = i : 1 \leq i \leq j \leq n \}. EXAMPLES:: sage: a = hyperplane_arrangements.Ish(3); a Arrangement of 6 hyperplanes of dimension 3 and rank 2 sage: a.characteristic_polynomial() x^3 - 6*x^2 + 9*x sage: b = hyperplane_arrangements.Shi(3) sage: b.characteristic_polynomial() x^3 - 6*x^2 + 9*x TESTS:: sage: a.characteristic_polynomial.clear_cache() # long time sage: a.characteristic_polynomial() # long time x^3 - 6*x^2 + 9*x REFERENCES: .. [AR] D. Armstrong, B. Rhoades "The Shi arrangement and the Ish arrangement" :arxiv:`1009.1655` """ H = make_parent(K, n, names) x = H.gens() hyperplanes = [] for i in range(n): for j in range(i+1, n): hyperplanes.append(x[i] - x[j]) hyperplanes.append(x[0] - x[j] - (i+1)) A = H(*hyperplanes) x = polygen(QQ, 'x') charpoly = x * sum([(-1)**k * stirling_number2(n, n-k) * prod([(x - 1 - j) for j in range(k, n-1)]) for k in range(0, n)]) A.characteristic_polynomial.set_cache(charpoly) return A
def cardinality(self): """ EXAMPLES:: sage: OrderedSetPartitions(4,2).cardinality() 14 sage: OrderedSetPartitions(4,1).cardinality() 1 """ set = self.s n = self.n return factorial(n)*stirling_number2(len(set),n)
def cardinality(self): """ The Stirling number of the second kind is the number of partitions of a set of size `n` into `k` blocks. EXAMPLES:: sage: SetPartitions(5, 3).cardinality() 25 sage: stirling_number2(5,3) 25 """ return stirling_number2(len(self._set), self.n)
def cardinality(self): """ Return the cardinality of ``self``. The number of ordered partitions of a set of size `n` into `k` parts is equal to `k! S(n,k)` where `S(n,k)` denotes the Stirling number of the second kind. EXAMPLES:: sage: OrderedSetPartitions(4,2).cardinality() 14 sage: OrderedSetPartitions(4,1).cardinality() 1 """ return factorial(self.n)*stirling_number2(len(self._set), self.n)
def semiorder(self, n, K=QQ, names=None): r""" Return the semiorder arrangement. INPUT: - ``n`` -- integer - ``K`` -- field (default: `\QQ`) - ``names`` -- tuple of strings or ``None`` (default); the variable names for the ambient space OUTPUT: The semiorder arrangement, which is the set of `n(n-1)` hyperplanes `\{ x_i - x_j = -1,1 : 1 \leq i \leq j \leq n\}`. EXAMPLES:: sage: hyperplane_arrangements.semiorder(4) Arrangement of 12 hyperplanes of dimension 4 and rank 3 TESTS:: sage: h = hyperplane_arrangements.semiorder(5) sage: h.characteristic_polynomial() x^5 - 20*x^4 + 180*x^3 - 790*x^2 + 1380*x sage: h.characteristic_polynomial.clear_cache() # long time sage: h.characteristic_polynomial() # long time x^5 - 20*x^4 + 180*x^3 - 790*x^2 + 1380*x """ H = make_parent(K, n, names) x = H.gens() hyperplanes = [] for i in range(n): for j in range(i + 1, n): for k in [-1, 1]: hyperplanes.append(x[i] - x[j] - k) A = H(*hyperplanes) x = polygen(QQ, 'x') charpoly = x * sum([ stirling_number2(n, k) * prod([x - k - i for i in range(1, k)]) for k in range(1, n + 1) ]) A.characteristic_polynomial.set_cache(charpoly) return A
def Shi(self, n, K=QQ, names=None): r""" Return the Shi arrangement. INPUT: - ``n`` -- integer - ``K`` -- field (default:``QQ``) - ``names`` -- tuple of strings or ``None`` (default); the variable names for the ambient space OUTPUT: The Shi arrangement is the set of `n(n-1)` hyperplanes: `\{ x_i - x_j = 0,1 : 1 \leq i \leq j \leq n \}`. EXAMPLES:: sage: hyperplane_arrangements.Shi(4) Arrangement of 12 hyperplanes of dimension 4 and rank 3 TESTS:: sage: h = hyperplane_arrangements.Shi(4) sage: h.characteristic_polynomial() x^4 - 12*x^3 + 48*x^2 - 64*x sage: h.characteristic_polynomial.clear_cache() # long time sage: h.characteristic_polynomial() # long time x^4 - 12*x^3 + 48*x^2 - 64*x """ H = make_parent(K, n, names) x = H.gens() hyperplanes = [] for i in range(n): for j in range(i + 1, n): for const in [0, 1]: hyperplanes.append(x[i] - x[j] - const) A = H(*hyperplanes) x = polygen(QQ, 'x') charpoly = x * sum([(-1)**k * stirling_number2(n, n - k) * prod([(x - 1 - j) for j in range(k, n - 1)]) for k in range(0, n)]) A.characteristic_polynomial.set_cache(charpoly) return A
def Shi(self, n, K=QQ, names=None): r""" Return the Shi arrangement. INPUT: - ``n`` -- integer - ``K`` -- field (default:``QQ``) - ``names`` -- tuple of strings or ``None`` (default); the variable names for the ambient space OUTPUT: The Shi arrangement is the set of `n(n-1)` hyperplanes: `\{ x_i - x_j = 0,1 : 1 \leq i \leq j \leq n \}`. EXAMPLES:: sage: hyperplane_arrangements.Shi(4) Arrangement of 12 hyperplanes of dimension 4 and rank 3 TESTS:: sage: h = hyperplane_arrangements.Shi(4) sage: h.characteristic_polynomial() x^4 - 12*x^3 + 48*x^2 - 64*x sage: h.characteristic_polynomial.clear_cache() # long time sage: h.characteristic_polynomial() # long time x^4 - 12*x^3 + 48*x^2 - 64*x """ H = make_parent(K, n, names) x = H.gens() hyperplanes = [] for i in range(n): for j in range(i+1, n): for const in [0, 1]: hyperplanes.append(x[i] - x[j] - const) A = H(*hyperplanes) x = polygen(QQ, 'x') charpoly = x * sum([(-1)**k * stirling_number2(n, n-k) * prod([(x - 1 - j) for j in range(k, n-1)]) for k in range(0, n)]) A.characteristic_polynomial.set_cache(charpoly) return A
def semiorder(self, n, K=QQ, names=None): r""" Return the semiorder arrangement. INPUT: - ``n`` -- integer - ``K`` -- field (default: `\QQ`) - ``names`` -- tuple of strings or ``None`` (default); the variable names for the ambient space OUTPUT: The semiorder arrangement, which is the set of `n(n-1)` hyperplanes `\{ x_i - x_j = -1,1 : 1 \leq i \leq j \leq n\}`. EXAMPLES:: sage: hyperplane_arrangements.semiorder(4) Arrangement of 12 hyperplanes of dimension 4 and rank 3 TESTS:: sage: h = hyperplane_arrangements.semiorder(5) sage: h.characteristic_polynomial() x^5 - 20*x^4 + 180*x^3 - 790*x^2 + 1380*x sage: h.characteristic_polynomial.clear_cache() # long time sage: h.characteristic_polynomial() # long time x^5 - 20*x^4 + 180*x^3 - 790*x^2 + 1380*x """ H = make_parent(K, n, names) x = H.gens() hyperplanes = [] for i in range(n): for j in range(i+1, n): for k in [-1, 1]: hyperplanes.append(x[i] - x[j] - k) A = H(*hyperplanes) x = polygen(QQ, 'x') charpoly = x * sum([stirling_number2(n, k) * prod([x - k - i for i in range(1, k)]) for k in range(1, n+1)]) A.characteristic_polynomial.set_cache(charpoly) return A
def cardinality(self): """ EXAMPLES:: sage: OrderedSetPartitions(0).cardinality() 1 sage: OrderedSetPartitions(1).cardinality() 1 sage: OrderedSetPartitions(2).cardinality() 3 sage: OrderedSetPartitions(3).cardinality() 13 sage: OrderedSetPartitions([1,2,3]).cardinality() 13 sage: OrderedSetPartitions(4).cardinality() 75 sage: OrderedSetPartitions(5).cardinality() 541 """ return sum([factorial(k)*stirling_number2(len(self._set),k) for k in range(len(self._set)+1)])