{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Welcome to Nemo version 0.18.2\n",
"\n",
"Nemo comes with absolutely no warranty whatsoever\n",
"\n",
"Singular.jl, based on\n",
" SINGULAR / \n",
" A Computer Algebra System for Polynomial Computations / Singular.jl: 0.4.1 \n",
" 0< Singular : 2.3.1-4\n",
" by: W. Decker, G.-M. Greuel, G. Pfister, H. Schoenemann \\ \n",
"FB Mathematik der Universitaet, D-67653 Kaiserslautern \\\n",
" \n"
]
},
{
"data": {
"text/html": [
"$\\require{action}$"
]
},
"metadata": {},
"output_type": "display_data"
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"\n",
"Welcome to \n",
"\n",
"\u001b[31m _ _ _\u001b[39m\n",
"\u001b[31m | | | | | |\u001b[39m\n",
"\u001b[31m | |__| | ___ ___| | _____\u001b[39m\n",
"\u001b[31m | __ |/ _ \\/ __| |/ / _ \\\u001b[39m\n",
"\u001b[31m | | | | __/ (__| < __/\u001b[39m\n",
"\u001b[31m |_| |_|\\___|\\___|_|\\_\\___|\u001b[39m\n",
"\u001b[31m \u001b[39m\n",
"Version\u001b[32m 0.8.5 \u001b[39m... \n",
" ... which comes with absolutely no warranty whatsoever\n",
"(c) 2015-2020 by Claus Fieker, Tommy Hofmann and Carlo Sircana\n",
"\n",
" ┌───────┐ GAP 4.11.0 of 29-Feb-2020\n",
" │ GAP │ https://www.gap-system.org\n",
" └───────┘ Architecture: x86_64-pc-linux-gnu-julia64-kv7-v1.5\n",
" Configuration: gmp 6.2.1, Julia GC, Julia 1.5.3, readline\n",
" Loading the library and packages ...\n",
" Packages: AClib 1.3.2, Alnuth 3.1.2, AtlasRep 2.1.0, AutoDoc 2019.09.04, \n",
" AutPGrp 1.10.2, CRISP 1.4.5, Cryst 4.1.23, CrystCat 1.1.9, \n",
" CTblLib 1.2.2, FactInt 1.6.3, FGA 1.4.0, GAPDoc 1.6.3, \n",
" IRREDSOL 1.4, LAGUNA 3.9.3, Polenta 1.3.9, Polycyclic 2.15.1, \n",
" PrimGrp 3.4.0, RadiRoot 2.8, ResClasses 4.7.2, SmallGrp 1.4.1, \n",
" Sophus 1.24, SpinSym 1.5.2, TomLib 1.2.9, TransGrp 2.0.5, \n",
" utils 0.69\n",
" Try '??help' for help. See also '?copyright', '?cite' and '?authors'\n"
]
},
{
"name": "stderr",
"output_type": "stream",
"text": [
"┌ Warning: Setting `POLYMAKE_CONFIG` to use a custom polymake installation is no longer supported. Please use `Overrides.toml` to override `polymake_jll` and `libpolymake_julia_jll`.\n",
"└ @ Polymake /home/mic/.julia/packages/Polymake/omVjG/src/Polymake.jl:89\n"
]
},
{
"name": "stdout",
"output_type": "stream",
"text": [
"polymake version 4.2\n",
"Copyright (c) 1997-2020\n",
"Ewgenij Gawrilow, Michael Joswig, and the polymake team\n",
"Technische Universität Berlin, Germany\n",
"https://polymake.org\n",
"\n",
"This is free software licensed under GPL; see the source for copying conditions.\n",
"There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.\n",
"\n",
" ----- ----- ----- - ----- \n",
"| | | | | | | | | | \n",
"| | | | | | | | \n",
"| | ----- | | | |----- \n",
"| | | | |-----| | | \n",
"| | | | | | | | | | \n",
" ----- ----- ----- - - - - \n",
"\n",
"...combining (and extending) ANTIC, GAP, Polymake and Singular\n",
"Version\u001b[32m 0.5.0 \u001b[39m... \n",
" ... which comes with absolutely no warranty whatsoever\n",
"Type: '?Oscar' for more information\n",
"(c) 2019-2020 by The Oscar Development Team\n"
]
},
{
"data": {
"text/plain": [
"Polymake"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"using OscarPolytope\n",
"import HomotopyContinuation\n",
"const HC = HomotopyContinuation\n",
"import Oscar\n",
"const PM = Polymake"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"\r",
"\u001b[32mTracking 18 paths... 100%|██████████████████████████████| Time: 0:00:05\u001b[39m\r\n",
"\u001b[34m # paths tracked: 18\u001b[39m\r\n",
"\u001b[34m # non-singular solutions (real): 18 (2)\u001b[39m\r\n",
"\u001b[34m # singular endpoints (real): 0 (0)\u001b[39m\r\n",
"\u001b[34m # total solutions (real): 18 (2)\u001b[39m\n"
]
},
{
"data": {
"text/plain": [
"Result with 18 solutions\n",
"========================\n",
"• 18 paths tracked\n",
"• 18 non-singular solutions (2 real)\n",
"• random_seed: 0x72a42ac9\n",
"• start_system: :polyhedral\n"
]
},
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# declare variables x and y\n",
"HC.@var x y\n",
"\n",
"# coefficents (should be nonzero)\n",
"a=3\n",
"b=-5\n",
"c=7\n",
"\n",
"# define the polynomials\n",
"f1 = a*x^3*y^2 + b*x + y^2 + 1\n",
"f2 = c*x*y^4 + x^3 + y\n",
"\n",
"I = HC.System([f1, f2])\n",
"result = HC.solve(I)"
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"18-element Array{Array{Complex{Float64},1},1}:\n",
" [1.340225711645152 + 0.9159833603576045im, 0.6590525482311473 - 0.3794165713690084im]\n",
" [-1.5100478578303818 + 0.747148406080495im, 0.7045914201772829 + 0.40141743901854726im]\n",
" [-0.02442606686413184 - 1.5916615157207026im, 0.004868431285595915 + 0.8120271592489284im]\n",
" [0.32382288015373734 - 3.851859888774472e-34im, -0.7495841367553178 + 0.0im]\n",
" [-1.4977914053203611 + 0.835403679367293im, -0.6669583945843404 - 0.42523554469922104im]\n",
" [-0.02560796504818028 - 1.6893260277716458im, -0.007105971404015341 - 0.7653188139169057im]\n",
" [-1.5100478578303818 - 0.7471484060804948im, 0.7045914201772829 - 0.4014174390185472im]\n",
" [1.3402257116451521 - 0.9159833603576046im, 0.6590525482311473 + 0.3794165713690084im]\n",
" [-0.025607965048180276 + 1.6893260277716458im, -0.007105971404015341 + 0.7653188139169057im]\n",
" [-1.4977914053203614 - 0.835403679367293im, -0.6669583945843404 + 0.4252355446992211im]\n",
" [1.3196957586419347 - 0.8127670055293637im, -0.7032022887072434 - 0.3565375703063238im]\n",
" [-0.024426066864131835 + 1.5916615157207026im, 0.004868431285595914 - 0.8120271592489284im]\n",
" [0.18218296898212613 + 0.14241428223397667im, 0.5756293626887855 + 0.6299648343167716im]\n",
" [0.20001311243612505 + 2.407412430484045e-35im, -0.008001579334804713 + 0.0im]\n",
" [1.3196957586419347 + 0.8127670055293635im, -0.7032022887072434 + 0.3565375703063238im]\n",
" [0.18218296898212613 - 0.14241428223397667im, 0.5756293626887855 - 0.6299648343167717im]\n",
" [-0.04614914050108896 + 0.08482395456275871im, -0.18808224964215126 - 1.123788634197406im]\n",
" [-0.04614914050108896 - 0.08482395456275872im, -0.18808224964215128 + 1.123788634197406im]"
]
},
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"HC.solutions(result)"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"2-element Array{Array{Float64,1},1}:\n",
" [0.32382288015373734, -0.7495841367553178]\n",
" [0.20001311243612505, -0.008001579334804713]"
]
},
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"HC.real_solutions(result)"
]
},
{
"cell_type": "code",
"execution_count": 5,
"metadata": {},
"outputs": [],
"source": [
"using ImplicitPlots, Plots\n",
"p = plot(legend=false);"
]
},
{
"cell_type": "code",
"execution_count": 6,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"image/svg+xml": [
"\n",
"\n"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"implicit_plot!(p, f1);\n",
"implicit_plot!(p, f2; linecolor=:red);\n",
"p"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"A Polyhedron with neither vertex nor face representation computed."
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"function hc_newton_polytope(f)\n",
" convex_hull(transpose(first(HC.exponents_coefficients(f, [x,y]))))\n",
"end\n",
"\n",
"P1 = hc_newton_polytope(f1)\n",
"P2 = hc_newton_polytope(f2)"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"polymake: used package ppl\n",
" The Parma Polyhedra Library ([[wiki:external_software#PPL]]): A C++ library for convex polyhedra\n",
" and other numerical abstractions.\n",
" http://www.cs.unipr.it/ppl/\n",
"\n"
]
},
{
"data": {
"text/plain": [
"(A = pm::Matrix\n",
"-1 0\n",
"0 -1\n",
"1 -1\n",
"0 1\n",
", b = pm::Vector\n",
"0 0 1 2)"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"facets(P1)"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"pm::Matrix\n",
"0 1 0\n",
"0 0 1\n",
"1 -1 1\n",
"2 0 -1\n"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"P1.pm_polytope.FACETS"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stderr",
"output_type": "stream",
"text": [
"polymake: used package cdd\n",
" cddlib\n",
" Implementation of the double description method of Motzkin et al.\n",
" Copyright by Komei Fukuda.\n",
" http://www-oldurls.inf.ethz.ch/personal/fukudak/cdd_home/\n",
"\n",
"polymake: used package lrs\n",
" Implementation of the reverse search algorithm of Avis and Fukuda.\n",
" Copyright by David Avis.\n",
" http://cgm.cs.mcgill.ca/~avis/C/lrs.html\n",
"\n"
]
},
{
"data": {
"text/plain": [
"pm::Vector\n",
"3 3"
]
},
"execution_count": 10,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"P2.pm_polytope.F_VECTOR"
]
},
{
"cell_type": "code",
"execution_count": 11,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"18"
]
},
"execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"PM.polytope.mixed_volume(P1.pm_polytope,P2.pm_polytope)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Julia 1.5.3",
"language": "julia",
"name": "julia-1.5"
},
"language_info": {
"file_extension": ".jl",
"mimetype": "application/julia",
"name": "julia",
"version": "1.5.3"
}
},
"nbformat": 4,
"nbformat_minor": 4
}