This is a first IJulia notebook to demonstrate features of Polymake.jl.
Author: Michael Joswig
using Cxx
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.
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/
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.
g = convert(Array{Int32}, give( P, "G_VECTOR" ))
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.
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
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"))
Comparing with the maximal g-vector from McMullen's upper bound theorem shows that the random polytopes have rather few faces.
give( upper_bound_theorem(6,n_vertices), "G_VECTOR" )
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.