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

Division

Open shashi opened this issue 5 years ago • 5 comments

  • [ ] 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.

shashi avatar Oct 23 '20 16:10 shashi

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?

MasonProtter avatar Nov 19 '20 18:11 MasonProtter

I agree, integer division should lead to term(Rational, ...)

shashi avatar Nov 19 '20 19:11 shashi

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.

MasonProtter avatar Nov 19 '20 20:11 MasonProtter

I think we should just treat / with Int like a rational, but not actually expose that to the outside code.

MasonProtter avatar Nov 19 '20 20:11 MasonProtter

That works too.

shashi avatar Nov 19 '20 20:11 shashi