-
Notifications
You must be signed in to change notification settings - Fork 154
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Simplified derivative expansion gives float coefficients #1083
Comments
It's a bug, we should find how what causes it. |
Here is the most minimal example I am able to reduce it to: using Symbolics
@variables a b
simplify(a/b + 2*a^2/b) This outputs With |
Possibly, and then it evaluates the fraction with |
I've done some digging. It seems that even using SymbolicUtils
@syms x
pf = PolyForm(x) # polynomial 1*x^1
div(pf, pf) # x / x outputs Digging into in SymbolicUtils.jl's polyform.jl, it seems that it ultimately relies on DynamicPolynomials.jl to do the division. There is an identical open/unresolved issue in that library. But it seems to me that this SymbolicUtils.jl commit was made to provide a workaround? What is the way to go about this? I suppose the ideal way would be to fix it upstream? |
All examples in this issue would be fixed by JuliaAlgebra/MultivariatePolynomials.jl#294. |
This was fixed by JuliaAlgebra/MultivariatePolynomials.jl/pull/296 😃 using Symbolics
@variables t a(t)
D(expr) = expand_derivatives(Differential(t)(expr))
simplify_fractions(D(D(a)/a) + D(D(a)/a)) now gives rational coefficients: ((2//1)*a(t)*Differential(t)(Differential(t)(a(t))) - (2//1)*(Differential(t)(a(t))^2)) / (a(t)^2) Similarly, using Symbolics
@variables a b
simplify(a/b + 2*a^2/b) gives (a + (2//1)*(a^2)) / b |
The simplified derivative expansion
outputs
Why are the coefficients
2.0
instead of2
? I would like them to be exact integers/rationals instead of floats. Thanks!The text was updated successfully, but these errors were encountered: