Closed phpsmarter closed 2 years ago
I think you want to bypass Polynomials
, right? If so, I found this thread to be helpful:
julia> d = Symbolics.value(res).dict
Dict{Any, Number} with 2 entries:
λ^2 => 1
λ => 1
To get the constant, something akin to this would be needed:
julia> substitute(res, Dict(λ=>0))
-6
This set of commands could be used to get a Polynomial object:
julia> dd = Dict(Symbolics.degree(first(kv)) => kv[2] for kv ∈ d)
Dict{Int64, Int64} with 2 entries:
2 => 1
1 => 1
julia> dd[0] = substitute(res, Dict(λ=>0)).val
-6
julia> SparsePolynomial(dd, :λ)
SparsePolynomial(-6 + λ + λ^2)
That thread is a year old, perhaps there is another solution out there.
I think you want to bypass
Polynomials
, right? If so, I found this thread to be helpful:
Thanks. This is exactly what I want
let
@variables A,λ,I,x,poly
A=[3 0 2; 6 4 3; -4 0 -3]
I=diagm([1,1,1])
poly=(A-λ*I)|>det|>expand # characteristic polynomial of matrix
coffes_dict = Symbolics.value(poly).dict
dd = Dict(Symbolics.degree(first(kv)) => kv[2] for kv ∈ coffes_dict)
dd[0] = substitute(poly, Dict(λ=>0)).val
characteristicpoly= SparsePolynomial(dd, :λ)
roots=roots(characteristicpoly)
end
Hi, I'm closing this. Re-open if I read the conclusion wrong.
I want to write more algebraic style code , so do this
here is the code for eigen polynomials with pluto note
so , I can get eigen polynomial of matrices.
could get coefficients from symbolics expression directly?