Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place.
| Download
GAP 4.8.9 installation with standard packages -- copy to your CoCalc project to get it
Project: cocalc-sagemath-dev-slelievre
Views: 418346<?xml version="1.0" encoding="UTF-8"?>12<!-- This is an automatically generated file. -->3<Chapter Label="Chapter_Examples">4<Heading>Examples</Heading>56<P/>7<Section Label="Chapter_Examples_Section_Generators">8<Heading>Generators</Heading>910<P/>11<Example><![CDATA[12gap> C := NmzCone(["integral_closure",[[2,1],[1,3]]]);13<a Normaliz cone>14gap> NmzHasConeProperty(C,"HilbertBasis");15false16gap> NmzHasConeProperty(C,"SupportHyperplanes");17false18gap> NmzConeProperty(C,"HilbertBasis");19[ [ 1, 1 ], [ 1, 2 ], [ 1, 3 ], [ 2, 1 ] ]20gap> NmzHasConeProperty(C,"SupportHyperplanes");21true22gap> NmzConeProperty(C,"SupportHyperplanes");23[ [ -1, 2 ], [ 3, -1 ] ]24]]></Example>25262728<P/>29</Section>303132<Section Label="Chapter_Examples_Section_System_of_equations">33<Heading>System of equations</Heading>3435<Example><![CDATA[36gap> D := NmzCone(["equations",[[1,2,-3]], "grading",[[0,-1,3]]]);37<a Normaliz cone>38gap> NmzCompute(D,["DualMode","HilbertSeries"]);39true40gap> NmzHilbertBasis(D);41[ [ 1, 1, 1 ], [ 0, 3, 2 ], [ 3, 0, 1 ] ]42gap> NmzHilbertSeries(D);43[ t^2-t+1, [ [ 1, 1 ], [ 3, 1 ] ] ]44gap> NmzHasConeProperty(D,"SupportHyperplanes");45true46gap> NmzSupportHyperplanes(D);47[ [ 1, 0, 0 ], [ 1, 3, -3 ] ]48gap> NmzEquations(D);49[ [ 1, 2, -3 ] ]50]]></Example>51525354<P/>55</Section>565758<Section Label="Chapter_Examples_Section_System_of_inhomogeneous_equations">59<Heading>System of inhomogeneous equations</Heading>6061<Example><![CDATA[62gap> P := NmzCone(["inhom_equations",[[1,2,-3,1]], "grading", [[1,1,1]]]);63<a Normaliz cone>64gap> NmzIsInhomogeneous(C);65false66gap> NmzIsInhomogeneous(P);67true68gap> NmzHilbertBasis(P);69[ [ 1, 1, 1, 0 ], [ 3, 0, 1, 0 ], [ 0, 3, 2, 0 ] ]70gap> NmzModuleGenerators(P);71[ [ 0, 1, 1, 1 ], [ 2, 0, 1, 1 ] ]72]]></Example>73747576<P/>77</Section>787980<Section Label="Chapter_Examples_Section_Combined_input">81<Heading>Combined input</Heading>8283Normaliz also allows the combination of different kinds of input, e.g.84multiple constraint types, or additional data like a grading.85<P/>86Suppose that you have a 3 by 3 <Q>square</Q> of nonnegative integers such that87the 3 numbers in all rows, all columns, and both diagonals sum to the same88constant <M>M</M>. Sometimes such squares are called magic and <M>M</M> is the89magic constant. This leads to a linear system of equations. The magic constant90is a natural choice for the grading. Additionally we force here the 4 corner91to have even value by adding congruences.92<P/>93<Example><![CDATA[94gap> Magic3x3even := NmzCone(["equations",95> [ [1, 1, 1, -1, -1, -1, 0, 0, 0],96> [1, 1, 1, 0, 0, 0, -1, -1, -1],97> [0, 1, 1, -1, 0, 0, -1, 0, 0],98> [1, 0, 1, 0, -1, 0, 0, -1, 0],99> [1, 1, 0, 0, 0, -1, 0, 0, -1],100> [0, 1, 1, 0, -1, 0, 0, 0, -1],101> [1, 1, 0, 0, -1, 0, -1, 0, 0] ],102> "congruences",103> [ [1, 0, 0, 0, 0, 0, 0, 0, 0, 2],104> [0, 0, 1, 0, 0, 0, 0, 0, 0, 2],105> [0, 0, 0, 0, 0, 0, 1, 0, 0, 2],106> [0, 0, 0, 0, 0, 0, 0, 0, 1, 2] ],107> "grading",108> [ [1, 1, 1, 0, 0, 0, 0, 0, 0] ] ] );109<a Normaliz cone>110gap> NmzHilbertBasis(Magic3x3even);111[ [ 0, 4, 2, 4, 2, 0, 2, 0, 4 ], [ 2, 0, 4, 4, 2, 0, 0, 4, 2 ],112[ 2, 2, 2, 2, 2, 2, 2, 2, 2 ], [ 2, 4, 0, 0, 2, 4, 4, 0, 2 ],113[ 4, 0, 2, 0, 2, 4, 2, 4, 0 ], [ 2, 3, 4, 5, 3, 1, 2, 3, 4 ],114[ 2, 5, 2, 3, 3, 3, 4, 1, 4 ], [ 4, 1, 4, 3, 3, 3, 2, 5, 2 ],115[ 4, 3, 2, 1, 3, 5, 4, 3, 2 ] ]116gap> NmzHilbertSeries(Magic3x3even);117[ t^3+3*t^2-t+1, [ [ 1, 1 ], [ 2, 2 ] ] ]118gap> NmzHilbertQuasiPolynomial(Magic3x3even);119[ 1/2*t^2+t+1, 1/2*t^2-1/2 ]120]]></Example>121122123124<P/>125</Section>126127128<Section Label="Chapter_Examples_Section_Using_the_dual_mode">129<Heading>Using the dual mode</Heading>130131For solving systems of equations and inequalities it is often faster to use132the dual Normaliz algorithm. We demonstrate how to use it with an133inhomogeneous system of equations and inequalities.134<P/>135The input consists of a system of 8 inhomogeneous equations in R^3. The first136row of the matrix M encodes the inequality <M>8x + 8y + 8z + 7 \geq 0</M>.137Additionally we say that <M>x, y, z</M> should be non-negative by giving the138sign vector and use the total degree.139<Example><![CDATA[140gap> M := [141> [ 8, 8, 8, 7 ],142> [ 0, 4, 0, 1 ],143> [ 0, 1, 0, 7 ],144> [ 0, -2, 0, 7 ],145> [ 0, -2, 0, 1 ],146> [ 8, 48, 8, 17 ],147> [ 1, 6, 1, 34 ],148> [ 2,-12, -2, 37 ],149> [ 4,-24, -4, 14 ]150> ];151[ [ 8, 8, 8, 7 ], [ 0, 4, 0, 1 ], [ 0, 1, 0, 7 ], [ 0, -2, 0, 7 ],152[ 0, -2, 0, 1 ], [ 8, 48, 8, 17 ], [ 1, 6, 1, 34 ],153[ 2, -12, -2, 37 ], [ 4, -24, -4, 14 ] ]154gap> D := NmzCone(["inhom_inequalities", M,155> "signs", [[1,1,1]],156> "grading", [[1,1,1]]]);157<a Normaliz cone>158gap> NmzCompute(D,["DualMode","HilbertBasis","ModuleGenerators"]);159true160gap> NmzHilbertBasis(D);161[ [ 1, 0, 0, 0 ], [ 1, 0, 1, 0 ] ]162gap> NmzModuleGenerators(D);163[ [ 0, 0, 0, 1 ], [ 0, 0, 1, 1 ], [ 0, 0, 2, 1 ], [ 0, 0, 3, 1 ] ]164]]></Example>165166167168<P/>169As result we get the Hilbert basis of the cone of the solutions to the170homogeneous system and the module generators which are the base171solutions to the inhomogeneous system.172<P/>173</Section>174175176</Chapter>177178179180