Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

429 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
16 votes
2 answers

Factorize trigonometric matrices

Consider two square matrices $A_1$ and $A_2$. Consider the following matrix involving matrix trigonometric functions: \begin{equation} M_1(t)=\begin{bmatrix} \cos(tA_1) & t\mathrm{sinc}(t A_1) \\ ...
anderstood's user avatar
  • 14.3k
13 votes
0 answers

What algorithm is Mathematica using to find the smallest eigenvalue so quickly?

My question is what kind of black magic is Mathematica doing to obtain the correct answer so quickly compared to other programming languages? Details: I've written a Mathematica notebook to find the ...
Daniel Walsh's user avatar
11 votes
0 answers

How to speed up calculations on big symbolic matrices?

this is my first time posting something on a community of the StackExchange platform, so please feel free to correct me if I'm doing something wrong. :) Additionally you should probably know that I'm ...
TSwift's user avatar
  • 121
10 votes
0 answers

Bug in PositiveDefiniteMatrixQ?

Fixed in 10.1.0. Exists in at least 9.0.1 -- 10.0.2. This seems like a bug in PositiveDefiniteMatrixQ to me: ...
Teake Nutma's user avatar
  • 5,981
9 votes
0 answers

Symbolically evaluating gradients/Hessians

I'm taking a machine learning course, which involves taking a lot of analytical gradients and Hessians. It would be ideal if I could perform these calculations in Mathematica. However, I am only aware ...
user48151's user avatar
8 votes
0 answers

Why has Version 10.3 precision reduced?

In version and versions 10.0 and 10.1 the following is produced: ...
Chris Degnen's user avatar
  • 30.9k
7 votes
0 answers

Differing behavior of Eigenvalues and Eigensystem

