This is a first IJulia notebook to demonstrate features of Polymake.jl.

Author: Michael Joswig

In [1]:
using Cxx
In [2]:
using Polymake
polymake version 3.1.1
Copyright (c) 1997-2018
Ewgenij Gawrilow, Michael Joswig (TU Berlin)
http://www.polymake.org

This is free software licensed under GPL; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Produce a 6-dimensional polytope with 20 vertices, drawn uniformly at random on the unit sphere, and print its f-vector.

In [3]:
P = rand_sphere(6,20)
give( P, "F_VECTOR" )
polymake: used package cdd
  cddlib
  Implementation of the double description method of Motzkin et al.
  Copyright by Komei Fukuda.
  http://www-oldurls.inf.ethz.ch/personal/fukudak/cdd_home/

Out[3]:
pm::Vector<pm::Integer>
20 167 636 1173 1026 342

Now for the g-vector of the same polytope, but this time it is converted to a Julia Array.

In [4]:
g = convert(Array{Int32}, give( P, "G_VECTOR" ))
Out[4]:
4-element Array{Int32,1}:
  1
 13
 68
 66

Let's do a census of 100 random samples and plot the result. Since g_0=1 and g_1=#vertices-dimension-1 are constant, it suffices to plot g_2 versus g_3.

In [5]:
n_vertices=20
n_samples=100
g_vectors = Array{Int32}(n_samples,2)

for i=1:n_samples
    RS = rand_sphere(6,n_vertices)
    g = convert(Array{Int32}, give( RS, "G_VECTOR" ))
    g_vectors[i,1] = g[3] # notice index shift as Julia counts from 1
    g_vectors[i,2] = g[4]
end
In [7]:
using Gadfly
plot(x=g_vectors[1:n_samples,1], y=g_vectors[1:n_samples,2],
    Guide.xlabel("g_2"), Guide.ylabel("g_3"))
Out[7]:
g_2 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 40 60 80 100 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 0 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 0 2 4 6 8 10 12 14 16 18 20 22 24 26 28 30 32 34 36 38 40 42 44 46 48 50 52 54 56 58 60 62 64 66 68 70 72 74 76 78 80 82 84 86 88 90 92 94 96 98 100 102 104 106 108 110 112 114 116 118 120 122 124 126 128 130 132 134 136 138 140 142 144 146 148 150 152 154 156 158 160 0 50 100 150 200 0 5 10 15 20 25 30 35 40 45 50 55 60 65 70 75 80 85 90 95 100 105 110 115 120 125 130 135 140 145 150 155 160 g_3

Comparing with the maximal g-vector from McMullen's upper bound theorem shows that the random polytopes have rather few faces.

In [8]:
give( upper_bound_theorem(6,n_vertices), "G_VECTOR" )
Out[8]:
pm::Vector<pm::Integer>
1 13 91 455

The lesson to learn here is the following.

By just looking at this class of random polytopes, one cannot get an adequate intuition about the set of all 6-polytopes with 20 vertices, not even the simplicial ones.