File tree Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Expand file tree Collapse file tree 2 files changed +12
-1
lines changed Original file line number Diff line number Diff line change @@ -136,6 +136,14 @@ function term_matcher_constructor(term, acSets)
136
136
result = loop (data, bindings, matchers)
137
137
result != = nothing && return success (result, 1 )
138
138
139
+ # if data is of the alternative form (1/...)^(...), it might match with negative exponent
140
+ if (operation (data) === ^ ) && iscall (arguments (data)[1 ]) && (operation (arguments (data)[1 ]) === / ) && isequal (arguments (arguments (data)[1 ])[1 ], 1 )
141
+ one_over_smth = arguments (data)[1 ]
142
+ T = symtype (one_over_smth)
143
+ frankestein = Term {T} (^ , [arguments (one_over_smth)[2 ], - arguments (data)[2 ]])
144
+ result = loop (frankestein, bindings, matchers)
145
+ result != = nothing && return success (result, 1 )
146
+ end
139
147
# if data is of the alternative form 1/(...)^(...), it might match with negative exponent
140
148
if (operation (data) === / ) && isequal (arguments (data)[1 ], 1 ) && iscall (arguments (data)[2 ]) && (operation (arguments (data)[2 ]) === ^ )
141
149
denominator = arguments (data)[2 ]
Original file line number Diff line number Diff line change 109
109
@test r_mixmix (exp (x)* sin (x+ x^ 2 )) === (1 , 0 , x)
110
110
end
111
111
112
- @testset " 1/ power matches power with exponent of opposite sign " begin
112
+ @testset " power matcher with negative exponent " begin
113
113
r1 = @rule (~ x)^ (~ y) => (~ x, ~ y) # rule with slot as exponent
114
114
@test r1 (1 / a^ b) === (a, - b) # uses frankestein
115
115
@test r1 (1 / a^ (b+ 2 c)) === (a, - b- 2 c) # uses frankestein
124
124
@test r1defslot (1 / a^ (b+ 2 c)) === (a, - b- 2 c) # uses frankestein
125
125
@test r1defslot (1 / a^ 2 ) === (a, - 2 ) # uses opposite_sign_matcher
126
126
@test r1defslot (a) === (a, 1 )
127
+
128
+ r = @rule (~ x + ~ y)^ (~ m) => (~ x, ~ y, ~ m) # rule to match (1/...)^(...)
129
+ @test r ((1 / (a+ b))^ 3 ) === (a,b,- 3 )
127
130
end
128
131
129
132
using SymbolicUtils: @capture
You can’t perform that action at this time.
0 commit comments