Skip to content

Commit dd1f2c1

Browse files
Merge pull request #3517 from AayushSabharwal/as/hc-test
test: make homotopy continuation test more robust
2 parents 547cb4e + 6a5a885 commit dd1f2c1

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

test/extensions/homotopy_continuation.jl

+5-5
Original file line numberDiff line numberDiff line change
@@ -151,22 +151,22 @@ end
151151
@variables x=0.25 y=0.125
152152
a = sin(x^2 - 4x + 1)
153153
b = cos(3log(y) + 4)
154-
@mtkbuild sys = NonlinearSystem([(a^2 - 4a * b + 4b^2) / (a - 0.25) ~ 0
154+
@mtkbuild sys = NonlinearSystem([(a^2 - 5a * b + 6b^2) / (a - 0.25) ~ 0
155155
(a^2 - 0.75a + 0.125) ~ 0])
156156
prob = HomotopyContinuationProblem(sys, [])
157157
@test prob[x] 0.25
158158
@test prob[y] 0.125
159159
sol = solve(prob, allrootsalg).u[1]
160160
@test SciMLBase.successful_retcode(sol)
161161
@test sol[a]0.5 atol=1e-6
162-
@test sol[b]0.25 atol=1e-6
162+
@test isapprox(sol[b], 0.25; atol = 1e-6) || isapprox(sol[b], 0.5 / 3; atol = 1e-6)
163163
end
164164

165165
@testset "Rational functions" begin
166166
@variables x=2.0 y=2.0
167-
@parameters n = 4
167+
@parameters n = 5
168168
@mtkbuild sys = NonlinearSystem([
169-
0 ~ (x^2 - n * x + n) * (x - 1) / (x - 2) / (x - 3)
169+
0 ~ (x^2 - n * x + 6) * (x - 1) / (x - 2) / (x - 3)
170170
])
171171
prob = HomotopyContinuationProblem(sys, [])
172172
sol = solve_allroots_closest(prob)
@@ -184,7 +184,7 @@ end
184184
0 ~ ((y - 3) / (y - 4)) * (n / (y - 5)) + ((x - 1.5) / (x - 5.5))^2
185185
],
186186
[x, y],
187-
[n])
187+
[n]; defaults = [n => 4])
188188
sys = complete(sys)
189189
prob = HomotopyContinuationProblem(sys, [])
190190
sol = solve(prob, singlerootalg)

0 commit comments

Comments
 (0)