next | previous | forward | backward | up | top | index | toc | Macaulay2 web site
PHCpack :: phcSolve

phcSolve -- a black-box solver, which returns approximations to all complex isolated roots of a polynomial system; invokes "phc -b" from PHCpack

Synopsis

Description

Suppose we would like to compute the numerical solutions to the following system which lives in the polynomical ring with 3 variables.
i1 : R=QQ[x,y,z]

o1 = R

o1 : PolynomialRing
i2 : S={x+y+z-1,x^2+y^2,x+y-z-3}

                      2    2
o2 = {x + y + z - 1, x  + y , x + y - z - 3}

o2 : List
We call PHCpack’s blackbox solver.
i3 : printWidth = 300 -- want output to fit on one line

o3 = 300
i4 : L=phcSolve(S)
using temporary file name /tmp/M2-7473-1PHCinput

o4 = {{1+ii, 1-ii, -1}, {1-ii, 1+ii, -1}}

o4 : List
Notice that in addition to the values of the three variables, the hashtable for each solution contains the following keys for diagnostics: err, the magnitude of the last correction term used in Newton’s method; mult, the multiplicity of the solution; rco, estimate for the inverse condition of the root; residual, the maginitude of the system when evaluated at the given solution; and time, the end value of the continuation parameter, if t=1 then the solver reached the end of the path properly.

A brief discussion on the dimension of the system is in place. If we try to run: we get an error. This is because the code does not check for dimension of the system; it checks for number of equations instead. The dimension computation is extremely expensive.

One way to solve problems to make the system and then use only minimal generators of the ideal by using "mingens". Here is a second system which is square, but has a free variable anyway (x) :
i5 : I=ideal(y-x^2,z-x^3,x^2-y)

               2         3       2
o5 = ideal (- x  + y, - x  + z, x  - y)

o5 : Ideal of R
i6 : dim I

o6 = 1
the system is not zero-dimensional (there is a free variable!!); but the code does not know that; since we have the system is “square”...
i7 : system = flatten entries gens I

         2         3       2
o7 = {- x  + y, - x  + z, x  - y}

o7 : List
i8 : vol = mixedVolume(system) --this returns zero, but that's not informative!
using temporary file name /tmp/M2-7473-2PHCinput

o8 = 0
i9 : phcSolve(system)
using temporary file name /tmp/M2-7473-3PHCinput

o9 = {(2.11183e-16-9.35296e-16*ii, -8.92359e-31-4.8099e-32*ii, 6.62326e-30-6.32352e-30*ii)}

o9 : List
however, i get a different error message when i prune the generators:
i10 : numgens I

o10 = 3
i11 : numgens ring I

o11 = 3
i12 : numcols mingens I --not all generators are minimal.

o12 = 2

Thus, if you are not sure if you have a *truly* square (or overdetermined system), that is, if you want to make sure the system is not positive dimensional (underdetermined), you can check this by getting rid of the non-minimal generators of the ideal (note: here we use "mingens" which returns a matrix; we could have used "trim" which returns an ideal)

In case we need slack variables:
i13 : dim trim I

o13 = 1
Also, if the system is overdetermined, then the code inserts slack variables, so it still works:
i14 : system={y-x^2, z-x^3,x+y+z-1,x+y+ x^3 -1}

          2         3                      3
o14 = {- x  + y, - x  + z, x + y + z - 1, x  + x + y - 1}

o14 : List
i15 : #system > numcols vars R --overdetermined system

o15 = true
i16 : solns =phcSolve(system); --but code still works (slack vars)
using temporary file name /tmp/M2-7473-4PHCinput
i17 : numSolns = #solns

o17 = 3

Ways to use phcSolve :