# Simplify with Symbolics.jl

**URL:** https://discourse.julialang.org/t/simplify-with-symbolics-jl/73545
**Category:** General Usage
**Tags:** question, symbolics, symbolic-utils
**Created:** [December 23, 2021, 7:24pm UTC](https://discourse.julialang.org/t/simplify-with-symbolics-jl/73545 "2021-12-23T19:24:57Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![sungj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sungj/32/32176_2.png) [@sungj](https://discourse.julialang.org/u/sungj)
#### Post date: [December 23, 2021, 7:24pm UTC](https://discourse.julialang.org/t/simplify-with-symbolics-jl/73545/1 "2021-12-23T19:24:57Z")

</div>

Hi,

How can I simplify this simple expression?

```julia
julia> using Symbolics

julia> @variables x, y, z
3-element Vector{Num}:
 x
 y
 z

julia> simplify( cos(x)^2*cos(y)^2*cos(z)^2 + cos(x)^2*sin(y)^2*cos(z)^2 )
(cos(x)^2)*(cos(y)^2)*(cos(z)^2) + (cos(x)^2)*(sin(y)^2)*(cos(z)^2)

```

I would like to get the expected answer `(cos(x)^2)*(cos(z)^2)`.

This happens only when `cos(y)^2 + sin(y)^2` is not the first or the last part of its homogeneous factors.  
In other words this happens when the (inverse) distributive law is needed on both left and right sides.

For example, when `cos^2 + sin^2` is in the first or last part of the terms, `simplify` works well (below example)

```julia
julia> simplify( cos(x)^2*cos(y)^2*cos(z)^2 + sin(x)^2*cos(y)^2*cos(z)^2 )
(cos(y)^2)*(cos(z)^2)

julia> simplify( cos(x)^2*cos(y)^2*cos(z)^2 + cos(x)^2*sin(y)^2*cos(z)^2 )
(cos(x)^2)*(cos(y)^2)*(cos(z)^2) + (cos(x)^2)*(sin(y)^2)*(cos(z)^2)

julia> simplify( cos(x)^2*cos(y)^2*cos(z)^2 + cos(x)^2*cos(y)^2*sin(z)^2 )
(cos(x)^2)*(cos(y)^2)

```

Is there a variant (or keyword or anything) of `simplify` that can solve this problem?

---

<div class="post-metadata">

### Author: ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)
#### Post date: [December 23, 2021, 10:08pm UTC](https://discourse.julialang.org/t/simplify-with-symbolics-jl/73545/2 "2021-12-23T22:08:16Z")

</div>

Open an issue. Seems like it’s just missing something.

---

<div class="post-metadata">

### Author: ![sungj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sungj/32/32176_2.png) [@sungj](https://discourse.julialang.org/u/sungj)
#### Post date: [December 23, 2021, 10:32pm UTC](https://discourse.julialang.org/t/simplify-with-symbolics-jl/73545/3 "2021-12-23T22:32:13Z")

</div>

I will. Thanks, Chris!
