Skip to main content
17 votes
Accepted

How to get inverse matrix for large size matrix in Mathematica?

As you can observe in the tiny instance of the problem, the matrix Ainv is dense. So you would need $O(\mathrm{matrixSize}^2)$ memory for storing the result. That ...
Henrik Schumacher's user avatar
11 votes
Accepted

Efficient way to reconstruct matrix from list of iterated dot products

How about this? Arec is the reconstructed matrix. Remarks: $\bullet$ This code works only when $\{\boldsymbol{x}, A\boldsymbol{x}, A^2\boldsymbol{x}, \cdots, A^{n-1}...
A. Kato's user avatar
  • 6,140
9 votes
Accepted

Quickly computing product of Householder reflections $\prod_{v} I - v v^T$

Here's a way to do what you ask and @Henrik Schumacher's variant with LAPACK routines: ...
Michael E2's user avatar
  • 247k
8 votes

Why does Together speed up RowReduce?

The difference (in Mac ARM V14.1) is that an internal solver works on mat // Together but not on mat. I could not spelunk deeper ...
Michael E2's user avatar
  • 247k
8 votes

Quickly computing product of Householder reflections $\prod_{v} I - v v^T$

The point of working with rank-one-perturbations of the identity is that you never form that actual matrix. That is an algorithmic restriction, but it can be exploited quite often. The BFGS ...
Henrik Schumacher's user avatar
7 votes
Accepted

Writing a matrix as a linear combination of matrices

...
Bob Hanlon's user avatar
  • 163k
7 votes

Can Mathematica do symbolic linear algebra?

Calculus with symbolic arrays in Wolfram 14.1 Mathematica 14.1 (i.e. Wolfram 14.1) introduces (July 2024) calculus with symbolic arrays. One can now define the following symbolic arrays and vectors ...
divenex's user avatar
  • 736
6 votes

Quadratic form derivative in Mathematica

You can use VectorSymbol and MatrixSymbol, introduced in version 14.1 as part of the Symbolic Vectors, Matrices and Arrays ...
Domen's user avatar
  • 33.8k
6 votes

Symbolic linear algebra gradients/matrix calculus

Use the new-in-14.1 VectorSymbol: ...
xzczd's user avatar
  • 68.7k
6 votes
Accepted

How to find all the possible products from a list of commutative $2 \times 2$ matrices?

Try this one-liner ...
yarchik's user avatar
  • 20.3k
5 votes

What is the best way to write a polynomial in the Bernstein basis?

There is a very straightforward algorithm (a two-liner in Mathematica!) to convert a polynomial to a Bernstein basis based on reversing a differences table of its coefficients, described in the paper: ...
Silverfish's user avatar
5 votes

Solving a system of linear equations modulo n

We now have LinearSolveMod in the Wolfram Function Repository ...
5 votes

Computing log-determinant?

The determinant of a matrix may be outside the usual 64-bit floating point range, even if the log determinant isn't. Hence using Log[Det[...]] to compute the log ...
Wicher's user avatar
  • 101
5 votes

How to ask Mathematica to find the nontrivial (nonzero) solution of a homogeneous system of equations?

The answer will depend how the determinant vanishes: mat = {{a, b, 0}, {c, d, e}, {0, f, g}}; Det[mat] (* -a e f - b c g + a d g *) cases = Solve[% == 0] ...
A. Kato's user avatar
  • 6,140
5 votes
Accepted

How to convert a $2 \times 2$ matrix with entries of $4 \times 4$ matrices into a regular $8 \times 8 $ matrix

z = ConstantArray[0, {4, 4}]; i = IdentityMatrix[4]; matrix = {{z, i}, {i, z}} // ArrayFlatten; matrix // MatrixForm $$ \left( \begin{array}{cccccccc} 0 & 0 &...
Roman's user avatar
  • 50.3k
4 votes

Non-valid modulus when using LinearSolve

We now have LinearSolveMod in the Wolfram Function Repository Get a solution and generating set for the null vectors: ...
Daniel Lichtblau's user avatar
4 votes

Finite Differences:

We can use Difference[#,n] to get n order difference. Flatten[#,{{2},{1}}] can be use to ...
cvgmt's user avatar
  • 84.7k
4 votes

Finite Differences:

...
Syed's user avatar
  • 61.2k
4 votes
Accepted

Saving solutions of equations with indexed variables to a table

First, use Solve to get the solution: sol = First@Solve[{c[0, 4, 0] + ...} == {494/(6561 Sqrt[π]), ...}]; Now iterate through the values and put them in another ...
Domen's user avatar
  • 33.8k
4 votes

Converting an algebric expression into a matrix form

I think CoefficientArrays is what you are after. I start by putting in your expression and defining two vectors of coefficients. ...
Hugh's user avatar
  • 16.8k
4 votes
Accepted

Find more relationships with LatticeReduce

If we limit vec to four elements and test all possible sublist we get more results. ...
azerbajdzan's user avatar
  • 25.2k
4 votes

Subsets command not working as expected with dot product of matrices

A fundamental aspect of Mathematica is that everything is an expression and evaluating an expression is just applying rules to transform the expression into another expression. You really can't rely ...
lericr's user avatar
  • 34.6k
4 votes
Accepted

How to get all possible multiplicative combinations of $5$ matrices with unique output

Do not use uppercase symbols, they are used for the system. We may solve this using only abstract elements, without the complication of matrices. I note the abstract elements by : g[i]. We know that ...
Daniel Huber's user avatar
  • 56.9k
4 votes
Accepted

Identifying the order of the output

Use Eigensystem. ...
Domen's user avatar
  • 33.8k
4 votes
Accepted

Computing norm of a matrix with positive entries

You're not going top fit that matrix just anywhere. You need a specialized matrix-times-vector routine (and vice versa, for the case at hand). I won't show the simple confirmation tests I did, but ...
Daniel Lichtblau's user avatar
4 votes

How to ask Mathematica to find the nontrivial (nonzero) solution of a homogeneous system of equations?

Try Reduce ...
Ulrich Neumann's user avatar
4 votes
Accepted

How to find intersecting linear equations between two lists?

Can intersect using Intersection once all right-hand-sides are zero. Just use Together on the quotient of left-hand-sides as the ...
Daniel Lichtblau's user avatar
4 votes

What is an elegant way to find where a row of 0's and a column of 0's in a matrix intersect?

(mat = {{0, 0, -(1/Sqrt[2]), 1/Sqrt[2]}, {0, 0, 1/Sqrt[2], 1/Sqrt[2]}, {0, 0, 0, 0}, {0, 0, 0, 0}}) // MatrixForm $\left( \begin{array}{cccc} 0 & 0 &...
Syed's user avatar
  • 61.2k
4 votes

Finding additive span of a list, without repeating elements

This following can be one way of organizing and visualizing this task. Mainly, I am using indexed lists so that random lists can be generated and accessed. Let me know if you have difficulty tailoring ...
Syed's user avatar
  • 61.2k

Only top scored, non community-wiki answers of a minimum length are eligible