Symbolics.jl: simplification of expressions with trigonometric terms

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(2x)/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?

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)

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.


Bah I cant believed I missed that


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.

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, and its documentation (there’s also a link on the page I just mentioned) is here.

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.

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…]

They just need better docs.

1 Like

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?