@@ -6,82 +6,135 @@ using HomotopyContinuation, DynamicPolynomials, LinearAlgebra
6
6
@polyvar x[1 : 3 ] p[1 : 10 ]
7
7
8
8
N = 1000
9
- results1_direct = fill (0 ,8 )
10
- results1_template = fill (0 ,8 )
11
- results2_direct = fill (0 ,8 )
12
- results2_template = fill (0 ,8 )
13
- results3_direct = fill (0 ,8 )
14
- results3_template = fill (0 ,8 )
15
- results4_direct = fill (0 ,8 )
16
- results4_template = fill (0 ,8 )
9
+ results1_direct = fill (0 , 8 )
10
+ results1_template = fill (0 , 8 )
11
+ results2_direct = fill (0 , 8 )
12
+ results2_template = fill (0 , 8 )
13
+ results3_direct = fill (0 , 8 )
14
+ results3_template = fill (0 , 8 )
15
+ results4_direct = fill (0 , 8 )
16
+ results4_template = fill (0 , 8 )
17
17
18
18
@time for i = 1 : N
19
- pol = [ - x[1 ]* x[3 ]* p[3 ] - x[1 ]* p[2 ] + p[1 ],
20
- x[1 ]* x[2 ]* x[3 ]* p[8 ]* p[9 ] + x[1 ]* x[3 ]* p[7 ]* p[8 ]* p[9 ] - x[2 ]* x[3 ]* p[5 ]* p[6 ] - x[2 ]* p[5 ]* p[6 ]* p[10 ] - x[2 ]* x[3 ]* p[4 ] - x[2 ]* p[4 ]* p[10 ],
21
- x[2 ] + x[3 ] - 1.0 ]
22
- p_vals = [0.04 ,0.04 ,1. ,1. ,10.0 ,0. ,0.04 ,35. ,.1 ,.04 ]
19
+ pol = [
20
+ - x[1 ] * x[3 ] * p[3 ] - x[1 ] * p[2 ] + p[1 ],
21
+ x[1 ] * x[2 ] * x[3 ] * p[8 ] * p[9 ] + x[1 ] * x[3 ] * p[7 ] * p[8 ] * p[9 ] -
22
+ x[2 ] * x[3 ] * p[5 ] * p[6 ] - x[2 ] * p[5 ] * p[6 ] * p[10 ] - x[2 ] * x[3 ] * p[4 ] -
23
+ x[2 ] * p[4 ] * p[10 ],
24
+ x[2 ] + x[3 ] - 1.0 ,
25
+ ]
26
+ p_vals = [0.04 , 0.04 , 1.0 , 1.0 , 10.0 , 0.0 , 0.04 , 35.0 , 0.1 , 0.04 ]
23
27
pol_pars = DynamicPolynomials. subs .(pol, Ref (p => p_vals))
24
- sol = solutions (solve (pol_pars, show_progress= false ))
25
- results1_direct[length (sol)+ 1 ] += 1
28
+ sol = solutions (solve (pol_pars, show_progress = false ))
29
+ results1_direct[length (sol)+ 1 ] += 1
26
30
27
31
p_template = randn (ComplexF64, 10 )
28
32
f_template = DynamicPolynomials. subs .(pol, Ref (p => p_template))
29
- result_template = solutions (solve (f_template, show_progress= false ))
30
- sol_again = solutions (solve (pol, result_template, parameters= p, p₁= p_template,
31
- p₀= ComplexF64 .(p_vals), show_progress= false ))
33
+ result_template = solutions (solve (f_template, show_progress = false ))
34
+ sol_again = solutions (
35
+ solve (
36
+ pol,
37
+ result_template,
38
+ parameters = p,
39
+ p₁ = p_template,
40
+ p₀ = ComplexF64 .(p_vals),
41
+ show_progress = false ,
42
+ ),
43
+ )
32
44
results1_template[length (sol_again)+ 1 ] += 1
33
45
34
- pol2 = [ - x[1 ]^ 5 * x[2 ]* p[5 ] + x[1 ]^ 4 * x[3 ]* p[6 ]* p[8 ] - x[1 ]* x[2 ]* p[3 ]^ 4 * p[5 ] + x[3 ]* p[3 ]^ 4 * p[6 ]* p[8 ] - x[1 ]^ 5 * p[7 ] + x[1 ]^ 4 * x[3 ]* p[4 ] - x[1 ]* p[3 ]^ 4 * p[7 ] + x[3 ]* p[3 ]^ 4 * p[4 ] + x[1 ]^ 4 * p[1 ] + x[1 ]^ 4 * p[2 ] + p[1 ]* p[3 ]^ 4 ,
35
- - x[1 ]^ 5 * x[2 ]* p[5 ] - x[1 ]* x[2 ]* p[3 ]^ 4 * p[5 ] - x[1 ]^ 4 * x[2 ]* p[7 ] + x[1 ]^ 4 * x[3 ]* p[4 ] - x[2 ]* p[3 ]^ 4 * p[7 ] + x[3 ]* p[3 ]^ 4 * p[4 ] + x[1 ]^ 4 * p[1 ] + x[1 ]^ 4 * p[2 ] + p[1 ]* p[3 ]^ 4 ,
36
- x[1 ]* x[2 ]* p[5 ] - x[3 ]* p[6 ]* p[8 ] - x[3 ]* p[4 ] - x[3 ]* p[7 ] ]
37
- p2_vals = [0.005 , 0.1 , 2.8 , 10 , 100 , 0.1 , 0.01 , 0. ]
46
+ pol2 = [
47
+ - x[1 ]^ 5 * x[2 ] * p[5 ] + x[1 ]^ 4 * x[3 ] * p[6 ] * p[8 ] - x[1 ] * x[2 ] * p[3 ]^ 4 * p[5 ] + x[3 ] * p[3 ]^ 4 * p[6 ] * p[8 ] - x[1 ]^ 5 * p[7 ] +
48
+ x[1 ]^ 4 * x[3 ] * p[4 ] - x[1 ] * p[3 ]^ 4 * p[7 ] +
49
+ x[3 ] * p[3 ]^ 4 * p[4 ] +
50
+ x[1 ]^ 4 * p[1 ] +
51
+ x[1 ]^ 4 * p[2 ] +
52
+ p[1 ] * p[3 ]^ 4 ,
53
+ - x[1 ]^ 5 * x[2 ] * p[5 ] - x[1 ] * x[2 ] * p[3 ]^ 4 * p[5 ] - x[1 ]^ 4 * x[2 ] * p[7 ] +
54
+ x[1 ]^ 4 * x[3 ] * p[4 ] - x[2 ] * p[3 ]^ 4 * p[7 ] +
55
+ x[3 ] * p[3 ]^ 4 * p[4 ] +
56
+ x[1 ]^ 4 * p[1 ] +
57
+ x[1 ]^ 4 * p[2 ] +
58
+ p[1 ] * p[3 ]^ 4 ,
59
+ x[1 ] * x[2 ] * p[5 ] - x[3 ] * p[6 ] * p[8 ] - x[3 ] * p[4 ] - x[3 ] * p[7 ],
60
+ ]
61
+ p2_vals = [0.005 , 0.1 , 2.8 , 10 , 100 , 0.1 , 0.01 , 0.0 ]
38
62
pol2_pars = DynamicPolynomials. subs .(pol2, Ref (p => p2_vals))
39
- sol2 = solutions (solve (pol2_pars, show_progress= false ))
40
- results2_direct[length (sol2)+ 1 ] += 1
63
+ sol2 = solutions (solve (pol2_pars, show_progress = false ))
64
+ results2_direct[length (sol2)+ 1 ] += 1
41
65
42
66
p2_template = randn (ComplexF64, 8 )
43
67
f2_template = DynamicPolynomials. subs .(pol2, Ref (p => p2_template))
44
- solve_templ2 = solve (f2_template, show_progress= false )
68
+ solve_templ2 = solve (f2_template, show_progress = false )
45
69
result2_template = solutions (solve_templ2)
46
- sol2_again = solutions (solve (pol2, result2_template, precision= PRECISION_ADAPTIVE, parameters= p[1 : 8 ], p₁= p2_template, p₀= ComplexF64 .(p2_vals), show_progress= false ))
70
+ sol2_again = solutions (
71
+ solve (
72
+ pol2,
73
+ result2_template,
74
+ precision = PRECISION_ADAPTIVE,
75
+ parameters = p[1 : 8 ],
76
+ p₁ = p2_template,
77
+ p₀ = ComplexF64 .(p2_vals),
78
+ show_progress = false ,
79
+ ),
80
+ )
47
81
48
- results2_template[length (sol2_again)+ 1 ] += 1
82
+ results2_template[length (sol2_again)+ 1 ] += 1
49
83
50
84
pol3 = pol2
51
- p3_vals = [0.005 , 0.1 , 2.8 , 10 , 100 , 0.1 , 0.01 , 1. ] # Last parameter is 1 and not 0. Here there should be 3 real solutions instead of 1.
85
+ p3_vals = [0.005 , 0.1 , 2.8 , 10 , 100 , 0.1 , 0.01 , 1.0 ] # Last parameter is 1 and not 0. Here there should be 3 real solutions instead of 1.
52
86
pol3_pars = DynamicPolynomials. subs .(pol3, Ref (p => p3_vals))
53
- sol3 = solutions (solve (pol3_pars, precision= PRECISION_ADAPTIVE, show_progress= false ))
54
- results3_direct[length (sol3)+ 1 ] += 1
87
+ sol3 =
88
+ solutions (solve (pol3_pars, precision = PRECISION_ADAPTIVE, show_progress = false ))
89
+ results3_direct[length (sol3)+ 1 ] += 1
55
90
56
91
p3_template = randn (ComplexF64, 8 )
57
92
f3_template = DynamicPolynomials. subs .(pol3, Ref (p => p3_template))
58
- result3_template = solutions (solve (f3_template, show_progress= false ))
59
- sol3_again = solutions (solve (pol3, result3_template, parameters= p[1 : 8 ], p₁= p3_template, p₀= ComplexF64 .(p3_vals), show_progress= false ))
60
- results3_template[length (sol3_again)+ 1 ] += 1
93
+ result3_template = solutions (solve (f3_template, show_progress = false ))
94
+ sol3_again = solutions (
95
+ solve (
96
+ pol3,
97
+ result3_template,
98
+ parameters = p[1 : 8 ],
99
+ p₁ = p3_template,
100
+ p₀ = ComplexF64 .(p3_vals),
101
+ show_progress = false ,
102
+ ),
103
+ )
104
+ results3_template[length (sol3_again)+ 1 ] += 1
61
105
62
- pol4 = [- x[1 ]^ 3 * p[3 ] - x[1 ]* p[2 ]^ 2 * p[3 ] + x[1 ]^ 2 * p[1 ]]
63
- p4_vals = [1. , 0.2 , 1. ];
106
+ pol4 = [- x[1 ]^ 3 * p[3 ] - x[1 ] * p[2 ]^ 2 * p[3 ] + x[1 ]^ 2 * p[1 ]]
107
+ p4_vals = [1.0 , 0.2 , 1.0 ]
64
108
pol4_pars = DynamicPolynomials. subs .(pol4, Ref (p => p4_vals))
65
- sol4 = solutions (solve (pol4_pars, show_progress= false ))
66
- results4_direct[length (sol4)+ 1 ] += 1
109
+ sol4 = solutions (solve (pol4_pars, show_progress = false ))
110
+ results4_direct[length (sol4)+ 1 ] += 1
67
111
68
112
p4_template = randn (ComplexF64, 3 )
69
113
f4_template = DynamicPolynomials. subs .(pol4, Ref (p => p4_template))
70
- result4_template = solutions (solve (f4_template, show_progress= false ))
71
- sol4_again = solutions (solve (pol4, result4_template, parameters= p[1 : 3 ], p₁= p4_template, p₀= ComplexF64 .(p4_vals), show_progress= false ))
72
- results4_template[length (sol4_again)+ 1 ] += 1
114
+ result4_template = solutions (solve (f4_template, show_progress = false ))
115
+ sol4_again = solutions (
116
+ solve (
117
+ pol4,
118
+ result4_template,
119
+ parameters = p[1 : 3 ],
120
+ p₁ = p4_template,
121
+ p₀ = ComplexF64 .(p4_vals),
122
+ show_progress = false ,
123
+ ),
124
+ )
125
+ results4_template[length (sol4_again)+ 1 ] += 1
73
126
end
74
127
75
128
# These numbers should all coincide
76
129
println (" Results for the first system" )
77
130
println (results1_direct)
78
- println (results1_template," \n " )
131
+ println (results1_template, " \n " )
79
132
println (" Results for the second system" )
80
133
println (results2_direct)
81
- println (results2_template," \n " )
134
+ println (results2_template, " \n " )
82
135
println (" Results for the third system" )
83
136
println (results3_direct)
84
- println (results3_template," \n " )
137
+ println (results3_template, " \n " )
85
138
println (" Results for the fourth system" )
86
139
println (results4_direct)
87
140
println (results4_template)
0 commit comments