# Determinant of a square random matrix using juliac

**URL:** <https://discourse.julialang.org/t/determinant-of-a-square-random-matrix-using-juliac/131144>\
**Category:** Internals & Design\
**Tags:** juliac\
**Created:** [July 28, 2025, 7:32pm UTC](https://discourse.julialang.org/t/determinant-of-a-square-random-matrix-using-juliac/131144 "2025-07-28T19:32:27Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![jbytecode](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbytecode/32/17719_2.png) [@jbytecode](https://discourse.julialang.org/u/jbytecode)\
**Post date:** [July 28, 2025, 7:32pm UTC](https://discourse.julialang.org/t/determinant-of-a-square-random-matrix-using-juliac/131144/1 "2025-07-28T19:32:27Z")

</div>

The Julia code is

```julia
using LinearAlgebra

function (@main)(args::Vector{String})::Cint
    m = rand(Float64, 3, 3)
	for i in 1:3
		for j in 1:3
				print(Core.stdout, m[i, j], " ")
		end 
		println(Core.stdout)
	end 

	result = -Inf

	try
		result = det(m)
	catch e 
		println(Core.stdout, "Error occured")
		println(Core.stdout, typeof(e))
	end
    println(Core.stdout, "Determinant of matrix m is: ", result)
    return 0
end 

# This file currently throws a TypeError
# due to possibly a type unstability in the LinearAlgebra.det()

```

This file is located in the repo [GitHub - jbytecode/juliac: Examples for Julia's generating small binary executables and libraries feature.](https://github.com/jbytecode/juliac)

I compile the code using

```shell
julia +nightly ./juliac/juliac.jl --experimental --trim --output-exe determinant determinant.jl

```

When I run the compiled binary using

```shell
> ./determinant

```

I get

```shell
> ./determinant
0.8743122811827831 0.6300620531943388 0.3450695610105955 
0.7027868683889693 0.8758619592106516 0.2880180735794807 
0.6450057839884562 0.3323840835725862 0.8649912996516349 
Error occured
TypeError
Determinant of matrix m is: -Inf

```

I know `juliac` is its initial stages, how to get rid of this error?

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [July 29, 2025, 6:27am UTC](https://discourse.julialang.org/t/determinant-of-a-square-random-matrix-using-juliac/131144/2 "2025-07-29T06:27:19Z")

</div>

Strange, I was under the impression that type instabilities would result in compile-time warnings/errors, but that looks very much like a runtime error. What happens when you don’t try-catch, could you let the stacktrace print out and see what calls threw it?

Might be worth making the matrix values constant while you work it out, but those printed values should work fine with `det`.

```julia-auto
julia> using LinearAlgebra # 1.12.0-rc1

julia> [0.8743122811827831 0.6300620531943388 0.3450695610105955
       0.7027868683889693 0.8758619592106516 0.2880180735794807
       0.6450057839884562 0.3323840835725862 0.8649912996516349] |> det
0.19838562158551779

```

---

<div class="post-metadata">

**Author:** ![Herve](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/herve/32/222014_2.png) [@Herve](https://discourse.julialang.org/u/Herve)\
**Post date:** [July 29, 2025, 12:41pm UTC](https://discourse.julialang.org/t/determinant-of-a-square-random-matrix-using-juliac/131144/3 "2025-07-29T12:41:34Z")

</div>

On my system, it does compile and provide a numerical result (and no error) using the 1.12 release candidate. I have experienced the same as you have on the nightly releases. I don’t know the difference between the two, but it seems the nightly version is still more unstable than the 1.12 rc.

---

<div class="post-metadata">

**Author:** ![Benny](https://avatars.discourse-cdn.com/v4/letter/b/49beb7/32.png) [@Benny](https://discourse.julialang.org/u/Benny)\
**Post date:** [July 29, 2025, 1:49pm UTC](https://discourse.julialang.org/t/determinant-of-a-square-random-matrix-using-juliac/131144/4 "2025-07-29T13:49:11Z")

</div>

Yikes, does that happen when you evaluate the same code in the REPL?

---

<div class="post-metadata">

**Author:** ![topolarity](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/topolarity/32/209470_2.png) [@topolarity](https://discourse.julialang.org/u/topolarity)\
**Post date:** [July 29, 2025, 5:58pm UTC](https://discourse.julialang.org/t/determinant-of-a-square-random-matrix-using-juliac/131144/5 "2025-07-29T17:58:53Z")

</div>

The issue on nightly is due to known limitations around LazyLibrary and `--trim`

This works fine on 1.12, since it doesn’t use `LazyLibrary` to load BLAS, but on `master` this will be regressed until this is fixed [trimming: no way to `ccall` into a dynamically-computed library name · Issue #57707 · JuliaLang/julia · GitHub](https://github.com/JuliaLang/julia/issues/57707).

We’ve got a plan to resolve this before 1.13, but it’s definitely a regression for `nightly` in the mean time.

---

<div class="post-metadata">

**Author:** ![jbytecode](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jbytecode/32/17719_2.png) [@jbytecode](https://discourse.julialang.org/u/jbytecode)\
**Post date:** [July 29, 2025, 7:57pm UTC](https://discourse.julialang.org/t/determinant-of-a-square-random-matrix-using-juliac/131144/6 "2025-07-29T19:57:35Z")

</div>

@topolarity - Thank you for the response. Whenever I remove the `--trim` flag, it successfully compiles and runs as expected (but indeed it’s very big). I’m now leaving the `Makefile` as is with the nightly build and I will be watching the latest news on the `juliac`.  
Thanks again for those who contribute to `juliac` again.
