giordano / PolynomialRoots.jl

Fast complex polynomial root finder, with support for arbitrary precision calculations
Other
53 stars 15 forks source link

Truncate polynomial if it has zeros in the trailing elements #12

Closed giordano closed 4 years ago

giordano commented 4 years ago

Before the PR:

julia> roots([1, -2, 1, 0, 0, 0])
5-element Array{Complex{Float64},1}:
               -0.0 - 0.0im               
               -0.0 - 0.0im               
 -6120.142457360636 + 1922.2699239774856im
  1.000000005275489 + 0.0im               
 0.9999999947245112 + 0.0im

After the PR:

julia> roots([1, -2, 1, 0, 0, 0])
2-element Array{Complex{Float64},1}:
 1.0 - 0.0im
 1.0 + 0.0im

julia> roots([0, 1, 4, 1, 0, 0, 0])
3-element Array{Complex{Float64},1}:
  -3.732050807568877 + 0.0im
 -0.2679491924311227 - 0.0im
                 0.0 + 0.0im

Fix #11 CC: @yhkalayci