Пример #1
0
def top_cascade(nvr, dim, pols, tol, nbtasks=0, prc='d', verbose=True):
    r"""
    Constructs an embedding of the polynomials in *pols*,
    with the number of variables in *pols* equal to *nvr*,
    where *dim* is the top dimension of the solution set.
    Applies the blackbox solver to the embedded system.
    The tolerance *tol* is used to split the solution list in the list
    of generic points and the nonsolutions for use in the cascade.
    Returns a tuple with three items:

    1. the embedded system,

    2. the solutions with zero last coordinate w.r.t. *tol*,

    3. the solutions with nonzero last coordinate w.r.t. *tol*.

    The three parameters are

    1. *nbtasks* is the number of tasks, 0 if no multitasking;

    2. the working precision *prc*, 'd' for double, 'dd' for double double,
       or 'qd' for quad double;

    3. if *verbose*, then some output is written to screen.
    """
    from phcpy.sets import embed
    from phcpy.solver import solve
    topemb = embed(nvr, dim, pols)
    if verbose:
        print 'solving the embedded system at the top ...'
    topsols = solve(topemb, verbose=verbose, tasks=nbtasks, precision=prc)
    if verbose:
        print 'number of solutions found :', len(topsols)
    (sols0, sols1) = split_filter(topsols, dim, tol, verbose=verbose)
    return (topemb, sols0, sols1)
Пример #2
0
def top_cascade(nvr, dim, pols, tol, nbtasks=0, prc='d', verbose=True):
    r"""
    Constructs an embedding of the polynomials in *pols*,
    with the number of variables in *pols* equal to *nvr*,
    where *dim* is the top dimension of the solution set.
    Applies the blackbox solver to the embedded system.
    The tolerance *tol* is used to split the solution list in the list
    of generic points and the nonsolutions for use in the cascade.
    Returns a tuple with three items:

    1. the embedded system,

    2. the solutions with zero last coordinate w.r.t. *tol*,

    3. the solutions with nonzero last coordinate w.r.t. *tol*.

    The three parameters are

    1. *nbtasks* is the number of tasks, 0 if no multitasking;

    2. the working precision *prc*, 'd' for double, 'dd' for double double,
       or 'qd' for quad double;

    3. if *verbose*, then some output is written to screen.
    """
    from phcpy.sets import embed
    from phcpy.solver import solve
    topemb = embed(nvr, dim, pols)
    if verbose:
        print 'solving the embedded system at the top ...'
    topsols = solve(topemb, verbose=verbose, tasks=nbtasks, precision=prc)
    if verbose:
         print 'number of solutions found :', len(topsols)
    (sols0, sols1) = split_filter(topsols, dim, tol, verbose=verbose)
    return (topemb, sols0, sols1)
Пример #3
0
def test_monodromy(prc='d'):
    """
    Runs a test on applying monodromy loops
    to factor a curve into irreducible components.
    """
    from phcpy.solver import solve
    from phcpy.sets import embed
    pols = ['(x^2 - y)*(x-y);', 'x^3 - z;']
    embsys = embed(3, 1, pols, prc)
    # patch : make sure zz1 is last symbol!
    embsys[0] = 'x - x + y - y + z - z + ' + embsys[0]
    print(embsys)
    sols = solve(embsys, verbose=False, precision=prc)
    # for sol in sols: print sol
    print('the degree is', len(sols))
    monodromy_breakup(embsys, sols, 1, islaurent=0, verbose=True, prec=prc)
Пример #4
0
def test_monodromy(prc='d'):
    """
    Runs a test on applying monodromy loops
    to factor a curve into irreducible components.
    """
    from phcpy.solver import solve
    from phcpy.sets import embed
    pols = ['(x^2 - y)*(x-y);', 'x^3 - z;']
    embsys = embed(3, 1, pols, prc)
    # patch : make sure zz1 is last symbol!
    embsys[0] = 'x - x + y - y + z - z + ' + embsys[0]
    print(embsys)
    sols = solve(embsys, verbose=False, precision=prc)
    # for sol in sols: print sol
    print('the degree is', len(sols))
    monodromy_breakup(embsys, sols, 1, islaurent=0, verbose=True, prec=prc)
