Strange order of operations on SymPy.jl / multiplication with a(1/a)

In SymPy.jl I’m seeing a strange order of operations. Is there a way to have a(1/a) == 1 or do I always need to explicitly include the * operator before the parentheses? Thanks!

using SymPy
@vars a
a(1/a) == 1 / a # == true
a*(1/a) == 1 # == true

a(1/a) is not multiplication, rather evaluation. Use the operator. Only numeric literals benefit from juxtaposition.

thanks, that’s useful! Appreciate it.

Why does a(1/a) evaluates to 1/a?

a(1/a) is expanding to a(a=>1/a), which substitutes 1/a for a.

1 Like