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

substitutions for powers and fractions

Open kjellqvist opened this issue 2 years ago • 0 comments

Hi, Certain substitutions do not work the way I would expect. For example:

@variables x y
eq1 = (1/x)^2
substitute(eq1, Dict([1/x => y]))
julia> y^2

eq2 = 1/x^2
substitute(eq2, Dict([1/x => y]))
julia> 1 / (x^2)

I expected the answers to be equivalent.

Fractions aren't handled the way I would expect either:

@variables x y z
eq3 = x/y
substitute(eq3, Dict([1/y => z]))
julia> x/y

Finally, substitution doesn't work the way you would expect with mononmials,

eq4 = (x^2)^2
substitute(eq4, Dict([x^2 => y]))
julia> x^4

I expected it to return y^2. I use Julia version 1.7.1 with Symbolics v4.4.3.

kjellqvist avatar May 09 '22 20:05 kjellqvist