add https://github.com/LauraBMo/BudanTables.jl.git
or
import Pkg
Pkg.add(url="https://github.com/LauraBMo/BudanTables.jl.git")
Plots the Budan’s table of a polynomial (see https://hal.inria.fr/hal-00653762/document).
The type T
representing polynomials needs methods
BudanTables.degree(p::T)
andBudanTables.derivative(p::T, i::Int)
must be defined,- and it have to be compatible with the function
_ROOTS
computing roots (seeset_getting_roots
help).
The defaults are type Polynomial
and function Polynomials.roots
from Polynomials.jl.
But, if PolynomialRoots.jl is loaded, it uses PolynomialRoots.roots
(accepting polynomials of type Polynomial
).
using Plots
using Polynomials
using BudanTables
P = fromroots([0,0,1,2,2,4,4])
budantable(P)
using Plots
using Polynomials
using PolynomialRoots
using BudanTables
P = fromroots([0,0,1,2,2,4,4])
budantable(P)
Type Vector
and roots PolynomialRoots.roots
using Plots
using BudanTables
# Setting function to compute roots from a polynomial represented
# as a vector.
import PolynomialRoots
_BigFloat(A::AbstractArray) = BigFloat.(A)
# Notice we do not precompose by `coeffs`
set_getting_roots(PolynomialRoots.roots∘_BigFloat)
BudanTables.degree(v::AbstractVector) = length(v) - 1
BudanTables.derivative(v::AbstractVector) = .*(v[begin+1:end], 1:(length(v)-1))
function BudanTables.derivative(v::AbstractVector, i::Int)
out = copy(v)
while i > 0
i-=1
out = derivative(out)
end
return out
end
import Polynomials
P = Polynomials.coeffs(Polynomials.fromroots([0,0,1,2,2,4,4]))
budantable(P)