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

add Exp rules

Open Roger-luo opened this issue 6 years ago • 3 comments

however I find this might be conflict with BASIC rules which evals the pi * im expression, is there a way to treat Irrationals differently?

Update: I changed the is_constant and printings for Irrational, it looks working now! should fix #81

Roger-luo avatar Sep 24 '19 06:09 Roger-luo

Codecov Report

Merging #80 into master will increase coverage by 4.3%. The diff coverage is 80%.

Impacted file tree graph

@@            Coverage Diff            @@
##           master      #80     +/-   ##
=========================================
+ Coverage   88.47%   92.78%   +4.3%     
=========================================
  Files           8        8             
  Lines         269      291     +22     
=========================================
+ Hits          238      270     +32     
+ Misses         31       21     -10
Impacted Files Coverage Δ
src/rules.jl 92.18% <100%> (+0.95%) :arrow_up:
src/utils.jl 75% <100%> (+8.33%) :arrow_up:
src/types.jl 90.9% <50%> (+7.18%) :arrow_up:
src/match.jl 97.01% <0%> (+0.34%) :arrow_up:
src/rule.jl 98.59% <0%> (+4.65%) :arrow_up:
src/properties.jl 71.42% <0%> (+9.89%) :arrow_up:
src/context.jl 88.88% <0%> (+12.41%) :arrow_up:

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update 4711ded...c6f3c40. Read the comment docs.

codecov-io avatar Sep 24 '19 06:09 codecov-io

it seems the rule of exp(2π * im) => 1 is not working when combined with :BASIC, since the definitions is

julia> dump(r)
PatternRule
  left: Term
    ex: Expr
      head: Symbol call
      args: Array{Any}((2,))
        1: exp (function of type typeof(exp))
        2: Expr
          head: Symbol call
          args: Array{Any}((3,))
            1: * (function of type typeof(*))
            2: Expr
              head: Symbol call
              args: Array{Any}((3,))
                1: * (function of type typeof(*))
                2: Int64 2
                3: Irrational{:π} π = 3.1415926535897...
            3: Complex{Bool}
              re: Bool false
              im: Bool true
  right: Term
    ex: Int64 1
  ps: Array{Function}((0,))

but after :BASIC, the * expression will be treated as associative operator which is a list of all args instead of the binary tree.

Roger-luo avatar Sep 25 '19 19:09 Roger-luo

I fixed this by defining it as exp(*(2, π, im)) => 1 but I'm wondering if there is some kind of better fix for associative operators?

Roger-luo avatar Sep 25 '19 20:09 Roger-luo