You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Recently I had a case, where simplify_fractions (and thus simplify in Symbolics.jl) fails.
@syms a::Real b::Real c::Real d::Real e::Realsimplify_fractions(1/ (4* a * b) * (4* (c + d) +4* e /3))
(c + d) / (a*b)
From what I could figure out, the problem originates in rm_gcds(ns, ds) where 4//1 is correctly identified as GCD but somewhere down the line (in MultivariatePolynomials.jl), div(4//3, 4//1) returns 0 such the the term with e disappears from the sum.
Maybe it would be an idea, to treat a rational divisor differently. The following code fixes the issue for the example above while the tests still pass.
_divide_by_divisor(x, y) =div(x, y)
_divide_by_divisor(x::PolyForm, y::Rational) =PolyForm{promote_symtype(/, symtype(x), symtype(y))}(
MP.map_coefficients(term -> term / y, x.p), x.pvar2sym, x.sym2term
)
functionrm_gcds(ns, ds)
ns =flatten_pows(ns)
ds =flatten_pows(ds)
for i =1:length(ns)
for j =1:length(ds)
g =_gcd(ns[i], ds[j])
if!_isone(g)
ns[i] =_divide_by_divisor(ns[i], g)
ds[j] =_divide_by_divisor(ds[j], g)
endendendfilter!(!_isone, ns)
filter!(!_isone, ds)
ns, ds
end
However, I'm sure that I miss something, my understanding of SymbolicUtils is extremely limited.
Since I am pretty new to Julia and this is the first time I try to contribute to an open source project, any advice how to proceed is warmly appreciated.
The text was updated successfully, but these errors were encountered:
Recently I had a case, where
simplify_fractions
(and thussimplify
in Symbolics.jl) fails.From what I could figure out, the problem originates in
rm_gcds(ns, ds)
where4//1
is correctly identified as GCD but somewhere down the line (in MultivariatePolynomials.jl),div(4//3, 4//1)
returns0
such the the term withe
disappears from the sum.Maybe it would be an idea, to treat a rational divisor differently. The following code fixes the issue for the example above while the tests still pass.
However, I'm sure that I miss something, my understanding of SymbolicUtils is extremely limited.
Since I am pretty new to Julia and this is the first time I try to contribute to an open source project, any advice how to proceed is warmly appreciated.
The text was updated successfully, but these errors were encountered: