JuliaSymbolics / SymbolicUtils.jl

Symbolic expressions, rewriting and simplification
https://docs.sciml.ai/SymbolicUtils/stable/
Other
545 stars 114 forks source link

integer division error in `simplify_fractions` #350

Closed shashi closed 3 years ago

shashi commented 3 years ago
julia> @syms a b c d e f g h i
(a, b, c, d, e, f, g, h, i)

julia> ex = ex = (d + g*d) / (d^2)
(d + g*d) / (d^2)

julia> SymbolicUtils.simplify_div(ex)
ERROR: DivideError: integer division error
Stacktrace:
  [1] div
    @ ./int.jl:261 [inlined]
  [2] _operate_exponents_to!(output::Vector{Int64}, op::typeof(div), z1::Vector{Int64}, z2::Vector{Int64}, n::Int64, maps::Vector{Vector{Int64}})
    @ DynamicPolynomials ~/.julia/dev/DynamicPolynomials/src/cmult.jl:42
  [3] multdivmono!(output::Vector{Int64}, output_variables::Vector{DynamicPolynomials.PolyVar{true}}, v::Vector{DynamicPolynomials.PolyVar{true}}, x::DynamicPolynomials.Monomial{true}, op::Function, z::Vector{Int64})
    @ DynamicPolynomials ~/.julia/dev/DynamicPolynomials/src/cmult.jl:72
  [4] mapexponents!
    @ ~/.julia/dev/DynamicPolynomials/src/cmult.jl:117 [inlined]
  [5] operate
    @ ~/.julia/dev/MultivariatePolynomials/src/gcd.jl:187 [inlined]
  [6] deflate(p::DynamicPolynomials.Monomial{true}, shift::DynamicPolynomials.Monomial{true}, defl::DynamicPolynomials.Monomial{true})
    @ MultivariatePolynomials ~/.julia/dev/MultivariatePolynomials/src/gcd.jl:171
  [7] gcd(p1::DynamicPolynomials.Polynomial{true, Int64}, p2::DynamicPolynomials.Monomial{true}, algo::MultivariatePolynomials.GeneralizedEuclideanAlgorithm)
    @ MultivariatePolynomials ~/.julia/dev/MultivariatePolynomials/src/gcd.jl:122
  [8] gcd
    @ ~/.julia/dev/MultivariatePolynomials/src/gcd.jl:107 [inlined]
  [9] _gcd(x::DynamicPolynomials.Polynomial{true, Int64}, y::DynamicPolynomials.Monomial{true})
    @ SymbolicUtils ~/.julia/dev/SymbolicUtils/src/polyform.jl:304
 [10] gcd(x::PolyForm{Number, Nothing}, y::PolyForm{Number, Nothing})
shashi commented 3 years ago

Moved here https://github.com/JuliaAlgebra/MultivariatePolynomials.jl/issues/173