Julia Symbolics can't simplify derivative expressions

Viewed 151

I am using the Symbolics package in Julia, and it seems to not be simplifying derivatives of expressions.

E.g.:

@variables r
Dr = Differential(r)
simplify(expand_derivatives(Dr((2/r)^2)))

results in

(-4(2 / (r^2))) / r

If I instead create the derivative expression by hand, then simplify works great

simplify((-4*(2 / (r^2))) / r)

gives

-8 / (r^3)

as expected.

Why doesn't simplify work correctly on expressions created from differentiation?

1 Answers

Use expand=true. Set up code:

using Symbolics
@variables r
Dr = Differential(r)

And now:

julia> simplify(expand_derivatives(Dr((2/r)^2)); expand=true)
-8 / (r^3)

Note that simplify((-4(2 / (r^2))) / r) worked because (-4(2 / (r^2))) / r was simplified before reaching that function:

julia> -4(2 / (r^2)) / r
-8 / (r^3)
Related