Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Symbolic expression simplification in Julia Symbolics

I have a piece of code here in Julia:

   using Symbolics
  @variables x y z
3-element Vector{Num}:
 x
 y
 z

julia> q = [x y z]*[1 2 3;4 5 6;5 4 2]*[x y z]'
1×1 Matrix{Num}:
 x*(x + 4y + 5z) + y*(2x + 5y + 4z) + z*(3x + 6y + 2z)

simplify(q,expand=true)

simplify(q,expand=true) is not giving any better results.

How to expand the expression q correctly in julia.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

The issue appears to be that q is a 1×1 Matrix{Num}, and Symbolics doesn’t like that. Select the first element from the matrix though, and it works fine:

simplify(q[1], expand = true) # x^2 + 5(y^2) + 2(z^2) + 6x*y + 8x*z + 10y*z
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading