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

coeff not producing correct output

Open amcostant opened this issue 6 years ago • 3 comments

When I run coeff without expand I get

julia> coeff.((1 + h)*x_2*(h^2*t^2*Umax + 2*h*t*(1 + h)*x_2),t,0:3)
4-element Array{Basic,1}:
 0
 0
 0
 0

but when I run expand first I get the correct result

julia> coeff.(expand((1 + h)*x_2*(h^2*t^2*Umax + 2*h*t*(1 + h)*x_2)),t,0:3)
4-element Array{Basic,1}:
                                     0
 2*h*x_2^2 + 4*h^2*x_2^2 + 2*h^3*x_2^2
           h^2*x_2*Umax + h^3*x_2*Umax
                                     0

amcostant avatar Jul 17 '19 03:07 amcostant

@isuruf The issue also extends to problems where the 0th order coefficient is an Int, Float, or Rational. Here is a very basic example

julia> coeff.(-1//2*Basic(1)+t,t,0:3)
4-element Array{Basic,1}:
 0
 1
 0
 0

julia> coeff.(-1//2*Basic(1),t,0:3)
4-element Array{Basic,1}:
 -1/2
    0
    0
    0

amcostant avatar Aug 15 '19 01:08 amcostant

I think I fixed this in https://github.com/symengine/symengine/commit/c853166c1e5cada03a07112c5fca89de991ba14b

isuruf avatar Aug 15 '19 02:08 isuruf

is the current Julia build v0.7.0 using that version of Symengine?

amcostant avatar Aug 15 '19 02:08 amcostant