SymbolicUtils.jl
SymbolicUtils.jl copied to clipboard
Division
- [ ] make sure inv does not get introduced, only negative powers do.
- [X] simplify using exponent arithmetic
- [ ] put back
/after simplification so that there are no negative powers. OR: - [ ] have an optional argument which simplifies to a rational polynomial normal form i.e. (p / q) where p and q are "polynomials" in variables and non-linear functions of them.
Currently,
julia> @syms x
(x,)
julia> x / 37 |> simplify
0.02702702702702703 * x
I am starting to wonder if perhaps instead we should just carry around the / 37 rather than actually computing 1/37. It'd be more in line with other CAS and often gives outputs that are more meaningful. Sometimes the 1/37 is rather important.
People can of course use rationals if they wish, but I wonder if it'd be better for us to symbolically handle rationals for them. Thoughts?
I agree, integer division should lead to term(Rational, ...)
I'm actually not sure if it should lead to term(Rational, ...), because we don't want someone to use x/2 in their MTK code and then run build_function and end up with rationals where they expected fast floating point arithmetic.
I think we should just treat / with Int like a rational, but not actually expose that to the outside code.
That works too.