JuliaSymbolics / SymbolicUtils.jl

Symbolic expressions, rewriting and simplification
https://docs.sciml.ai/SymbolicUtils/stable/
Other
536 stars 107 forks source link

Add rules to simplify exponentials. #382

Closed kllrak closed 2 years ago

kllrak commented 2 years ago

This PR attempts to resolve https://github.com/JuliaSymbolics/SymbolicUtils.jl/issues/182#issuecomment-768843602.

Without the _iszero check, the first added rule can result in 1.0 instead of 1 when the exponentials cancel. I'm fine with changing this if it is too fancy. The second added rule implements https://github.com/JuliaSymbolics/SymbolicUtils.jl/issues/182#issuecomment-766427681. I lumped exp in with the trig functions for the control flow of the default simplifier.

shashi commented 2 years ago

Nice, thanks!

the _iszero check

seems fine.

codecov-commenter commented 2 years ago

Codecov Report

Merging #382 (a321227) into master (48cc5ff) will decrease coverage by 0.33%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #382      +/-   ##
==========================================
- Coverage   83.70%   83.36%   -0.34%     
==========================================
  Files          12       12              
  Lines        1479     1479              
==========================================
- Hits         1238     1233       -5     
- Misses        241      246       +5     
Impacted Files Coverage Δ
src/simplify_rules.jl 81.81% <100.00%> (ø)
src/utils.jl 58.65% <100.00%> (ø)
src/polyform.jl 92.76% <0.00%> (-1.36%) :arrow_down:
src/ordering.jl 89.53% <0.00%> (-1.17%) :arrow_down:
src/code.jl 80.55% <0.00%> (-0.56%) :arrow_down:

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 48cc5ff...a321227. Read the comment docs.