Advertisements
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.
>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