# Symbolics.jl: simplification of expressions with trigonometric terms

**URL:** https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904
**Category:** General Usage
**Created:** [April 23, 2021, 10:00pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904 "2021-04-23T22:00:46Z")
**Posts on this page:** 10
**Page:** 1

<div class="post-metadata">

### Author: ![cnf](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@cnf](https://discourse.julialang.org/u/cnf)
#### Post date: [April 23, 2021, 10:00pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904/1 "2021-04-23T22:00:46Z")

</div>

I am using the Symbolics.jl package with julia 1.5.2 running on a linux machine.

Any assistance with the following would be appreciated.

(1) How can I simplify expressions with trigonometric terms?

For example, I applied simplify() to various expressions but it could not transform sin(x)_cos(x) to sin(2_x)/2, and cos(x)^2-sin(x)^2 to cos(2\*x).

How can these simplifications be achieved?

(2) Are there expand() and factor() simplification functions?

(3) Where can I obtain pdf file documentation for the  
Symbolics.jl package?

I looked in the table of contents of the julia 1.5.2 manual but could not see anything about the Symbolics.jl package?

---

<div class="post-metadata">

### Author: ![lstagner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lstagner/32/448_2.png) [@lstagner](https://discourse.julialang.org/u/lstagner)
#### Post date: [April 23, 2021, 10:35pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904/2 "2021-04-23T22:35:24Z")

</div>

I wonder what the criterion is for “simpler”. For instance `sin(x)cos(x)` just has two function calls but `sin(2x)/2` has three function calls.

Granted `cos(x)^2 - sin(x)^2` should simplify to `cos(2x)`

---

<div class="post-metadata">

### Author: ![DNF](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/dnf/32/10191_2.png) [@DNF](https://discourse.julialang.org/u/DNF)
#### Post date: [April 23, 2021, 11:09pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904/3 "2021-04-23T23:09:13Z")

</div>

> [@lstagner](#):
>
> `sin(x)cos(x)` just has two function calls but `sin(2x)/2` has three function calls.

Ahem, both of those have three function calls, and not all functions are equal. A `cos` call is far more expensive than a simple multiply or divide. I expect there are a lot of multiplications and divisions going on inside `sin` and `cos`.

---

<div class="post-metadata">

### Author: ![lstagner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/lstagner/32/448_2.png) [@lstagner](https://discourse.julialang.org/u/lstagner)
#### Post date: [April 24, 2021, 1:16am UTC](https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904/4 "2021-04-24T01:16:54Z")

</div>

Bah I cant believed I missed that

---

<div class="post-metadata">

### Author: ![cnf](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@cnf](https://discourse.julialang.org/u/cnf)
#### Post date: [April 24, 2021, 12:09pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904/5 "2021-04-24T12:09:42Z")

</div>

Thank you for the interest and comments. If at all possible please respond to my other questions as well or refer to a colleague who may be able to assist. I would like to explore further the Symbolics.jl package but need more information.

---

<div class="post-metadata">

### Author: ![magister-ludi](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/magister-ludi/32/4003_2.png) [@magister-ludi](https://discourse.julialang.org/u/magister-ludi)
#### Post date: [April 24, 2021, 12:56pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904/6 "2021-04-24T12:56:49Z")

</div>

Symbolics.jl is not part of Julia itself, so you won’t find any reference to it in the Julia manual. The Symbolics.jl codebase is [here](https://github.com/JuliaSymbolics/Symbolics.jl), and its documentation (there’s also a link on the page I just mentioned) is [here](https://symbolics.juliasymbolics.org/stable/).

---

<div class="post-metadata">

### Author: ![cnf](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@cnf](https://discourse.julialang.org/u/cnf)
#### Post date: [April 24, 2021, 4:52pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904/7 "2021-04-24T16:52:40Z")

</div>

Yes, I visited this website previously but other than simplify() I  
could not find  
any additional simplification functions, eg. factor(), expand(), etc. I assume  
that they are not available yet?

Also, I could not find some linear algebra functions for symbolic matrices, eg.  
reduced row echelon form, etc.

---

<div class="post-metadata">

### Author: ![BLI](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/bli/32/37206_2.png) [@BLI](https://discourse.julialang.org/u/BLI)
#### Post date: [April 24, 2021, 6:25pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904/8 "2021-04-24T18:25:44Z")

</div>

I don’t know if it helps, but `Symbolics.jl` uses some routines in package `SymbolicUtils.jl`, and the `simplify` functionality is better explained in the documentation for `SymbolicUtils.jl`. [At least last time I checked…]

---

<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: [April 29, 2021, 3:22pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904/9 "2021-04-29T15:22:56Z")

</div>

> [@cnf](#):
>
> any additional simplification functions, eg. factor(), expand(), etc. I assume  
> that they are not available yet?

They just need better docs.

---

<div class="post-metadata">

### Author: ![cnf](https://avatars.discourse-cdn.com/v4/letter/c/b38774/32.png) [@cnf](https://discourse.julialang.org/u/cnf)
#### Post date: [April 29, 2021, 8:19pm UTC](https://discourse.julialang.org/t/symbolics-jl-simplification-of-expressions-with-trigonometric-terms/59904/10 "2021-04-29T20:19:00Z")

</div>

If they are available then I would like to try them. Please let me know  
as soon as the documentation is available.

I noticed that the julia command names(Symbolics) and names(Symbolics,  
all=true) provides the user with some information as to all the methods that  
are available in the package Symbolics.

Are there julia commands for listing the contents of a specified method in  
the Symbolics package or any julia package?
