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 ...
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}...
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:
...
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 ...
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 ...
7
votes
Accepted
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 ...
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 ...
6
votes
6
votes
Accepted
How to find all the possible products from a list of commutative $2 \times 2$ matrices?
Try this one-liner
...
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:
...
5
votes
Solving a system of linear equations modulo n
We now have LinearSolveMod in the Wolfram Function Repository
...
Community wiki
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 ...
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]
...
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 &...
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:
...
4
votes
Finite Differences:
We can use Difference[#,n] to get n order difference.
Flatten[#,{{2},{1}}] can be use to ...
4
votes
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 ...
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.
...
4
votes
Accepted
Find more relationships with LatticeReduce
If we limit vec to four elements and test all possible sublist we get more results.
...
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 ...
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 ...
4
votes
Accepted
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 ...
4
votes
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 ...
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 &...
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 ...
Only top scored, non community-wiki answers of a minimum length are eligible
Related Tags
linear-algebra × 1645matrix × 826
equation-solving × 216
eigenvalues × 163
performance-tuning × 110
numerics × 86
list-manipulation × 85
mathematical-optimization × 74
symbolic × 73
sparse-arrays × 67
plotting × 62
vector × 51
tensors × 48
calculus-and-analysis × 37
differential-equations × 36
functions × 34
algebraic-manipulation × 34
polynomials × 33
simplifying-expressions × 32
bugs × 26
inverse × 25
function-construction × 23
complex × 21
implementation-details × 21
warning-messages × 20