Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Dimensions when intersecting #62

Open
wilrop opened this issue Jun 23, 2022 · 1 comment
Open

Dimensions when intersecting #62

wilrop opened this issue Jun 23, 2022 · 1 comment

Comments

@wilrop
Copy link

wilrop commented Jun 23, 2022

I'm having a problem with getting the dimensions right for the diagonal homotopy solver. In the example below, I define two sets of polynomials, where one contains some that are also in the other. Unless I understood it incorrectly, the dimension for the first set is 1 while it is zero for the second. However, when I do this the output is incorrect and gives me results for the variables a1, a2, b1, b2. If I set dim2 = 1, which I think is actually incorrect for this system, the output for the intersection is correct.

polys1 = ['a + b;']
polys2 = ['a + b;', 'a - 5;']
amb_dim = 2
dim1 = 1
dim2 = 0
emb1 = embed(amb_dim, dim1, polys1)
emb2 = embed(amb_dim, dim2, polys2)

sols1 = solve(emb1, verbose=False, precision='d')
sols2 = solve(emb2, verbose=False, precision='d')

emb1[0] = 'a + b - a - b + ' + emb1[0]
emb2[0] = 'a + b - a - b + ' + emb2[0]

polys, sols = diagsolve(amb_dim, dim1, emb1, sols1, dim2, emb2, sols2, prc='d', verbose=False)

print("Diagonal solutions")
for sol in sols:
    print(sol)

polys = ['a + b;', 'a - 5;']
dim3 = 0
emb = embed(amb_dim, dim3, polys)
sols = solve(emb, verbose=False, precision='d')

print("Regular solutions")
for sol in sols:
    print(sol)

Another example is the following,

polys1 = ['x + y + z;']
polys2 = ['z - 2;', 'x + y + z;']
amb_dim = 3
dim1 = 2
dim2 = 1
emb1 = embed(amb_dim, dim1, polys1)
emb2 = embed(amb_dim, dim2, polys2)

sols1 = solve(emb1, verbose=False, precision='d')
sols2 = solve(emb2, verbose=False, precision='d')

emb1[0] = 'x + y + z - x - y - z + ' + emb1[0]
emb2[0] = 'x + y + z - x - y - z + ' + emb2[0]

polys, sols = diagsolve(amb_dim, dim1, emb1, sols1, dim2, emb2, sols2, prc='d', verbose=False)

print("Diagonal solutions")
for sol in sols:
    print(sol)

polys = ['z - 2;', 'x + y + z;']
emb = embed(amb_dim, 1, polys)
sols = solve(emb, verbose=False, precision='d')

print("Regular solutions")
for sol in sols:
    print(sol)

When running this, it gives a solution of dimension 0 for the diagonal homotopy but of dimension 1 for the black box solver. Lastly, the following example gives me zero solutions for the diagonal homotopy but four for the black box solver.

polys1 = [
        '(3 * d * h + 1 * d * j + 9 * d * k + 9 * f * h + 5 * f * j + 3 * f * k + 5 * g * h + 2 * g * j + 1 * g * k) - (5 * d * h + 8 * d * j + 1 * d * k + 5 * f * h + 8 * f * j + 7 * f * k + 2 * g * h + 8 * g * j + 9 * g * k);',
        'b + c - 1;', 'd + f + g - 1;', 'h + j + k - 1;', 'a;']
polys2 = [
    '(3 * a * h + 5 * a * j + 2 * a * k + 6 * b * h + 8 * b * j + 7 * b * k + 4 * c * h + 7 * c * j + 3 * c * k) - (2 * a * h + 1 * a * j + 8 * a * k + 9 * b * h + 7 * b * j + 4 * b * k + 8 * c * h + 2 * c * j + 4 * c * k);',
    'a + b + c - 1;', 'd + g - 1;', 'h + j + k - 1;', 'f;']

amb_dim = 9

dim1 = 4
emb1 = embed(amb_dim, dim1, polys1)
sols1 = solve(emb1, verbose=False, precision='d')

dim2 = 4
emb2 = embed(amb_dim, dim2, polys2)
sols2 = solve(emb2, verbose=False, precision='d')

emb1[0] = 'a + b + c + d + f + g + h + j + k - a - b - c - d - f - g - h - j - k + ' + emb1[0]
emb2[0] = 'a + b + c + d + f + g + h + j + k - a - b - c - d - f - g - h - j - k + ' + emb2[0]

polys, sols = diagsolve(amb_dim, dim1, emb1, sols1, dim2, emb2, sols2, prc='d', verbose=False)

print("Diagonal solutions: ", len(sols))

polys3 = [
    '(3 * d * h + 1 * d * j + 9 * d * k + 9 * f * h + 5 * f * j + 3 * f * k + 5 * g * h + 2 * g * j + 1 * g * k) - (5 * d * h + 8 * d * j + 1 * d * k + 5 * f * h + 8 * f * j + 7 * f * k + 2 * g * h + 8 * g * j + 9 * g * k);',
    'b + c - 1;', 'h + j + k - 1;', 'a;', 'd + g - 1;', 'f;',
    '(3 * a * h + 5 * a * j + 2 * a * k + 6 * b * h + 8 * b * j + 7 * b * k + 4 * c * h + 7 * c * j + 3 * c * k) - (2 * a * h + 1 * a * j + 8 * a * k + 9 * b * h + 7 * b * j + 4 * b * k + 8 * c * h + 2 * c * j + 4 * c * k);',
]

dim = 2
emb = embed(amb_dim, dim, polys3)
sols = solve(emb, verbose=False)

print("Regular solutions: ", len(sols))

All of these examples have in common that some polynomials are overlapping or the same in both systems. I'm wondering then if the output for the diagonal homotopy is a bug or if I should be setting the dimensions differently? I have tried a lot of dimension configurations but anything I try leads to other problems.

I'm honestly completely stuck here, so if you could help me out I would greatly appreciate it!

@janverschelde
Copy link
Owner

Thanks for reporting this issue. Setting the verbose option to True in the blackbox solver gives different results, I will check this out.
To compute a witness set for one polynomial, there are more efficient methods available.
For example:

from phcpy.sets import witness_set_of_hypersurface as withyp
(p, s) = withyp(3, 'x+y+z;', 'd')

will return in p the embedded system and in s the witness points.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants