# Solving AX=B with a matrix B of right-hand sides

**URL:** <https://discourse.julialang.org/t/solving-ax-b-with-a-matrix-b-of-right-hand-sides/125282>\
**Category:** Numerics\
**Tags:** linearalgebra\
**Created:** [January 15, 2025, 3:39pm UTC](https://discourse.julialang.org/t/solving-ax-b-with-a-matrix-b-of-right-hand-sides/125282 "2025-01-15T15:39:05Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![B4rtel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/b4rtel/32/214171_2.png) [@B4rtel](https://discourse.julialang.org/u/B4rtel)\
**Post date:** [January 15, 2025, 3:39pm UTC](https://discourse.julialang.org/t/solving-ax-b-with-a-matrix-b-of-right-hand-sides/125282/1 "2025-01-15T15:39:05Z")

</div>

Hi, is your answer also the same for the case `AX=B` i.e. when X and B are matrices instead of vectors?

---

<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:** [January 27, 2025, 9:12pm UTC](https://discourse.julialang.org/t/solving-ax-b-with-a-matrix-b-of-right-hand-sides/125282/2 "2025-01-27T21:12:19Z")

</div>

Yes. You should still generally use `X = A \ B`.

The only time `inv(A) * B` becomes more efficient is usually when `size(B,2)` is much greater than `size(B,1)`, and even then only for dense matrices. See: [Why re-use factorization(A) rather than inv(A) - #3 by stevengj](https://discourse.julialang.org/t/why-re-use-factorization-a-rather-than-inv-a/113234/3)

PS. I moved your question to a new thread. Please don’t post new questions on ancient threads.
