Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

239 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
14
votes
1answer
370 views

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) \\ ...
11
votes
0answers
750 views

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 ...
11
votes
0answers
523 views

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 ...
9
votes
0answers
126 views

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 ...
9
votes
0answers
196 views

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: ...
8
votes
0answers
282 views

Extracting the principal component analysis vectors in the original basis

I'm using Mathematica's PrincipalComponents[] to do a principal components analysis on a data set with m data points and n variables (m > n). The command produces ...
8
votes
0answers
173 views

Why has Version 10.3 precision reduced?

In version 7.0.1.0 and versions 10.0 and 10.1 the following is produced: ...
7
votes
0answers
339 views

Examples of using Mathematica to solve matrix equations symbolically

Suppose we want to solve a linear system like $$\left\lbrack\begin{array}{cc}M& S\\ -S^\mathrm{T}&0 \end{array} \right\rbrack \left\lbrack \begin{array}{c} x\\y\end{array}\right\rbrack = \...
7
votes
0answers
442 views

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 ...
6
votes
0answers
66 views

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{...
6
votes
0answers
131 views

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 ...
6
votes
0answers
1k views

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 ...
5
votes
0answers
96 views

Arbitrary Precision, Nearly-Singular Matrices, and LinearSolve

I have been trying to solve a nonlinear eigenvalue problem, $\mathbf{M}(\lambda) \mathbf{v} = 0$, in Mathematica using Newton's method. The core of the algorithm relies upon an inverse iteration, ...
5
votes
0answers
139 views

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 ...
5
votes
0answers
633 views

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$ ...
5
votes
0answers
983 views

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 ...
4
votes
0answers
134 views

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 ...
4
votes
0answers
65 views

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: ...
4
votes
1answer
285 views

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 (...
4
votes
0answers
221 views

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 ...
4
votes
0answers
169 views

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. (...
4
votes
0answers
156 views

Sparse matrix multiplication mod p

Let A and B be sparse matrices with integer coefficients between 0 and ...
4
votes
0answers
594 views

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: ...
4
votes
0answers
286 views

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 ...
4
votes
0answers
465 views

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 ...
4
votes
0answers
1k views

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 ...
4
votes
0answers
1k views

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 ...
4
votes
1answer
355 views

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 ...
3
votes
0answers
74 views

Hafnian of a matrix

Is there a Mathematica built-in function for the calculation of the Hafnian of a matrix? I am interested in the function as it appears naturally in the calculation of moments of a multivariate ...
3
votes
0answers
80 views

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}, ... , ...
3
votes
0answers
78 views

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: ...
3
votes
0answers
82 views

How to extract positions of a set of linear independent components of a matrix / tensor?

Given a in general non-symmetric matrix / tensor of arbitrary shape A, I want to obtain efficiently the positions of a set of linear independent components of ...
3
votes
0answers
199 views

Matrix Exponentiation

This is in continuation with this one but it is more general. I will try to make it self contained. I have a program and I need to take the Dot product of many ...
3
votes
0answers
656 views

Differentiation of a matrix function

I'd like to compute the derivative (Jacobian) of the function $\mathbf{\Psi\left(\mathbf{F}\right)}$ w.r.t. $\mathbf{F}$ where $\mathbf{F}$ is a 2x2 matrix and $G$ and $v$ are just real constants; $$ ...
3
votes
0answers
316 views

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, ...
3
votes
0answers
90 views

How to ArrayFlatten some matrix which have repeated element

I have many such matrices(whose dimension are all 3*3.) like: ...
3
votes
0answers
255 views

Why does Eigenvalues work for a matrix $\{M\}$ but not $\{\{M\}\}$?

Suppose I have a matrix {{1, 2}, {3, 4}} which I'll call mat. In a blur of human error, I computed the eigenvalues of ...
3
votes
0answers
81 views

Optimization for iterating and plotting a matrix product and its elements?

I have an iterative matrix product of this type $$ \begin{pmatrix}y_{n+1} \\ x_{n+1} \end{pmatrix} = \begin{pmatrix} A & B \\ C & D \end{pmatrix} \begin{pmatrix}y_{n} \\ x_{n} \end{pmatrix} $...
3
votes
0answers
960 views

Mathematica's Singular Value Decomposition different from another math engine

I’ve been working with SVD – singular value decomposition. Things weren’t working as expected. Thus, I looked over to Matlab and executed the following code: ...
3
votes
0answers
113 views

FindInstance of Matrices

I'm trying to use FindInstance to find examples of matrices that complete an expression. However, it seems like I need to specify atomics as my variables to the ...
3
votes
0answers
141 views

Diagonalisation of equations for NDSolve

I have a linear matrix differential equation and I wish to speed up evaluation by diagonalising using eigenvectors. There is an example in Help for finite elements under "swinging beam" that is ...
3
votes
0answers
646 views

Fast export of large numerical data

Edit It seems that the bottelneck is not due to eigen value problem. I will esit the question soon. I have a 6000by6000 matrix which I got after some calculations. I want to get the eigenvalues and ...
3
votes
0answers
255 views

The CorrelationMatrix is equal to corrcoef of Matlab?

How can I generate a matrix which is equivalent to the results of the "correlation coefficients" command (corrcoef) in Matlab? When I make a LinearModelFit, I can get a CorrelationMatrix, but is this ...
3
votes
0answers
255 views

Mathematica Complains about Non Symmetric Covariance matrix, when it's not the case

I was doing some fitting with Mathematica7 using NonlinearModelFit. It's quite long the program to do the fit and that's why I am not displaying here ... It goes ok, and I can get the fit parameters ...
3
votes
1answer
358 views

How to generate a $ 9 \times 9 $ matrix like Sudoku ?

i want to generate a matrix that the number in each row, colum contains 1-9,and not repeated. my code always fall into no solution. here is my code. ...
2
votes
0answers
21 views

`MatrixFunction` is returning a cryptic error message about “the function `1`”

The "Possible Issues" section of the documentation for MatrixFunction lists several possible ways in which a call to ...
2
votes
0answers
86 views

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 ...
2
votes
0answers
34 views

What kind of performance should I expect out of Eigensystem using FEAST?

I'm numerically solving a time-independent Schrödinger equation using Eigensystem's FEAST method. It takes a lot longer than I ...
2
votes
0answers
73 views

Block diagonalizing a complex anti-symmetric matrix

I am going to evaluate the block diagonal form of few skew-matrices. When matrix elements are real I can simply follow the approach suggested in this thread which I have implemented that as ...
2
votes
0answers
49 views

How to calculate a projection of x,y,z data to x any y plane?

I have a List containing x,y,z data, which I can plot nicely in a ListContourPlot: ...

1
2 3 4 5