Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/make.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ makedocs(
"Extending" => "extending.md",
],
warnonly = [:cross_references, :missing_docs],
checkdocs=:exports,
)

deploydocs(repo = "github.com/JuliaMath/Polynomials.jl.git")
3 changes: 1 addition & 2 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -575,8 +575,7 @@ internally when converting to the `FactoredPolynomial` type:
julia> p = Polynomial([24, -50, 35, -10, 1])
Polynomial(24 - 50*x + 35*x^2 - 10*x^3 + x^4)

julia> q = convert(FactoredPolynomial, p) # noisy form of `factor`:
FactoredPolynomial((x - 4.0000000000000036) * (x - 1.0000000000000002) * (x - 2.9999999999999942) * (x - 2.0000000000000018))
julia> q = convert(FactoredPolynomial, p); # noisy form of `factor` subject to floating point vagaries

julia> map(x -> round(x, digits=10), q)
FactoredPolynomial((x - 4.0) * (x - 2.0) * (x - 3.0) * (x - 1.0))
Expand Down
3 changes: 3 additions & 0 deletions docs/src/reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ gcd
derivative
integrate
roots
residues
poles
companion
fit
vander
ArnoldiFit
```

## Plotting
Expand Down
6 changes: 3 additions & 3 deletions ext/PolynomialsRecipesBaseExt.jl
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ end

xlims = get(plotattributes, :xlims, (nothing, nothing))
ylims = get(plotattributes, :ylims, (nothing, nothing))
rational_function_trim(pq, a, b, xlims, ylims)
rational_function_trim(pq, a, b, xlims, ylims)

end

Expand All @@ -84,10 +84,10 @@ function rational_function_trim(pq, a, b, xlims, ylims)
dpq = derivative(p//q)
p′,q′ = lowest_terms(dpq)

λs = Multroot.multroot(q).values
λs = Polynomials.Multroot.multroot(q).values
λs = isempty(λs) ? λs : real.(filter(isapproxreal, λs))

cps = Multroot.multroot(p′).values
cps = Polynomials.Multroot.multroot(p′).values
cps = isempty(cps) ? cps : real.(filter(isapproxreal, cps))
cps = isempty(cps) ? cps : filter(!toobig(pq), cps)

Expand Down
2 changes: 1 addition & 1 deletion src/common.jl
Original file line number Diff line number Diff line change
Expand Up @@ -704,7 +704,7 @@ isconstant(p::AbstractPolynomial) = degree(p) <= 0 && firstindex(p) == 0
coeffs(::AbstractLaurentUnivariatePolynomial)

For a dense, univariate polynomial return the coefficients ``(a_0, a_1, \\dots, a_n)``
as an interable. This may be a vector or tuple, and may alias the
as an iterable. This may be a vector or tuple, and may alias the
polynomials coefficients.

For a Laurent type polynomial (e.g. `LaurentPolynomial`, `SparsePolynomial`) return the coefficients ``(a_i, a_{i+1}, \\dots, a_j)`` where
Expand Down
3 changes: 1 addition & 2 deletions src/polynomials/factored_polynomial.jl
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,7 @@ FactoredPolynomial(x * (x - 3) * (x - 1))
julia> p = Polynomial([24, -50, 35, -10, 1])
Polynomial(24 - 50*x + 35*x^2 - 10*x^3 + x^4)

julia> q = convert(FactoredPolynomial, p) # noisy form of `factor`:
FactoredPolynomial((x - 4.0000000000000036) * (x - 1.0000000000000002) * (x - 2.9999999999999942) * (x - 2.0000000000000018))
julia> q = convert(FactoredPolynomial, p); # noisy form of `factor`, subject to floating point issues

julia> map(x->round(x, digits=12), q) # map works over factors and leading coefficient -- not coefficients in the standard basis
FactoredPolynomial((x - 4.0) * (x - 2.0) * (x - 3.0) * (x - 1.0))
Expand Down
16 changes: 5 additions & 11 deletions src/polynomials/multroot.jl
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,14 @@ julia> using Polynomials
julia> p = fromroots([sqrt(2), sqrt(2), sqrt(2), 1, 1])
Polynomial(-2.8284271247461907 + 11.656854249492383*x - 19.07106781186548*x^2 + 15.485281374238573*x^3 - 6.242640687119286*x^4 + 1.0*x^5)

julia> roots(p)
5-element Vector{ComplexF64}:
0.999999677417768 + 0.0im
1.0000003225831504 + 0.0im
1.4141705716005881 + 0.0im
1.4142350577588914 - 3.722737728087131e-5im
1.4142350577588914 + 3.722737728087131e-5im
julia> roots(p) |> unique |> length # all are distinct
5

julia> m = Polynomials.Multroot.multroot(p);

julia> Dict(m.values .=> m.multiplicities)
Dict{Float64, Int64} with 2 entries:
1.41421 => 3
1.0 => 2
julia> ind = sortperm(m.values); ks = round.(m.values[ind];digits=6); vs = m.multiplicities[ind]; [ks .=> vs]
1-element Vector{Vector{Pair{Float64, Int64}}}:
[1.0 => 2, 1.414214 => 3]
```

## Extended help
Expand Down
Loading