Skip to content

Commit

Permalink
Increase precision to isolate roots
Browse files Browse the repository at this point in the history
  • Loading branch information
mgkurtz committed Jun 9, 2023
1 parent 8b9ca36 commit 7566819
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/Misc/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -853,7 +853,14 @@ function _n_positive_roots_sqf(f::PolyElem{nf_elem}, P::NumFieldEmb; start_prec:
coeffs[i + 1] = evaluate(coeff(f, i), P, prec)
end
g = Cx(coeffs)
rts = real.(Hecke.roots(g))
try
rts = Hecke.roots(g)
catch e
startswith(e.msg, "unable to isolate all roots") || rethrow()
prec *= 2
continue
end
rts = real.(rts)
if any(contains_zero, rts)
prec = 2 * prec
else
Expand Down
9 changes: 9 additions & 0 deletions test/Misc/Poly.jl
Original file line number Diff line number Diff line change
Expand Up @@ -147,3 +147,12 @@ end
f = x^8 + 319*x^7 + 1798*x^6 + 1177*x^5 + 1083*x^4 + 2070*x^3 + 2075*x^2 + 1937*x + 1896
@test collect(Hecke.lazy_factor(f)) == [f]
end

@testset "isolating roots" begin
QQx, x = QQ[:x]
QQ1, _ = number_field(x-1)
P = only(infinite_places(QQ1))
QQ1y, y = QQ1[:y]
n = Hecke.n_positive_roots((y-1//10000)*(y-2//10000)*(y-100), Hecke.embedding(P))
@test n == 3
end

0 comments on commit 7566819

Please sign in to comment.