You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
|`expand_fraction`|`(+(~~xs)) / ~c => sum(x/~c for x in ~~xs)`| 1.5x | Segment variable `~~xs` works but `_apply_termwise` is leaner |
116
+
|`exp_to_trig`| Custom node function via `PassThrough`| 2500x (no-op) |`_apply_termwise` skips non-exp subtrees; `Postwalk` visits all |
117
+
118
+
These could become faster than manual code if expression sizes grow significantly
119
+
(100+ nodes) or if SymbolicUtils optimizes the rewriter overhead in the future.
120
+
121
+
### Potentially Worth Revisiting
122
+
123
+
| Function | Possible `@rule`| Why it might help |
124
+
|---|---|---|
125
+
|`trig_to_exp` (both `Num` and `BasicSymbolic` versions) |`@rule sin(~x)^~n => im^n * ((exp(-im*~x) - exp(im*~x))/2)^n` and similar for `cos`| Currently builds a substitution dict manually by iterating `get_all_terms` and filtering trigs. A `Postwalk` with two rules would be more declarative. Worth trying if `trig_to_exp` becomes a bottleneck. |
126
+
|`simplify_complex`|`@rule` on `Const`-wrapped complex with zero imaginary | Currently uses `_apply_termwise` + `unwrap_const`. A single rule could handle the leaf case but traversal still needed. |
127
+
|`is_trig`|`@capture` macro | Could use `@capture expr (sin(~x) or cos(~x))` instead of manual `ispow` + `operation` check. Cleaner but unlikely faster. |
128
+
129
+
### Not Candidates (complex logic, not pattern-based)
130
+
131
+
| Function | File | Why rules don't fit |
132
+
|---|---|---|
133
+
|`get_independent`|`Symbolics_utils.jl`| Requires semantic `is_function()` check per argument — each term needs a variable-dependence query, not a structural pattern match |
134
+
|`exp_to_trig` (inner logic) |`fourier.jl`| Sign normalization uses alphabetic ordering of `sorted_arguments` and `_has_negative_coefficient` heuristics — too stateful for a rule |
135
+
|`drop_powers`|`drop_powers.jl`| Uses algebraic ε-substitution strategy: replaces `var → ε*var`, expands, removes high powers of ε. Not tree-pattern-based at all |
136
+
|`_fourier_term`|`fourier.jl`| Multi-step pipeline: `trig_reduce` → `get_independent` → complex simplification. Orchestration logic, not a rewrite |
137
+
|`_get_all_terms`|`Symbolics_utils.jl`| Collects terms into a flat list — accumulation, not transformation |
0 commit comments