Beispiel #1
0
def test_track(silent=True, precision="d", decimals=80):
    """
    Tests the path tracking on a small random system.
    Two random trinomials are generated and random constants
    are added to ensure there are no singular solutions
    so we can use this generated system as a start system.
    The target system has the same monomial structure as
    the start system, but with random real coefficients.
    Because all coefficients are random, the number of
    paths tracked equals the mixed volume of the system.
    """
    from phcpy.solver import random_trinomials, real_random_trinomials
    from phcpy.solver import solve, mixed_volume, newton_step

    pols = random_trinomials()
    real_pols = real_random_trinomials(pols)
    from random import uniform as u

    qone = pols[0][:-1] + ("%+.17f" % u(-1, +1)) + ";"
    qtwo = pols[1][:-1] + ("%+.17f" % u(-1, +1)) + ";"
    rone = real_pols[0][:-1] + ("%+.17f" % u(-1, +1)) + ";"
    rtwo = real_pols[1][:-1] + ("%+.17f" % u(-1, +1)) + ";"
    start = [qone, qtwo]
    target = [rone, rtwo]
    start_sols = solve(start, silent)
    sols = track(target, start, start_sols, precision, decimals)
    mixvol = mixed_volume(target)
    print "mixed volume of the target is", mixvol
    print "number of solutions found :", len(sols)
    newton_step(target, sols, precision, decimals)
Beispiel #2
0
def compute_degree():
    """
    Prompts the user for the parameters m and L.
    Computes the degree of the cyclic n-roots set,
    for n = m**2*L.
    """
    (m, L, n) = ask_inputs()
    print 'The dimension n = %d**2*%d = %d.' % (m, L, n)
    coords = component_monomials(m, L)
    print 'monomial coordinates of a cyclic %d-roots component :' % n
    for c in coords:
        print c
    dim = m-1
    print 'dimension =', dim
    pol = ''
    for c in coords:
        pol = pol + c
    print pol
    sys = []
    for k in range(dim):
        sys.append(pol + ';')
    print sys
    from phcpy.solver import mixed_volume
    deg = mixed_volume(sys)
    print 'the degree of cyclic %d-roots set : %d' % (n, deg)
Beispiel #3
0
def degree(m, L):
    """
    Returns the degree of the cyclic n-roots solution set,
    for n = m**2*L.
    """
    coords = component_monomials(m, L)
    dim = m - 1
    pol = ''
    for c in coords:
        pol = pol + c
    sys = []
    for k in range(m - 1):
        sys.append(pol + ';')
    from phcpy.solver import mixed_volume
    deg = mixed_volume(sys)
    return deg
Beispiel #4
0
def degree(m, L):
    """
    Returns the degree of the cyclic n-roots solution set,
    for n = m**2*L.
    """
    coords = component_monomials(m, L)
    dim = m-1
    pol = ''
    for c in coords:
        pol = pol + c
    sys = []
    for k in range(m-1):
        sys.append(pol + ';')
    from phcpy.solver import mixed_volume
    deg = mixed_volume(sys)
    return deg