# Matrix multiplication and type stability

**URL:** https://discourse.julialang.org/t/matrix-multiplication-and-type-stability/107020
**Category:** New to Julia
**Tags:** linearalgebra, algebra
**Created:** [December 1, 2023, 9:27pm UTC](https://discourse.julialang.org/t/matrix-multiplication-and-type-stability/107020 "2023-12-01T21:27:52Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![denshd](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/denshd/32/32247_2.png) [@denshd](https://discourse.julialang.org/u/denshd)
#### Post date: [December 1, 2023, 9:27pm UTC](https://discourse.julialang.org/t/matrix-multiplication-and-type-stability/107020/1 "2023-12-01T21:27:52Z")

</div>

Hello! Let’s consider MVE:

```julia
using LinearAlgebra
using AlgebraicNumbers

M = AlgebraicNumber.([
    1 2
    3 4
])

b = AlgebraicNumber.([5; 6])

println(typeof(M))
println(typeof(b))

x = M * b

println(typeof(x))

```

Expected a `Vector{AlgebraicNumber...}`, not `Vector{Any}`, just like in this:

```julia
using LinearAlgebra
using AlgebraicNumbers

M = Rational.([
    1 2
    3 4
])

b = Rational.([5; 6])

println(typeof(M))
println(typeof(b))

x = M * b

println(typeof(x))

```

That’s interesting that it works just fine with functions like `det` and `tr`, but not with matrix multiplication.

So, my question is: is it normal behavior? And if so, how should I perform this operation in order to get `Vector{AlgebraicNumber...}`? Should I just use conversion from type `Any`?

---

<div class="post-metadata">

### Author: ![fkastner](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fkastner/32/6322_2.png) [@fkastner](https://discourse.julialang.org/u/fkastner)
#### Post date: [December 4, 2023, 9:32am UTC](https://discourse.julialang.org/t/matrix-multiplication-and-type-stability/107020/2 "2023-12-04T09:32:06Z")

</div>

For anybody following, this should now be fixed.  
See this [issue](https://github.com/anj1/AlgebraicNumbers.jl/issues/25) and the corresponding [pr](https://github.com/anj1/AlgebraicNumbers.jl/pull/26).
