<?xml version="1.0" encoding="utf-8" ?> <!-- for emacs: -*- coding: utf-8 -*- --> <!-- Apache may like this line in the file .htaccess: AddCharset utf-8 .html --> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg-flat.dtd" > <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"> <head><title>Working with cones</title> <link rel="stylesheet" type="text/css" href="../../../../Macaulay2/Style/doc.css"/> </head> <body> <table class="buttons"> <tr> <td><div><a href="___Working_spwith_spfans.html">next</a> | <a href="_volume.html">previous</a> | <a href="___Working_spwith_spfans.html">forward</a> | <a href="_volume.html">backward</a> | up | <a href="index.html">top</a> | <a href="master.html">index</a> | <a href="toc.html">toc</a> | <a href="http://www.math.uiuc.edu/Macaulay2/">Macaulay2 web site</a></div> </td> </tr> </table> <hr/> <div><h1>Working with cones</h1> <div>We start with a cone in 2-space which is the positive hull (<a href="_pos__Hull.html" title="computes the positive hull of rays, cones, and the cone over a polyhedron">posHull</a>) of a given set of rays.<table class="examples"><tr><td><pre>i1 : R = matrix {{1,1,2},{2,1,1}} o1 = | 1 1 2 | | 2 1 1 | 2 3 o1 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i2 : C = posHull R o2 = {ambient dimension => 2 } dimension of lineality space => 0 dimension of the cone => 2 number of facets => 2 number of rays => 2 o2 : Cone</pre> </td></tr> <tr><td><pre>i3 : ambDim C o3 = 2</pre> </td></tr> </table> <p/> This gives an overview of the characteristics of the cone. If we want to know more details, we can ask for them.<table class="examples"><tr><td><pre>i4 : rays C o4 = | 2 1 | | 1 2 | 2 2 o4 : Matrix QQ <--- QQ</pre> </td></tr> </table> <p/> Using <a href="_rays.html" title="displays all rays of a Cone, a Fan, or a Polyhedron">rays</a> we see that (1,1) is not an extremal ray of the cone.<table class="examples"><tr><td><pre>i5 : HS = halfspaces C o5 = | -1 2 | | 2 -1 | 2 2 o5 : Matrix QQ <--- QQ</pre> </td></tr> </table> <p/> The function <a href="_halfspaces.html" title="computes the defining half-spaces of a Cone or a Polyhedron">halfspaces</a> gives the defining linear half-spaces, i.e. <tt>C</tt> is given by all <tt>p</tt> in the defining linear hyperplanes that satisfy <tt>HS*p >= 0</tt>. But in this case there are none, so the polyhedron is of full dimension. Furthermore, we can construct the positive hull of a set of rays and a linear subspace.<table class="examples"><tr><td><pre>i6 : R1 = R || matrix {{0,0,0}} o6 = | 1 1 2 | | 2 1 1 | | 0 0 0 | 3 3 o6 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i7 : LS = matrix {{1},{1},{1}} o7 = | 1 | | 1 | | 1 | 3 1 o7 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i8 : C1 = posHull(R1,LS) o8 = {ambient dimension => 3 } dimension of lineality space => 1 dimension of the cone => 3 number of facets => 2 number of rays => 2 o8 : Cone</pre> </td></tr> <tr><td><pre>i9 : rays C1 o9 = | 0 0 | | -1 1 | | -2 -1 | 3 2 o9 : Matrix QQ <--- QQ</pre> </td></tr> </table> <p/> Note that the rays are given modulo the lineality space. On the other hand we can construct cones as the <a href="_intersection.html" title="computes the intersection of half-spaces, hyperplanes, cones, and polyhedra">intersection</a> of linear half-spaces and hyperplanes.<table class="examples"><tr><td><pre>i10 : HS = transpose R1 o10 = | 1 2 0 | | 1 1 0 | | 2 1 0 | 3 3 o10 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i11 : HP = matrix {{1,1,1}} o11 = | 1 1 1 | 1 3 o11 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i12 : C2 = intersection(HS,HP) o12 = {ambient dimension => 3 } dimension of lineality space => 0 dimension of the cone => 2 number of facets => 2 number of rays => 2 o12 : Cone</pre> </td></tr> </table> <p/> This is a two dimensional cone in 3-space with the following rays:<table class="examples"><tr><td><pre>i13 : rays C2 o13 = | 2 -1 | | -1 2 | | -1 -1 | 3 2 o13 : Matrix QQ <--- QQ</pre> </td></tr> </table> <p/> If we don't intersect with the hyperplane we get a full dimensional cone.<table class="examples"><tr><td><pre>i14 : C3 = intersection HS o14 = {ambient dimension => 3 } dimension of lineality space => 1 dimension of the cone => 3 number of facets => 2 number of rays => 2 o14 : Cone</pre> </td></tr> <tr><td><pre>i15 : rays C3 o15 = | 2 -1 | | -1 2 | | 0 0 | 3 2 o15 : Matrix QQ <--- QQ</pre> </td></tr> <tr><td><pre>i16 : linSpace C3 o16 = | 0 | | 0 | | 1 | 3 1 o16 : Matrix QQ <--- QQ</pre> </td></tr> </table> <p/> Again, the rays are given modulo the lineality space. Also, one can use given cones, for example the positive orthant (<a href="_pos__Orthant.html" title="generates the positive orthant in n-space">posOrthant</a>):<table class="examples"><tr><td><pre>i17 : C4 = posOrthant 3 o17 = {ambient dimension => 3 } dimension of lineality space => 0 dimension of the cone => 3 number of facets => 3 number of rays => 3 o17 : Cone</pre> </td></tr> <tr><td><pre>i18 : rays C4 o18 = | 1 0 0 | | 0 1 0 | | 0 0 1 | 3 3 o18 : Matrix QQ <--- QQ</pre> </td></tr> </table> <p/> Now that we can construct cones, we can turn to the functions that can be applied to cones. First of all, we can apply the <a href="_intersection.html" title="computes the intersection of half-spaces, hyperplanes, cones, and polyhedra">intersection</a> function also to a pair of cones in the same ambient space:<table class="examples"><tr><td><pre>i19 : C5 = intersection(C1,C2) o19 = {ambient dimension => 3 } dimension of lineality space => 0 dimension of the cone => 2 number of facets => 2 number of rays => 2 o19 : Cone</pre> </td></tr> <tr><td><pre>i20 : rays C5 o20 = | 1 0 | | 0 1 | | -1 -1 | 3 2 o20 : Matrix QQ <--- QQ</pre> </td></tr> </table> <p/> On the other hand, we can take their positive hull by using <a href="_pos__Hull.html" title="computes the positive hull of rays, cones, and the cone over a polyhedron">posHull</a>:<table class="examples"><tr><td><pre>i21 : C6 = posHull(C1,C2) o21 = {ambient dimension => 3 } dimension of lineality space => 1 dimension of the cone => 3 number of facets => 2 number of rays => 2 o21 : Cone</pre> </td></tr> <tr><td><pre>i22 : rays C6 o22 = | 0 0 | | 1 -1 | | 0 -1 | 3 2 o22 : Matrix QQ <--- QQ</pre> </td></tr> <tr><td><pre>i23 : linSpace C6 o23 = | 1 | | 1 | | 1 | 3 1 o23 : Matrix QQ <--- QQ</pre> </td></tr> </table> <p/> Furthermore, both functions (<a href="_intersection.html" title="computes the intersection of half-spaces, hyperplanes, cones, and polyhedra">intersection</a> and <a href="_pos__Hull.html" title="computes the positive hull of rays, cones, and the cone over a polyhedron">posHull</a>) can be applied to a list containing any number of cones and matrices defining rays and lineality space or linear half-spaces and hyperplanes. These must be in the same ambient space. For example:<table class="examples"><tr><td><pre>i24 : R2 = matrix {{2,-1},{-1,2},{-1,-1}} o24 = | 2 -1 | | -1 2 | | -1 -1 | 3 2 o24 : Matrix ZZ <--- ZZ</pre> </td></tr> <tr><td><pre>i25 : C7 = posHull {R2,C3,C4} o25 = {ambient dimension => 3 } dimension of lineality space => 1 dimension of the cone => 3 number of facets => 2 number of rays => 2 o25 : Cone</pre> </td></tr> <tr><td><pre>i26 : rays C7 o26 = | 2 -1 | | -1 2 | | 0 0 | 3 2 o26 : Matrix QQ <--- QQ</pre> </td></tr> <tr><td><pre>i27 : linSpace C7 o27 = | 0 | | 0 | | 1 | 3 1 o27 : Matrix QQ <--- QQ</pre> </td></tr> </table> <p/> Since they are all cones their positive hull is the same as their Minkowski sum, so in fact:<table class="examples"><tr><td><pre>i28 : C6 == C1 + C2 o28 = true</pre> </td></tr> </table> <p/> But we can take the Minkowski sum of a cone and a polyhedron. For this, both objects must lie in the same ambient space and the resulting object is then a polyhedron:<table class="examples"><tr><td><pre>i29 : P = crossPolytope 3 o29 = {ambient dimension => 3 } dimension of lineality space => 0 dimension of polyhedron => 3 number of facets => 8 number of rays => 0 number of vertices => 6 o29 : Polyhedron</pre> </td></tr> <tr><td><pre>i30 : P1 = C6 + P o30 = {ambient dimension => 3 } dimension of lineality space => 1 dimension of polyhedron => 3 number of facets => 2 number of rays => 2 number of vertices => 1 o30 : Polyhedron</pre> </td></tr> <tr><td><pre>i31 : (vertices P1,rays P1) o31 = (| 0 |, | 0 0 |) | 0 | | 1 -1 | | 1 | | 0 -1 | o31 : Sequence</pre> </td></tr> </table> <p/> Furthermore, we can take the direct product (<a href="_direct__Product.html" title="computes the direct product of two convex objects">directProduct</a>) of two cones.<table class="examples"><tr><td><pre>i32 : C8 = C * C1 o32 = {ambient dimension => 5 } dimension of lineality space => 1 dimension of the cone => 5 number of facets => 4 number of rays => 4 o32 : Cone</pre> </td></tr> <tr><td><pre>i33 : rays C8 o33 = | 2 1 0 0 | | 1 2 0 0 | | 0 0 0 0 | | 0 0 -1 1 | | 0 0 -2 -1 | 5 4 o33 : Matrix QQ <--- QQ</pre> </td></tr> <tr><td><pre>i34 : linSpace C8 o34 = | 0 | | 0 | | 1 | | 1 | | 1 | 5 1 o34 : Matrix QQ <--- QQ</pre> </td></tr> </table> <p/> The result is in QQ^5.<table class="examples"><tr><td><pre>i35 : ambDim C8 o35 = 5</pre> </td></tr> </table> <p/> To find out more about this cone use for example <a href="_f__Vector.html" title="computes the f-vector of a Cone or Polyhedron">fVector</a>:<table class="examples"><tr><td><pre>i36 : fVector C8 o36 = {0, 1, 4, 6, 4, 1} o36 : List</pre> </td></tr> </table> <p/> This function gives the number of faces of each dimension, so it has 1 vertex, the origin, 1 line, 4 two dimensional faces and so on. We can access the faces of a certain codimension via <a href="_faces.html" title="computes all faces of a certain codimension of a Cone or Polyhedron">faces</a>:<table class="examples"><tr><td><pre>i37 : L = faces(1,C8) o37 = {{ambient dimension => 5 }, {ambient dimension => 5 dimension of lineality space => 1 dimension of lineality space => dimension of the cone => 4 dimension of the cone => 4 number of facets => 3 number of facets => 3 number of rays => 3 number of rays => 3 ----------------------------------------------------------------------- }, {ambient dimension => 5 }, {ambient dimension => 5 1 dimension of lineality space => 1 dimension of lineality space dimension of the cone => 4 dimension of the cone => 4 number of facets => 3 number of facets => 3 number of rays => 3 number of rays => 3 ----------------------------------------------------------------------- }} => 1 o37 : List</pre> </td></tr> <tr><td><pre>i38 : apply(L,rays) o38 = {| 2 0 0 |, | 1 0 0 |, | 2 1 0 |, | 2 1 0 |} | 1 0 0 | | 2 0 0 | | 1 2 0 | | 1 2 0 | | 0 0 0 | | 0 0 0 | | 0 0 0 | | 0 0 0 | | 0 -1 1 | | 0 -1 1 | | 0 0 -1 | | 0 0 1 | | 0 -2 -1 | | 0 -2 -1 | | 0 0 -2 | | 0 0 -1 | o38 : List</pre> </td></tr> </table> <p/> We can also check if the cone is smooth:<table class="examples"><tr><td><pre>i39 : isSmooth C8 o39 = false</pre> </td></tr> </table> <p/> Evenmore we can compute the Hilbert basis of the cone with <a href="_hilbert__Basis.html" title="computes the Hilbert basis of a Cone">hilbertBasis</a>.<table class="examples"><tr><td><pre>i40 : L = hilbertBasis C8 o40 = {| 0 |, | 0 |, | 0 |, | -1 |, | 0 |, | -1 |} | 0 | | 0 | | 0 | | -1 | | -1 | | 0 | | 0 | | 0 | | 0 | | -2 | | -2 | | -2 | | 1 | | 2 | | 1 | | 0 | | 0 | | 0 | | 1 | | 1 | | 2 | | 0 | | 0 | | 0 | o40 : List</pre> </td></tr> <tr><td><pre>i41 : #L o41 = 6</pre> </td></tr> </table> <p/> Finally, there is also a function to compute the dual cone, i.e. the set of all points in the dual space that are positive on the cone.<table class="examples"><tr><td><pre>i42 : C9 = dualCone C8 o42 = {ambient dimension => 5 } dimension of lineality space => 0 dimension of the cone => 4 number of facets => 4 number of rays => 4 o42 : Cone</pre> </td></tr> <tr><td><pre>i43 : rays C9 o43 = | 2 -1 0 0 | | -1 2 0 0 | | 0 0 2 -1 | | 0 0 -1 2 | | 0 0 -1 -1 | 5 4 o43 : Matrix QQ <--- QQ</pre> </td></tr> </table> </div> </div> </body> </html>