# Matrix in SymbolicUtils?

**URL:** <https://discourse.julialang.org/t/matrix-in-symbolicutils/43229>\
**Category:** New to Julia\
**Created:** [July 17, 2020, 11:48am UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229 "2020-07-17T11:48:30Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [July 17, 2020, 11:48am UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/1 "2020-07-17T11:48:30Z")

</div>

how could I create, say a 2x2, symbolic matrix using SymbolicUtils? e.g. something like `[a11 a12; a21 a22]` where `aij` are symbols… I cannot find in the manual…

also, could I create a _single_ symbol for a matrix e.g. `m`, and then access the element as a _symbol_ like `m[1,2]` ?

thanks.

---

<div class="post-metadata">

**Author:** ![simeonschaub](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simeonschaub/32/216566_2.png) [@simeonschaub](https://discourse.julialang.org/u/simeonschaub)\
**Post date:** [July 17, 2020, 12:02pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/2 "2020-07-17T12:02:40Z")

</div>

I think, you would want to use [ModelingToolkit.jl](https://mtk.sciml.ai/) for that, which uses SymbolicUtils under the hood. The relevant documentation for that would probably be in the [`@variables` docstring](https://mtk.sciml.ai/dev/highlevel/#ModelingToolkit.@variables). You could then write:

```julia
julia> using ModelingToolkit

julia> @variables a[1:2, 1:2]
(Operation[a₁ˏ₁ a₁ˏ₂; a₂ˏ₁ a₂ˏ₂],)

```

---

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [July 17, 2020, 12:30pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/3 "2020-07-17T12:30:10Z")

</div>

a related question: if I’m doing symbolic calculations (e.g. determinant, inverse) of a matrix, is it easier to use `Reduce.jl` or `ModelingToolkit.jl`? thanks.

---

<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:** [July 17, 2020, 12:46pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/4 "2020-07-17T12:46:51Z")

</div>

I can’t imagine it getting any simpler than ModelingToolkit. Just literally write the Julia code:

```julia
julia> using ModelingToolkit

julia> @variables u[1:3,1:3]
(Operation[u₁ˏ₁ u₁ˏ₂ u₁ˏ₃; u₂ˏ₁ u₂ˏ₂ u₂ˏ₃; u₃ˏ₁ u₃ˏ₂ u₃ˏ₃],)

julia> det(u)
(((1u₁ˏ₁) * (u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * ((u₃ˏ₃ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃))) * 1

julia> inv(u)
3×3 Array{Operation,2}:
 u₁ˏ₁ \ ((identity(true) - u₁ˏ₃ * (((u₃ˏ₃ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃)) \ ((identity(0) - (u₃ˏ₁ * inv(u₁ˏ₁)) * identity(true)) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * 
(identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(true))))) - u₁ˏ₂ * ((u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) \ ((identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(true)) - (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) * (((u₃ˏ₃ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃)) \ ((identity(0) - (u₃ˏ₁ * inv(u₁ˏ₁)) * identity(true)) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(true))))))) … u₁ˏ₁ \ ((identity(0) - u₁ˏ₃ * (((u₃ˏ₃ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃)) \ ((identity(true) - (u₃ˏ₁ 
* inv(u₁ˏ₁)) * identity(0)) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(0))))) - u₁ˏ₂ * ((u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) \ ((identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(0)) - (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) * (((u₃ˏ₃ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃)) \ ((identity(true) - (u₃ˏ₁ * inv(u₁ˏ₁)) * identity(0)) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(0)))))))        

                                                                   (u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) \ ((identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(true)) - (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) * (((u₃ˏ₃ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃)) \ ((identity(0) - (u₃ˏ₁ * inv(u₁ˏ₁)) * identity(true)) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(true)))))

                                                                 (u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) \ ((identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(0)) - (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) * (((u₃ˏ₃ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃)) \ ((identity(true) - (u₃ˏ₁ * inv(u₁ˏ₁)) * identity(0)) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * 
u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(0)))))        

                                                                                           ((u₃ˏ₃ - (u₃ˏ₁ * 
inv(u₁ˏ₁)) * u₁ˏ₃) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (u₂ˏ₃ - 
(u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃)) \ ((identity(0) - (u₃ˏ₁ * inv(u₁ˏ₁)) * identity(true)) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(true)))

                                                                                      ((u₃ˏ₃ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃)) \ ((identity(true) - (u₃ˏ₁ * inv(u₁ˏ₁)) * identity(0)) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) 
* u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (identity(0) - (u₂ˏ₁ * inv(u₁ˏ₁)) * identity(0))) 

```

and simplify it if you need to:

```julia
julia> @time simplify.(inv(u))
  0.225683 seconds (621.50 k allocations: 18.274 MiB)
3×3 Array{Operation,2}:
 u₁ˏ₁ \ (true + -1 * (u₁ˏ₂ * ((-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) \ (-1 * inv(u₁ˏ₁) * u₂ˏ₁ + -1 * ((u₃ˏ₃ + -1 * (inv(u₁ˏ₁) * u₁ˏ₃ * u₃ˏ₁ + inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + 
u₃ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))) \ (-1 * inv(u₁ˏ₁) * u₃ˏ₁ + inv(u₁ˏ₁) * u₂ˏ₁ * inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + u₃ˏ₂))) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))) + u₁ˏ₃ * ((u₃ˏ₃ + -1 * (inv(u₁ˏ₁) * u₁ˏ₃ * u₃ˏ₁ + inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + u₃ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))) \ (-1 * inv(u₁ˏ₁) * u₃ˏ₁ + inv(u₁ˏ₁) * u₂ˏ₁ * inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + u₃ˏ₂))))) … u₁ˏ₁ \ (-1 * 
u₁ˏ₂ * ((-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) \ (-1 * ((u₃ˏ₃ + -1 * (inv(u₁ˏ₁) * u₁ˏ₃ * u₃ˏ₁ + inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + u₃ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))) \ 1) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))) + -1 * u₁ˏ₃ * ((u₃ˏ₃ + -1 * (inv(u₁ˏ₁) * u₁ˏ₃ * u₃ˏ₁ + inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + u₃ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))) \ 1))

           (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) \ (-1 * inv(u₁ˏ₁) * u₂ˏ₁ + -1 * ((u₃ˏ₃ + -1 * (inv(u₁ˏ₁) * 
u₁ˏ₃ * u₃ˏ₁ + inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + u₃ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))) \ (-1 * inv(u₁ˏ₁) * u₃ˏ₁ + inv(u₁ˏ₁) * u₂ˏ₁ * inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ 
+ u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + u₃ˏ₂))) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))

                                                                                     (-1 * inv(u₁ˏ₁) * u₁ˏ₂ 
* u₂ˏ₁ + u₂ˏ₂) \ (-1 * ((u₃ˏ₃ + -1 * (inv(u₁ˏ₁) * u₁ˏ₃ * u₃ˏ₁ + inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + u₃ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))) \ 1) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))

                (u₃ˏ₃ + -1 * (inv(u₁ˏ₁) * u₁ˏ₃ * u₃ˏ₁ + inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + u₃ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))) \ (-1 * inv(u₁ˏ₁) * u₃ˏ₁ + inv(u₁ˏ₁) 
* u₂ˏ₁ * inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + u₃ˏ₂))

                                                                  (u₃ˏ₃ + -1 * (inv(u₁ˏ₁) * u₁ˏ₃ * u₃ˏ₁ + inv(-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₂ˏ₁ + u₂ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₂ * u₃ˏ₁ + u₃ˏ₂) * (-1 * inv(u₁ˏ₁) * u₁ˏ₃ * u₂ˏ₁ + u₂ˏ₃))) \ 1

```

---

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [July 17, 2020, 1:59pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/5 "2020-07-17T13:59:27Z")

</div>

thanks.

seems that `SymbolicUtils.jl` and `ModelingToolkit.jl` are in pure `Julia` (is it true?) so that they could seamlessly integrated with `Julia`. On the other hand, seems that `Reduce.jl` is from a more mature system and has a _more complete documentation_.

for example, I cannot find in `ModelingToolkit` manual about how to get `v[1,2]` below:

```julia
julia> @variables u[1:3,1:3]
(Operation[u₁ˏ₁ u₁ˏ₂ u₁ˏ₃; u₂ˏ₁ u₂ˏ₂ u₂ˏ₃; u₃ˏ₁ u₃ˏ₂ u₃ˏ₃],)

julia> v = LinearAlgebra.det(u)
(((1u₁ˏ₁) * (u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * ((u₃ˏ₃ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃) - ((u₃ˏ₂ - (u₃ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂) * inv(u₂ˏ₂ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₂)) * (u₂ˏ₃ - (u₂ˏ₁ * inv(u₁ˏ₁)) * u₁ˏ₃))) * 1

julia> typeof(v)
Operation

julia> typeof(u)
Array{Operation,2}

julia> u[1,2]
u₁ˏ₂

julia> v[1,2]
ERROR: BoundsError

```

or, did I miss any documentation besides [SymbolicUtils](https://juliasymbolics.github.io/SymbolicUtils.jl/) and [ModelingToolkit](https://mtk.sciml.ai/dev/)?

---

<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:** [July 17, 2020, 2:05pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/6 "2020-07-17T14:05:37Z")

</div>

The determinant of a matrix is a scalar, so I don’t know what you’re indexing. That BoundsError is correct.

---

<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:** [July 17, 2020, 2:06pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/7 "2020-07-17T14:06:18Z")

</div>

> [@tomtom](#):
>
> seems that `SymbolicUtils.jl` and `ModelingToolkit.jl` are in pure `Julia` (is it true?)

yes

---

<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:** [July 17, 2020, 2:06pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/8 "2020-07-17T14:06:48Z")

</div>

> [@tomtom](#):
>
> On the other hand, seems that `Reduce.jl` is from a more mature system and has a _more complete documentation_ .

Not necessarily. It has different stuff, but neither supersets the other.

---

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [July 17, 2020, 2:12pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/9 "2020-07-17T14:12:54Z")

</div>

> [@ChrisRackauckas](#):
>
> The determinant of a matrix is a scalar

oh my stupid! I was thinking matrix inverse 😅

---

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [July 17, 2020, 2:14pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/10 "2020-07-17T14:14:35Z")

</div>

> [@tomtom](#):
>
> did I miss any documentation besides [SymbolicUtils](https://juliasymbolics.github.io/SymbolicUtils.jl/) and [ModelingToolkit](https://mtk.sciml.ai/dev/)?

any suggestions? I afraid asking more stupid questions here like “how to bind a value into a symbol”, “how to evaluate a symbolic expressions”, etc… 😅

---

<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:** [July 17, 2020, 2:24pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/11 "2020-07-17T14:24:55Z")

</div>

Just ask. That’s the docs we have right now, it’ll get populated more by questions, and maybe people who read the answers will contribute answers back as well 🙂. A lot of the features are automatically generated, so actually documenting what it can do is a weird thing that’s more done in retrospect after figuring out how dispatch generates the features and what names people know that feature by.

---

<div class="post-metadata">

**Author:** ![tomtom](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tomtom/32/5106_2.png) [@tomtom](https://discourse.julialang.org/u/tomtom)\
**Post date:** [July 17, 2020, 2:46pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/12 "2020-07-17T14:46:20Z")

</div>

good for you to be so helpful 😃

so I ask more questions now:

1. how to declare a symbolic complex number in the form of `x = a + jb` and `x = rcosθ + jrsinθ`? that is, `x`,`a`,`b`,`r`,`θ` are all symbols.
2. in the following, how do I arrange `p` as a polynomial in `L`?
3. then, how to get the coefficients of the polynomials?
4. in general, how do I manipulate a `SymbolicUtils.Term` object? should I transform it into a standard `Julia` expression (how?) and then transverse the expression tree?

```julia
julia> @syms L α₁ α₂
(L, α₁, α₂)

julia> p = (1 - L) * (1 - α₁ * L) * (1 - α₂ * L)
(1 + (-1 * L)) * (1 + (-1 * L * α₁)) * (1 + (-1 * L * α₂))

```

many thanks! 🙏

---

<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:** [July 17, 2020, 3:37pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/13 "2020-07-17T15:37:27Z")

</div>

Probably answers most of it:

```julia
using ModelingToolkit

@variables x a b r θ

x + im * a

x = r*cos(θ) + im*r*sin(θ)

x.op # +
x.args

2-element Array{Expression,1}:
          r * cos(θ)
 ((im) * r) * sin(θ)

```

@shashi would have to answer the polynomial part.

---

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [July 17, 2020, 4:17pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/14 "2020-07-17T16:17:14Z")

</div>

This is super cool! How would one generate a julia function based on this result? I can’t find an obvious way to do it in the docs.

---

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [July 17, 2020, 4:31pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/15 "2020-07-17T16:31:59Z")

</div>

Nevermind, I saw [the tutorial](https://mtk.sciml.ai/stable/tutorials/symbolic_functions/). I think I was confused by the “Parallel” in the title…

```julia
julia> f_det = eval(ModelingToolkit.build_function( det(u), u ))
#6 (generic function with 1 method)

julia> A = rand(3,3);

julia> det(A)
-0.04382988531989483

julia> f_det(A)
-0.04382988531989484

```

---

<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:** [July 17, 2020, 4:33pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/16 "2020-07-17T16:33:40Z")

</div>

The first tutorial is titled " [Symbolic Calculations and Building Fast Parallel Functions](https://mtk.sciml.ai/dev/tutorials/symbolic_functions/#Symbolic-Calculations-and-Building-Fast-Parallel-Functions-1)" 😛. Let’s multithread it:

```julia
using ModelingToolkit
@variables u[1:3,1:3]
A = inv(u)
build_function(A,u,parallel=ModelingToolkit.MultithreadedForm())[2]

```

which creates:

```julia
:((var"##MTIIPVar#82901", var"##MTKArg#82899")->begin
          @inbounds begin
                  begin
                      (ModelingToolkit.fill_array_with_zero!)(var"##MTIIPVar#82901")
                      @sync begin
                              let (u₁ˏ₁, u₂ˏ₁, u₃ˏ₁, u₁ˏ₂, u₂ˏ₂, u₃ˏ₂, u₁ˏ₃, u₂ˏ₃, u₃ˏ₃) = (var"##MTKArg#82899"[1], var"##MTKArg#82899"[2], var"##MTKArg#82899"[3], var"##MTKArg#82899"[4], var"##MTKArg#82899"[5], var"##MTKArg#82899"[6], var"##MTKArg#82899"[7], var"##MTKArg#82899"[8], var"##MTKArg#82899"[9])
                                  begin
                                      Threads.@spawn begin
                                              var"##MTIIPVar#82901"[1] = (getproperty(Base, :\))(u₁ˏ₁, (getproperty(Base, :-))((getproperty(Base, :-))(identity(true), (getproperty(Base, :*))(u₁ˏ₃, (getproperty(Base, 
:\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(true))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(true)))))))), (getproperty(Base, :*))(u₁ˏ₂, (getproperty(Base, :\))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(true))), (getproperty(Base, 
:*))((getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, 
:inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, 
:*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(true))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(true))))))))))))
                                              var"##MTIIPVar#82901"[2] = (getproperty(Base, :\))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(true))), (getproperty(Base, :*))((getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), 
(getproperty(Base, :\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(true))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, 
:-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(true)))))))))
                                              var"##MTIIPVar#82901"[3] = (getproperty(Base, :\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, 
:*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(true))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), 
u₁ˏ₂)))), (getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(true))))))
                                          end
                                  end
                                  begin
                                      Threads.@spawn begin
                                              var"##MTIIPVar#82901"[4] = (getproperty(Base, :\))(u₁ˏ₁, (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))(u₁ˏ₃, (getproperty(Base, :\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(identity(true), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0)))))))), (getproperty(Base, :*))(u₁ˏ₂, (getproperty(Base, :\))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :-))((getproperty(Base, :-))(identity(true), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(identity(true), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))))))))))))
                                              var"##MTIIPVar#82901"[5] = (getproperty(Base, :\))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :-))((getproperty(Base, :-))(identity(true), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), 
(getproperty(Base, :\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(identity(true), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0)))))))))
                                              var"##MTIIPVar#82901"[6] = (getproperty(Base, :\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, 
:*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(identity(true), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))))))
                                          end
                                  end
                                  begin
                                      Threads.@spawn begin
                                              var"##MTIIPVar#82901"[7] = (getproperty(Base, :\))(u₁ˏ₁, (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))(u₁ˏ₃, (getproperty(Base, :\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(true), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0)))))))), (getproperty(Base, :*))(u₁ˏ₂, (getproperty(Base, :\))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(true), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))))))))))))
                                              var"##MTIIPVar#82901"[8] = (getproperty(Base, :\))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :-))((getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(true), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0)))))))))
                                              var"##MTIIPVar#82901"[9] = (getproperty(Base, :\))((getproperty(Base, :-))((getproperty(Base, :-))(u₃ˏ₃, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)))), (getproperty(Base, :-))(u₂ˏ₃, (getproperty(Base, :*))((getproperty(Base, 
:*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₃)))), (getproperty(Base, :-))((getproperty(Base, :-))(identity(true), (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))), (getproperty(Base, :*))((getproperty(Base, :*))((getproperty(Base, :-))(u₃ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₃ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), u₁ˏ₂)), (getproperty(Base, :inv))((getproperty(Base, :-))(u₂ˏ₂, (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), 
u₁ˏ₂)))), (getproperty(Base, :-))(identity(0), (getproperty(Base, :*))((getproperty(Base, :*))(u₂ˏ₁, (getproperty(Base, :inv))(u₁ˏ₁)), identity(0))))))
                                          end
                                  end
                                  begin
                                      Threads.@spawn begin
                                          end
                                  end
                              end
                          end
                  end
              end
          nothing
      end)

```

---

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [July 17, 2020, 4:36pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/17 "2020-07-17T16:36:27Z")

</div>

This is very impressive!

---

<div class="post-metadata">

**Author:** ![jebej](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jebej/32/1784_2.png) [@jebej](https://discourse.julialang.org/u/jebej)\
**Post date:** [July 17, 2020, 4:38pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/18 "2020-07-17T16:38:07Z")

</div>

What’s going on with the empty `Threads.@spawn begin end` towards the end?

---

<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:** [July 17, 2020, 4:40pm UTC](https://discourse.julialang.org/t/matrix-in-symbolicutils/43229/19 "2020-07-17T16:40:25Z")

</div>

It’s trying to do load balancing for my 4 cores, but it’s definitely not expensive enough to make good use of 4
