# Fast Symbolic Linear Algebra CAS?

I am a regular user of Mathematica, Julia, and MATLAB but I am looking for something different. The problem I am trying to solve in Mathematica only requires (dense) linear algebra to specify but is of a size such that Mathematica takes too long (and seems to automatically halt the computation after like 18 hours, when it should finish in a week or so). I am looking for a symbolic solution and not a numeric solution (to then use a machine learning approach on the resulting equations). I was wondering if anyone knew if there are more efficient and parallel symbolic packages. Checking around it looks like Singularity or Machaly2 may be what's right for this problem?

Edit: As requested here is more detail. It's as straight-forward as it sounds. I need to solve for the symbolic solution of a system of 4x4 matrices and 1x4 vectors. I am able to succinctly write down the exact solution (attached as a photo, hard to format it right in the editor...),

but as you can see it's a little unwieldy (then it gets squared and simplified). I want to use the resulting polynomial (in terms of the matrix coefficients) in numerical computations, but I don't want to have to solve this system of equations each time the matrices change since this would increase the computational cost immensely.

So at a higher level it's really simple, and coding Mathematica to get it to try this computation is simple, but it is taking a lot of computing time (largely because Mathematica's engine is single threaded). In the simple case when the $A$ and $B$ matrices are lower triangular, I Mathematica was able to solve it after about 10 minutes. But getting rid of this assumption on even one matrix increases the complexity by a lot.

Let me lastly note that I have computing power at my disposal. I do high-performance computing, and so I have a few nodes available for a few hundred CPU cores and about a terabyte of RAM to let it churn for a month (I was hoping to change each matrix from lower triangular to full one by one to see how far I can get). However, I don't know what program/language will do this kind of "HPC Symbolic Computing". I was hoping there was some computational algebra package that has the tools to do this.

• If you described your problem, perhaps something useful could be said, otherwise, your question is too general. – Igor Rivin Jan 26 '16 at 23:44
• What do you mean symbolic and linear algebra? So, you want to do gaussian elimination, but with some unknown entries? – Per Alexandersson Jan 27 '16 at 0:00
• Edited with more detail. I mean symbolic computation in the standard sense, and I mean linear algebra as in the equation to simplify can be expressed in terms of linear algebra objects and operations. All of the matrix coefficients are unknowns, and am looking for a solution in terms of the coefficients. – Chris Rackauckas Jan 27 '16 at 0:15
• Did you try to ask on the dedicated Mathematica SE site? – kjetil b halvorsen Jan 27 '16 at 13:02
• I assumed this would be off-topic on the Mathematica SE site since it's not about Mathematica. Due to the Mathematica's general overhead and not having a multithreaded kernal, I thought it would make more sense to ask other mathematicians who encountered the same problem and had switch from Mathematica. I know some reasearchers in things like computational group theory have specialized packages for solving computationally hard problems (GAP), so I was hoping to get advice from some of those folks here. However, it seems I may need to seek them out on the more computational forums. – Chris Rackauckas Jan 27 '16 at 17:08

If $M$ is an invertible matrix and $\bf v$ is a vector, Cramer's rule expresses $M^{-1} \bf v$ as $\det(M)^{-1} \bf w$ where $\det(M)$ and the entries of $\bf w$ are polynomials in the entries of $M$ and $\bf v$. In general, you can't make it any simpler than that. The more complicated the expression, the less likely you are to have cancellations.
• As I said, the symbolic solution of a $4 \times 4$ invertible system is expressible using Cramer's rule. Each $4 \times 4$ determinant is the sum of $24$ terms, where each term is $\pm 1$ times a product of four factors. In that form, the expression is very easy to evaluate. No need for hundreds of CPU's or terabytes of memory. If you try to combine a bunch of these and expand everything out, you get a nightmare. So don't expand everything out. – Robert Israel Jan 27 '16 at 20:53
• Thanks for the clarification. That might work. It's still less than ideal since every step of the machine learning algorithm I will have to recompute anything where the $A$'s and $B$'s are involved (for multiple $\mu$ and $\sigma$), but your method definitely puts it in the "computable" range. I threw the Mathematica code on the HPC to just churn on one node and see if that finishes before I get it solved with your method. However, I am going to leave the topic open to see if anyone answers with some package they are working on since that would be useful for similar problems in the future. – Chris Rackauckas Jan 28 '16 at 16:06