With the update to v12.0, I seem to be getting different behavior of eigenvalues returned by Eigenvalues and Eigensystem (oddly, ...
erfink's user avatar
  • 1,089
7 votes
0 answers

Inverse of a large sparse Hermitian block matrix

I am looking for a method (if it exists) for the inverse of a large sparse Hermitian block matrix. The off diagonal sparse matrices, named δ are 4x4, and they have ...
Raffaele Carlone's user avatar
6 votes
0 answers

Solving a matrix pencil (quadratic eigenvalue) problem with Mathematica

According to Wikipedia The matrix pencil of degree $\ell$ is the matrix-valued function defined on the complex numbers $L(k) = \sum_{i=0}^{\ell} k^{i} A_{i}$. Here $A_{\ell}$ are non-zero $n\times n$...
Rob's user avatar
  • 433
6 votes
0 answers

Where is the mistake in computing the particular eigenvector of the following DFT Matrix?

I have the following matrix (the DFT Matrix for N = 3) $$W = \frac{1}{\sqrt{3}}\begin{pmatrix} 1 & 1 & 1 \\ 1 & e^{-\frac{i 2 \pi}{3} } & e^{\frac{i 2 \pi}{3} } \\ 1 & e^{\frac{...
Sotiris's user avatar
  • 116
6 votes
0 answers

MatrixPower performance

In Mathematica 9, (I think) MatrixPower[matrix(m.m), n].vector has complexity $O(m^{2+\epsilon}\times\log(n))$ (Mathematica automatically find the algorithm that ...
user202729's user avatar
6 votes
0 answers

Export matrix to $\LaTeX$ with style

Is it possible to export a matrix to $\LaTeX$ with style? For example this code will create a matrix with equal spacing matrix and with background colors in some cell, is it possible to export that ...
xslittlegrass's user avatar
5 votes
0 answers

How to efficiently apply PCA followed by SVD to extract the components of PCA?

I am working on segmenting a textured image using Gabor Filters. This is based on this paper. There exist a Matlab implementation of this as well. Earlier I managed to do up to this. With the help of ...
user36426's user avatar
  • 3,335
5 votes
0 answers

Is Mathematica a good choice for a scientific project with Machine Learning?

I'm a chemist with some rudimentary programming skills and in the middle of the year I'll be starting a project concerning machine learning, so, I'm sorry if I'm going to ask two questions in this ...
HCSthe2nd's user avatar
  • 193
5 votes
0 answers

Finding eigenvalues in Mathematica: why so slow?

I am trying to find the eigensystem of a large sparse real symmetric matrix, and I only need the lowest 40 or so eigenstates. The relevant code is as follows: ...
Xiao's user avatar
  • 111
5 votes
0 answers

How to invert a matrix with 100 trillion elements?

I have a $10^{7}\times 10^{7}$ matrix with the following properties: it is sparse it is gamma-5 it is almost Hermitian. If $M$ is the matrix we are trying to invert, we know $M=A M^{\dagger} A$ ...
M.R.'s user avatar
  • 31.5k
5 votes
0 answers

Fast principal component analysis

I'd like to speed up a principal value value analysis. The data contains a large set of vectors with a large dimension. Both are in the range of 1000. I want to obtain the loadings matrix for further ...
AWi's user avatar
  • 51
5 votes
0 answers

Symbolic matrix calculus: What's new in Version 9

I have seen some of the related posts, which ask about doing matrix calculation on tensors unknown dimensions. One of the posts mentioned that version 9 has some capability, but it was concerned about ...
nonlinearism's user avatar
4 votes
1 answer

Finding real solution(s) to a complex equation

I have a matrix matA defined as ...
Zubin's user avatar
  • 425
4 votes
0 answers

Efficiently calculating half of the eigenvectors of a sparse array

Eigenvectors of a sparse array $\quad$ Problem statement I want to calculate the eigenvectors corresponding to the negative eigenvalues of an $8L^2 \times 8 L^2$ matrix ($L \sim 30 )$. Most of the ...
Lucas Freitas's user avatar
4 votes
0 answers

Solving or Minimizing the Norm of the matrix equation $M^TAM - M^TB - B^TM =C$

I am trying to solve the matrix equation $M^TAM - M^TB - B^TM=C$ where I know A, B and C. My unknown matrix is M which has the special form that all the rows and columns sum to zero. i.e. I have four ...
1729taxi's user avatar
  • 767
4 votes
0 answers

How to efficiently build a large sparse matrix and overloading a compiled function?

I would like to construct a large sparse matrix folding from rank-4 tensor given by the following: $\mathcal{L}_{1L}^{00}(i,j)=\mathcal{L}_{1L}^{00}(m_1,m_2;M_1,M_2)$ The indices of matrix $(i,j)$ are ...
Bob Lin's user avatar
  • 445
4 votes
0 answers

Finding matrix in Krylov subspace (Lanczos method)

The Lanczos method for finding the smallest eigenvalue of a hermiteian matrix $H$ is based on the construction of a vector subspace (Krylov space) where one can build a matrix $H_{Krylov}$ which is ...
Matteo's user avatar
  • 283
4 votes
1 answer

How do you ask someone to input the values of a matrix?

I'm trying to set up code that basically asks the user to input the values of a matrix with a certain key size. I want them to first enter the keysize and then ask for all of the entries necessary to ...
Alex Konar's user avatar
4 votes
0 answers

Orthogonal matrix decomposition of symmetric matrix?

If matrix mat is symmetric, we should be able to decompose it into eigenvalue matrix matJ and orthogonal matrix ...
Kagaratsch's user avatar
4 votes
0 answers

Is this the most idiomatic way to convert matrix into dataset?

Is this the most idiomatic way to convert matrix into dataset? (for Mathematica 10 or higher) I was kind of hoping this would work: ...
Luxspes's user avatar
  • 920
4 votes
1 answer

Implementing positivity constraints over a six-dimensional hypercube

This question involves the same subject matter as my previous one (How can one achieve the most accurate estimates of certain six-dimensional integrals under specific constraints?), but with another (...
Paul B. Slater's user avatar
4 votes
0 answers

What real symmetric matrices of this type can Mathematica find symbolic eigenvalues for?

I'm working on a problem calculating symbolic eigenvalues of matrices that always have a very simple form: they are real and symmetric and usually sparse. They have two distinct symbolic parameters. (...
William Kennerly's user avatar
4 votes
0 answers

Is it possible to do matrix algebra symbolically?

I'm reading a book that has the following theorem: I am trying to make Mathematica perform these calculations for me. Is it possible to do it without having to declare the matrices? For example, ...
Red Banana's user avatar
  • 5,329
4 votes
0 answers

Sparse matrix multiplication mod p

Let A and B be sparse matrices with integer coefficients between 0 and ...
Oliver Miller's user avatar
4 votes
0 answers

Real Canonical Form of Arbitrary Size Matrices

I have been searching the site and the Mathematica documentation, but have not found anything regarding this. If we find the Jordan Form of the following matrix, we get complex values, but I would ...
Moo's user avatar
  • 3,270
4 votes
0 answers

How can I force the use of sparse diagonalization methods?

When I evaluate the Eigenvalues function on a very large (e.g. 2^16 x 2^16) sparse matrix, Mathematica says something like: Because finding 65536 out of the ...
P.R.'s user avatar
  • 93
4 votes
0 answers

Analytically solve the eigenvalue problem with infinite dimensions by Mathematica?

If I am given a symbolic expression of all the matrix elements in an infinite-dimensional space, e.g., the Hamiltonian of a quantum mechanical system, is it possible to get the symbolic expression for ...
REX's user avatar
  • 41
4 votes
1 answer

How to accelerate updating some parts of sparse matrices?

I am trying to update some parts of an specific matrix as rapidly as possible. In what follows, I first set up the basics things that I want to use ...
M.J.2's user avatar
  • 491
3 votes
0 answers

Elegant operations on associations and datasets

As a useful extension of this question: Elegant operations on matrix rows and columns I would like to ask: What are for you elegant, short, useful or frequently used functions to use with ...
eldo's user avatar
  • 69k
3 votes
0 answers

First few smallest eigenvalues of a large dense symmetric matrix

I construct a large (say 2000x2000) matrix M whose entries are real random variables drawn from a certain distribution. Most of these values will be nonzero, so <...
sonarventu's user avatar
3 votes
0 answers

Speeding and avoiding unwanted crash of nested Table by `NearestNeighborGraph`

I have a code that generates coordinate points for a 2 dimensional lattice. So the coordinates are of the form {x,y}. Now, I generate a graph out of these ...
Shamina's user avatar
  • 633
3 votes
0 answers

Fastest Way to make rows and columns zero and corresponding (i,i) element 1 of a large Sparse Matrix

I have a 5552 by 5552 sparse matrix: ...
S.B.MD.Khaja Moinuddin's user avatar
3 votes
0 answers


According to the documentation, Transpose with a second argument {1,1} on a square matrix returns the diagonal of the matrix. ...
Whelp's user avatar
  • 1,715
3 votes
0 answers

Lanczos method to tridagonalize a matrix

I want to tridagonalize a sparse matrix using the Lanczos algorithm. I am working with a very large sparse matrix and I need some speed. In the following for example ...
Rasoul-Ghadimi's user avatar
3 votes
0 answers

Extract the dynamical map from the density matrix

I am working on open quantum systems and have been wondering whether there is a way to extract the dynamical map using mathematica. Say we have a density matrix $\rho(t) = \begin{bmatrix} p_{00} + (1 -...
dan's user avatar
  • 113
3 votes
0 answers

Reducing to Irreducible Representations

Group Theory Background / Utilities Suppose I give you a list G of matrices which represent some group, in that the matrices are closed under multiplication. In ...
evanb's user avatar
  • 6,026
3 votes
0 answers

Packages for study presentation of groups

This question asks if there are tools/packages in Mathematica for the study of presentation of groups, but it is almost 7 years old and an answer suggests to use Combinatorica package which is now ...
mattiav27's user avatar
  • 6,687
3 votes
0 answers

Does MMA have a built-in function or a user-defined function to judge whether the two matrices are congruent

It can be seen from the following relationship that matrix A and matrix B must be congruent matrices with each other: ...
A little mouse on the pampas's user avatar
3 votes
0 answers

Converting complex equations to matrix form

My question is a continuation of the topic: How to convert equation to vector (matrix) form? It is necessary to separate the components of equations into vectors and matrices and a combination of ...
dtn's user avatar
  • 2,394
3 votes
0 answers

Computing the invariant factors of a sparse matrix

Let M be a sparse $n\times m$ integral matrix, where $nm$ is very large. The goal is to compute its invariant factors. The naïve approach ...
AccidentalFourierTransform's user avatar
3 votes
0 answers

What's the usefulness of SymmetricMatrixQ and PositiveDefiniteQ if they fail with this matrix?

Let's define ...
An old man in the sea.'s user avatar
3 votes
0 answers

Antisymmetric Matrix Eigenvector Normalization

So, I have a complex $4n \times 4n$ antisymmetric matrix, $A$ and it has a non-degenerate spectrum. The matrix $A$ then has eigenvalues given by $$ \beta_{1}, -\beta_{1}, \beta_{2}, -\beta_{2}, ... , ...
user1058860's user avatar
3 votes
0 answers

AceFEM: Matrix condensation and elimination of local unknowns

Lately I have been working with non-linear mixed hybrid elements. The basic article that I took for my research is one by T.H.H. Pian dn K. Sumihara: Rational approach for assumed stress finite ...
Marko's user avatar
  • 464
3 votes
0 answers

Matrix elements in terms of Minors?

Is there a simple way to rewrite a rectangular $m \times n$ matrix in terms of its maximal minors? For a few small cases, $(m,n)$ = $(2,3),(2,4),(3,4)$ I can brute force by explicitly solving: ...
jjstankowicz's user avatar

2 3 4 5