SymEngine.jl
SymEngine.jl copied to clipboard
get the (numeric) coefficent of a specified symbol in an expression
Is there a funcion to get the coefficent of a specified symbol in an expression, for example
julia> using SymEngine
julia> x, y = symbols("x y")
(x, y)
julia> y = (2*x+1)^3
(1 + 2*x)^3
julia> y_expand = expand(y)
1 + 6*x + 12*x^2 + 8*x^3
If we want to get the coefficent of x^2
, than we have a function
get_coefficent(x^2, y)
or get_coefficent(x^2, y_expand)
. Then the function return 12
.
I think this is a basis function. Thank you very much!