Harrison Grodin
Harrison Grodin

Reputation: 2323

Simplify expression in SymEngine.jl

In SymPy.jl, expressions may be easily simplified using the simplify function.

julia> using SymPy

julia> expr = x * (3 - 4/x)
  ⎛    4⎞
x⋅⎜3 - ─⎟
  ⎝    x⎠

julia> simplify(expr)
3⋅x - 4

However, there seems to be no similar function in SymEngine.jl.

julia> using SymEngine

julia> expr = x * (3 - 4/x)
x*(3 - 4*x^(-1))

From what I can tell, SymEngine is, by no means, complete. I would still like to be able to simplify my expressions, though. Is there a way I can achieve this, either through either an existing or a custom function?

Upvotes: 3

Views: 1264

Answers (1)

isuruf
isuruf

Reputation: 2753

There's no simplify yet in SymEngine. There is expand though, which can do what you want in this case.

julia> expr = x * (3 - 4/x)
x*(3 - 4*x^(-1))

julia> expand(expr)
-4 + 3*x

This is similar to SymPy's expand

Upvotes: 5

Related Questions