# Determinant of a symbolic matrix

**URL:** <https://discourse.julialang.org/t/determinant-of-a-symbolic-matrix/85587>\
**Category:** Modelling & Simulations\
**Created:** [August 10, 2022, 2:31pm UTC](https://discourse.julialang.org/t/determinant-of-a-symbolic-matrix/85587 "2022-08-10T14:31:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![qwerty](https://avatars.discourse-cdn.com/v4/letter/q/4491bb/32.png) [@qwerty](https://discourse.julialang.org/u/qwerty)\
**Post date:** [August 10, 2022, 2:31pm UTC](https://discourse.julialang.org/t/determinant-of-a-symbolic-matrix/85587/1 "2022-08-10T14:31:08Z")

</div>

With Symbolics.jl how do I get the determinant of a symbolic matrix?  
I tried this:

```julia
@variables a[1:2, 1:2]
det(a)

```

The only thing I can get is: Symbolics.\_det(a, true)

---

<div class="post-metadata">

**Author:** ![stevengj](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stevengj/32/71_2.png) [@stevengj](https://discourse.julialang.org/u/stevengj)\
**Post date:** [August 10, 2022, 4:52pm UTC](https://discourse.julialang.org/t/determinant-of-a-symbolic-matrix/85587/2 "2022-08-10T16:52:49Z")

</div>

> [@qwerty](#):
>
> With Symbolics.jl how do I get the determinant of a symbolic matrix?

You need to do `using LinearAlgebra` for the `det` function. This notebook (from my [linear algebra course](https://github.com/mitmath/1806/tree/spring22)) has some examples of symbolic determinants: [Notes on determinants](https://nbviewer.org/github/mitmath/1806/blob/spring22/notes/Determinants.ipynb#Explicit-formulas,-high-school-version)

---

<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:** [August 10, 2022, 5:42pm UTC](https://discourse.julialang.org/t/determinant-of-a-symbolic-matrix/85587/3 "2022-08-10T17:42:48Z")

</div>

The issue is that `det` is lazy on symbolic arrays, so if you want the component-wise version you need to collect:

```julia
using Symbolics, LinearAlgebra
@variables a[1:2, 1:2]
det(collect(a)) # a[1, 1]*a[2, 2] - a[1, 2]*a[2, 1]

```

---

<div class="post-metadata">

**Author:** ![croberts](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/croberts/32/9465_2.png) [@croberts](https://discourse.julialang.org/u/croberts)\
**Post date:** [August 31, 2022, 11:08pm UTC](https://discourse.julialang.org/t/determinant-of-a-symbolic-matrix/85587/4 "2022-08-31T23:08:17Z")

</div>

How does Symbolics.jl make det lazy on symbolic arrays? Can you point me to a file or function in Symbolics.jl that implements this feature so that I can ape/extend it on other functions?

I’d like to be able to write equations like

```julia
@variables c, y1, y2, y3
c ~ argmax([y1, y2, y3])

```

I’m guessing that I need to add a method to argmax so that it is lazy with Num type?

Thanks BTW, I’m really excited by everything you are accomplishing.

---

<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:** [September 1, 2022, 12:33am UTC](https://discourse.julialang.org/t/determinant-of-a-symbolic-matrix/85587/5 "2022-09-01T00:33:39Z")

</div>

I’m not sure, you’ll need to open an issue and ask @shashi that one.
