SymEngine.jl icon indicating copy to clipboard operation
SymEngine.jl copied to clipboard

get the (numeric) coefficent of a specified symbol in an expression

Open fandengdong opened this issue 6 years ago • 0 comments

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!

fandengdong avatar Aug 05 '19 09:08 fandengdong