# Simplify expression with symbolics.jl

**URL:** <https://discourse.julialang.org/t/simplify-expression-with-symbolics-jl/103733>\
**Category:** General Usage\
**Tags:** question, symbolics\
**Created:** [September 11, 2023, 9:28am UTC](https://discourse.julialang.org/t/simplify-expression-with-symbolics-jl/103733 "2023-09-11T09:28:37Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 11, 2023, 9:28am UTC](https://discourse.julialang.org/t/simplify-expression-with-symbolics-jl/103733/1 "2023-09-11T09:28:37Z")

</div>

Why is the following expression not getting simplified?

```julia
julia> using Symbolics
julia> @variables a, b
julia> expr=2.25e-7(2.701832006722774e6a - 1.0131921447234855e6(b + 7.999959398007795a))

julia> simplify(expr)
2.25e-7(2.701832006722774e6a - 1.0131921447234855e6(b + 7.999959398007795a))

```

---

<div class="post-metadata">

**Author:** ![Sevi](https://avatars.discourse-cdn.com/v4/letter/s/c67d28/32.png) [@Sevi](https://discourse.julialang.org/u/Sevi)\
**Post date:** [September 11, 2023, 9:39am UTC](https://discourse.julialang.org/t/simplify-expression-with-symbolics-jl/103733/2 "2023-09-11T09:39:12Z")

</div>

I’m not sure if “simplify” is always well-defined, but I just assume that you want the parentheses expanded and the factors of `a` and `b` grouped together?

`simplify` has a keyword `expand` for that:

```julia
julia> using Symbolics

julia> @variables a, b;

julia> expr = 2(3a - 4(b + 5a))
2(3a - 4(b + 5a))

julia> simplify(expr)
2(3a - 4(b + 5a))

julia> simplify(expr; expand=true)
-8b - 34a

```

---

<div class="post-metadata">

**Author:** ![ufechner7](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ufechner7/32/51363_2.png) [@ufechner7](https://discourse.julialang.org/u/ufechner7)\
**Post date:** [September 11, 2023, 9:40am UTC](https://discourse.julialang.org/t/simplify-expression-with-symbolics-jl/103733/3 "2023-09-11T09:40:35Z")

</div>

Indeed, that works:

```julia
julia> simplify(expr; expand=true)
-0.22796823256278423b - 1.215824403025248a

```

Thank you!
