Open xiang-yu opened 1 year ago
The second argument of Symbolics.degree
should be a single symbolic variable or just nothing
.
(@v1.8) pkg> st -m Symbolics
Status `~/.julia/environments/v1.8/Manifest.toml`
[0c5d862f] Symbolics v4.13.0
julia> using Symbolics
help?> Symbolics.degree
degree(p, sym=nothing)
Extract the degree of p with respect to sym.
julia> x = @variables x1, x2
2-element Vector{Num}:
x1
x2
julia> y = x1 * x2
x1*x2
julia> Symbolics.degree(y)
2
julia> Symbolics.degree(y, x1)
1
julia> Symbolics.degree(y, x2)
1
julia> Symbolics.degree.(y, x) # element-wise
2-element Vector{Int64}:
1
1
Symbolics.degree
can only compute the degree with respect to either one single symbolic variable or all symbolic variables.
Thanks a lot! Symbolics.degree(y) works like a charm.
I try to get the degree of a multivariate polynomials (*y=x1x2) using Symbolics.degree, but I got unexpected values. I must misunderstood the function Symbolics.degree. At any rate, could you please point me to the Symbolics function that can return a degree of 2**?
julia> using Symbolic julia> x = @variables x1, x2 julia> y=x[1]*x[2] julia> Symbolics.degree(y,x) 0
julia> Symbolics.degree.(y,x) 2-element Vector{Int64}: 1 1
I am expecting 2 though.