# Tag Info

### How to check if a vector is an eigenvector of a matrix using mathematica?

You could use MatrixRank. Here is a function that does this: ...
• 131k
Accepted

### How to speed up RotationMatrix?

Having this problem so often, I also generated some tools to handle it which I'd like to share. This is the code (along with a usage message which is basically a small modification of ...
Accepted

### Speed up Do loops in MMA 13.0

Here's the fastest I've found: ...
• 236k

### How to roll a graph on the y-axis

We calculate the tangent vector of parametric curve {t^2,t} and the ArcLength from 0 to <...
• 72.9k
Accepted

### Find Elementary Matrices that produce RREF

Update April 29 2023 There is a newer version here Show steps in finding the reduced row echelon form of a symbolic matrix which now works on symbolic matrices also. edit May 12, 2022. Added frame ...
• 144k

### Get the coefficient matrix from a quadratic form

Here is a very short solution: qf = a x^2 + b y^2 + c z^2 + 2 d x y + 2 e x z + 2 f y z; 1/2 D[qf, {{x, y, z}, 2}] (* ==> {{a, d, e}, {d, b, f}, {e, f, c}} *) ...
• 97.3k
Accepted

### How can I reproduce the result of PrincipalComponents

I vastly prefer the formulation in terms of the singular value decomposition (SVD). This question gets asked a lot by users of these functions, so here's a quick reference: ...

### What are the counterparts in Wolfram to left and right division of a matrix in other programming language, e.g. Julia and MATLAB?

I just stumbled upon it! At least when storing the factorization in a LinearSolveFunction object, we can use it for the transposed solve by supplying a further (not ...
Accepted

### Efficiently defining a SparseArray function

The way the code is written, you can neither exploit packed arrays nor any vectorization. There are two major reasons: Using Rule prevents using packed arrays ...
Accepted

### Can someone boost even more my code?

Exploitation of low rank structure The ordering of summation/dot products is crucial here. As aooiiii pointed out, mat2 has a low-rank tensor product structure. So ...
Accepted

### How can I construct this matrix?

a[n_Integer?Positive] := Array[Mod[#2 - #1, n] + 1 &, {n, n}] a[6] // MatrixForm  \left( \begin{array}{cccccc} 1 & 2 & 3 & 4 & 5 & 6 \\ ...
• 47.5k

### What are the counterparts in Wolfram to left and right division of a matrix in other programming language, e.g. Julia and MATLAB?

The documentation for MATLAB's mrdivide states that The operators / and \ are related to each other by the equation B/A = (A'\B')' In light of this we may ...
• 70.6k

### Speed up Do loops in MMA 13.0

Hmm = With[{s = s}, Compile[{}, Table[1/(r + c - 1), {r, 1, s}, {c, 1, s}]]][]; // AbsoluteTiming (* {0.707614, Null} *) If you insist on ...
• 66.2k

### Is it possible to use the DGEEV and DSYEV LAPACK subroutines in Mathematica?

You can use LibraryLink to call LAPACK directly. It involves however quite a lot of boilerplate code. Here is an example: ...

### Elegant operations on matrix rows and columns

There are some internal, undocumented functions for row and columns operations: ...
• 236k

### Why does MatrixFunction with Sinc return this error?

Two things come into play: Sinc'[0] yields Indeterminate, when it should be $0$. This value needs to be evaluated in the ...
Accepted

### How to efficiently input matrices in Mathematica (compared to what MATLAB offers)

Quick-n-dirty. I dispense with open/close bracket, trivial to put in if it matters: ...
• 25.8k
Accepted

### Fast MATLAB, slow Mathematica: Export a matrix as TSV

After using them for several years, I have to admit that many Export routines in Mathematica are either broken or way too slow (a factor of 10 to 25 when compared ...

### How to solve this matrix equation

mat = ({{1, x, 3}, {2, 4, 5}, {2, 4, x}}); Select[MatrixRank[mat /. #] == 2 &][Solve[Det[mat] == 0, x, Reals]] {{x -> 2}, {x -> 5}}
• 395k
Accepted

### Finding "chains" of numbers in a matrix

Maybe someone can build on this to actually get all such paths, but in the meantime, here's something to get you started! Here's how you can get a graph whose vertices are elements of the matrix at ...
• 9,010

### Speed up Do loops in MMA 13.0

As other answers have suggested, a better approach here is to stick to high efficient functional way, and try to take advantage of "vectorizable" operation when possible. For OP's question, ...
Accepted

### How to plot the $\varepsilon$-pseudospectrum of a matrix

I still haven't gotten around to implementing the Arnoldi-based algorithm of Toh and Trefethen, so what follows is straightforward, but not very efficient code for visualizing $\varepsilon$-...

### Matrix indexed by one number

Partition[ Array[a, 4], 2] will do it. In general, makeMat[n_, m_] := Partition[ Array[a, n*m], m]
• 235k
Accepted

### Square root of a 2 by 2 matrix using MatrixPower[]

The nice thing about Mathematica is that one can (almost) always go back to the definitions if in doubt. For evaluating non-principal roots, one can just go back to the Jordan decomposition of a ...
Accepted

### Are compound matrices implemented in mathematica?

I don't think that they are built-in, but they are easy enough to implement: ...
Accepted

### Expressing the n-th power of a matrix

You need to understand that Mathematica prefers to write some numbers in their closed form because with numerical values, you would loose information and probably precision. It is kind of why it is ...
• 113k

### Noise filtering in images with PCA

Start data First let us get some images. I am going to use the MNIST dataset for clarity. (And because I experimented with similar data some time ago.) ...
• 37.8k
Accepted

### Why doesn't Mathematica return the identity matrix for the 0-th power of a singular square matrix?

Consider a general $2\times 2$ matrix, and its general power $n$: ...
• 24k
Accepted

### qz like function in Mathematica

As already hinted, Mathematica is perfectly capable of computing the eigensystem of a pencil. However, none of the commenters gave the function that is the closest to the functionality of MATLAB's <...