Пример #5
0
def make_witness_set(pols, verbose=True):
    """
    We have two equations in three variables in pols
    and therefore we expect a one dimensional set.
    """
    from phcpy.sets import embed
    from phcpy.solver import solve
    embpols = embed(3, 1, pols)
    if verbose:
        print 'the embedded system :'
        for pol in embpols:
            print pol
    embsols = solve(embpols, silent=not verbose)
    if verbose:
        print 'the witness points :'
        for sol in embsols:
            print sol
    return (embpols, embsols)
Пример #6
0
def witset(pols, verbose=True):
    """
    We have three equations in pols in five variables:
    x, y, s, L1, and L2.
    Therefore we expect a two dimensional set.
    """
    from phcpy.sets import embed
    from phcpy.solver import solve
    embpols = embed(5, 2, pols)
    if verbose:
        print 'the embedded system :'
        for pol in embpols:
            print pol
    embsols = solve(embpols, silent=not verbose)
    if verbose:
	print 'the witness points :'
        for sol in embsols:
            print sol
    return (embpols, embsols)
Пример #7
0
"""
Illustration of the witness set computation of the cyclic 4-roots system.
"""
from phcpy.families import cyclic
c4 = cyclic(4)
from phcpy.sets import embed
c4e1 = embed(4, 1, c4)
print 'the embedded cyclic 4-roots problem :'
for pol in c4e1:
    print pol
from phcpy.solver import solve
sols = solve(c4e1)
print 'computed', len(sols), 'solutions'
from phcpy.solutions import filter_zero_coordinates as filter
genpts = filter(sols, 'zz1', 1.0e-8, 'select')
print 'generic points :'
for sol in genpts:
    print sol
from phcpy.sets import membertest
sdpoint = [-1, 0, -1, 0, 1, 0, 1, 0]
print 'testing in standard double precision ...'
print membertest(c4e1, genpts, 1, sdpoint, verbose=True, precision='d')
raw_input('*** hit enter to continue ***')
print 'testing in double double precision ...'
ddpoint = [-1, 0, 0, 0, -1, 0, 0, 0, 1, 0, 0, 0, 1, 0, 0, 0]
print membertest(c4e1, genpts, 1, ddpoint, verbose=True, precision='dd')
raw_input('*** hit enter to continue ***')
print 'testing in quad double precision ...'
ddpoint = [-1, 0, 0, 0, 0, 0, 0, 0, \
           -1, 0, 0, 0, 0, 0, 0, 0, \
            1, 0, 0, 0, 0, 0, 0, 0, \
Пример #8
0
"""
As an extension of the witness set for the twisted cubic,
we consider the decomposition of the twisted cubic and line.
The decomposition is computed via monodromy on the witness
set for the one dimensional solution set.
"""
# f = ['(x^2 - y)*(y-0.5);', '(x^3 - z)*(z-0.5);']
f = ['x^2 - y;', 'x^3 - z;']
print 'polynomials that define an algebraic set:'
for pol in f:
    print pol
from phcpy.sets import embed, cascade_step
from phcpy.solver import solve
ef = embed(3, 1, f)
# patch : make sure zz1 is last symbol!
ef[0] = 'x - x + y - y + z - z + ' + ef[0]
efsols = solve(ef)
print 'degree of the set :', len(efsols)
from phcpy.sets import monodromy_breakup
monodromy_breakup(ef, efsols, 1)
Пример #9
0
"""
Making a witness set of the twisted cubic.
The twisted cubic is a curve in 3-space of degree 3,
defined as the intersection of a quadratic and a cubic cylinder.
Adding a random plane to the original system leads to three
generic points on the cubic.  These three points, jointly
with the embedded system form a witness set for the twisted cubic.
"""
twisted = ['x^2 - y;', 'x^3 - z;']
print 'polynomials that define the twisted cubic :'
for pol in twisted:
    print pol
from phcpy.sets import embed, cascade_step
from phcpy.solver import solve
et = embed(3, 1, twisted)
print 'polynomials in the embedded system :'
for pol in et:
    print pol
etsols = solve(et)
print 'the witness points :'
for point in etsols:
    print point