Skip to content

Commit 4cf69e4

Browse files
authored
Merge pull request #398 from JuliaSymbolics/s/fix-pow-expansion
fix avoidance of exponentiation in simplify_fractions
2 parents 701ce7f + c9c85d7 commit 4cf69e4

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

src/polyform.jl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ end
244244

245245
function polyform_factors(d, pvar2sym, sym2term)
246246
make(xs) = map(xs) do x
247-
if x isa Pow && x.base isa Integer && x.exp > 0
247+
if x isa Pow && x.exp isa Integer && x.exp > 0
248248
# here we do want to recurse one level, that's why it's wrong to just
249249
# use Fs = Union{typeof(+), typeof(*)} here.
250250
Pow(PolyForm(x.base, pvar2sym, sym2term), x.exp)

test/polyform.jl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ end
5656
@eqtest simplify_fractions(3x^2/x^3) == 3/x
5757
@eqtest simplify_fractions(3*(x^2)*(y^3)/(3*(x^3)*(y^2))) == y/x
5858
@eqtest simplify_fractions(3*(x^x)/x*y) == 3*(x^x)/x*y
59+
60+
##404#issuecomment-939404030
61+
a = 1 / (x - (2//1)) + ((-5//1) - x) / ((x - (2//1))^2)
62+
@test isequal(simplify_fractions(a), -7/(x-2)^2)
5963
end
6064

6165
@testset "isone iszero" begin

0 commit comments

Comments
 (0)