Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

Filter by
Sorted by
Tagged with
0
votes
0answers
31 views

To assign an array to a function

// Pre-defined parameter kS = 2*(\[Pi]*NefS)/LambdaSS; Here, NefS is a function of LambdaSS. The matrix m (i,j) defined corresponding value of NefS (jth ...
0
votes
2answers
80 views

How to calculate $(X^tX)^{-1}X^tY$? [duplicate]

This is MatrixForm[ {{1., 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}, {1, 1.5, 1.5, 1.5, 2, 2, 2.2, 2.4, 2.5, 2.5, 2.8, 2.8, 3, 3, 3.2, 3.3}}] $X^t$ ...
0
votes
0answers
35 views

Reshaping list of matrices

I have a list of square matrices $A_i$ as follows $$ \left(\begin{matrix}A_1 & \ldots& A_n \\A_{n+1}&\ldots &A_{2n} \\ \vdots & \ddots & \vdots \\ A_{(k-1)n+1} & \ldots &...
2
votes
1answer
41 views

Performance Tuning: Construction of Matrix with Summations

I am trying to solve an eigenvalue problem of a large matrix. The issue is that it takes too much time to construct this large matrix. This is the code that I built: ...
0
votes
2answers
100 views

Generating a large sample of 10 x10 symmetric matrices

I am currently having some issues with Mathematica. I have a 10x10 symmetric matrix with the diagonal entries removed and labeled as "z". I now want to create a command that generates a sample of ...
0
votes
2answers
95 views

Create special matrix

I need to construct special matrix in mathematica which is given in the following image
0
votes
1answer
77 views

Determinant of the symbolic matrix is giving very large expression

I have a symbolic matrix of size 16 by 16. I tried to get the determinant of this symbolic matrix, but it turned out to be a very large expression. How to make this expression concise so that it ...
0
votes
0answers
10 views

Evaluating a function over the rows of a matrix [duplicate]

I performed quite a search, and I am unable to find a quick solution to the following problem. I have a $p \times q$ matrix $c$, say c = {{1 , 3}, {3, 4}} and ...
0
votes
0answers
32 views

Inverting a matrix when its elements are given by difficult expressions?

I have a matrix which is composed by these elements: $$\mathcal{K}_{11} = \frac{3\alpha^{4/3}(4\mathcal{V} - \xi +6\alpha \sum_{k = 2}^n\lambda_k \tau_k^{3/2})}{4(2\mathcal{V}+\xi)^2(\mathcal{V}+\...
0
votes
2answers
51 views

Simplifying complex-valued entries in a matrix

I have a matrix where some entries are complex or roots of unity. For example, (-1)^(2/9) - (-1)^(5/9) + (-1)^(8/9) is one such entry and it is equal to 0. ...
1
vote
0answers
29 views

How to represent Dirac matrices in general $n$ dimensions in mathematica? [duplicate]

I want to represent Dirac matrices in $N$ dimensions in Mathematica like we have for the Pauli matrices, i.e. PauliMatrix[i], {i,1,3} I guess there must be some ...
8
votes
1answer
542 views

3.4 GHz Ryzen 5 slower to diagonalise large matrix than Intel i5-6300U 2.4 GHz

Sorry that this is quite a specific question but I need to diagonalise large matrices for the problem I'm trying to solve and can't for the life of me work out what's going on: I was expecting that ...
1
vote
1answer
40 views

How to extract a list from the table

What's and elegant way to extract List with components {x,y1} from the table with elements {x,{y1,y2,y3}?
0
votes
0answers
32 views

Selecting some vectors from a matrix

I am trying to write a code for band matrices that store only the nonzero vectors. For example if I have tridiagonal matrix of size 10, I want to store only the three diagonals as a vectors. n here ...
3
votes
1answer
56 views

Is it possible to solve for a matrix $ m $ satisfying $ m\cdot x=b $, given the vectors $ x $ and $ b $?

At first I thought it should be LinearSolve, which however turns out aiming at x, given m ...
6
votes
0answers
63 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{...
0
votes
0answers
55 views

The determinant of the matrix is very big, and solving becomes very difficult

I have a matrix of R1 of dimension 14 cross 14. I am trying to take the determinant, which happened to be the function of x and trying to find the roots of the determinant equation. But the det ...
4
votes
1answer
120 views

Numerically computing the eigenvalues of an infinite-dimensional tridiagonal matrix

I have one infinite dimensional tridiagonal matrix whose eigenvalues I have to compute. How can that be done numerically using Mathematica? Let me expose the concrete case I want to do it. I shall ...
0
votes
0answers
55 views

Why am I getting results containing Re and Conjugate?

Using the matrix Ham4LVLReg1, I am trying to get four vectors. Initially, I got the eigenvectors, and then, I computed the eigenvectors ...
9
votes
6answers
553 views

Finding the largest rectangular submatrix

I have a sparse non-symmetric binary matrix with a block structure. The dimensions of the matrix are thousands rows and less than one hundred columns. How do I identify the largest non-contiguous ...
2
votes
1answer
41 views

how to compounding more that one matrixs into other matrix? [duplicate]

How to let more than one matrix to compose as one matrix For example c = {{a, b}, {a, b}}; a = {{1, 0}, {0, 1}}; b = {{1, 1}, {1, 1}};
1
vote
2answers
83 views

Joining $4 \times 1$ vectors defined through functions to form a $4 \times n$ matrix

I define a $4x1 $column vector through a variable as: Z[i_]:=List[{a[i]},{b[i]},{c[i]},{d[i]}] I then want to make a $4\times n$ matrix by joining a specified ...
4
votes
5answers
446 views

How to join many columns of data in array?

I have large number of columns of data. How to put in single matrix? For example, with test data of 1 x 3 matrixs ...
0
votes
0answers
36 views

Inverting a lengthy matrix

I have a rather lengthy 10X10 matrix that I want to invert it. The matrix reads: ...
3
votes
2answers
115 views

Operation acting on arbitrary number of matrices, element-wise

I have a certain number of $N \times M$ matrices: $$ M_1 = \begin{pmatrix} a_{11} & a_{12} & ... & a_{1M} \\ a_{21} & & & \\ \vdots & & \ddots & \\ a_{N1} & &...
3
votes
1answer
143 views

Numerically solving a system of ODEs where the functions are vectorized

I am attempting to solve a system of ODEs where a, b, cv1 and ...
3
votes
1answer
38 views

Why doesn't this Kronecker Product work with columns, but with rows?

Using the formula given in this math.stackexchange answer by the user greg $$\eqalign{ vec(M\otimes dK) &= \left(\pmatrix{I_T\otimes (M \cdot e_1)\cr I_T\otimes (M \cdot e_2)\cr \vdots \cr I_T \...
5
votes
1answer
139 views

Calculating the trace of the product of several matrices

I want to calculate the trace of something like $\qquad\mathrm{Tr}(\Gamma_RG_d\Gamma_LG_d^\dagger)$ In order to optimise my code, I found something like this Faster trace of product of two matrices, ...
1
vote
1answer
43 views

Selecting from a matrix according to elements of a column — efficiency and speed?

I need to select all elements from matrix M that have in their 3rd column elements from some given list L (3rd column and L are real numbers). I have written the most obvious (to me) command to select ...
11
votes
4answers
783 views

Set every element to zero in matrix unless it's 1 or 1/2

I have the following code: ...
7
votes
2answers
158 views

Display Short Form of Large Matrix

Is there a way to display matrices in a shorter form similar to Short or Shallow? I find that I very often want to inspect the ...
4
votes
1answer
91 views

Fastest, and numerically stable way to compute $CA^{-1}B$ and $CA^{-1}x$?

I have to compute $CA^{-1}B$ and $CA^{-1}x$, where $A,B,C$ are conformable matrices and $x$ is a vector. I'm not sure if it helps, but $A$ is symmetric and positive definite. The $A$ matrix will be ...
0
votes
1answer
68 views

What is going wrong when I try to solve a simple linear equation? [closed]

I'm trying to understand how does the LinearSolve function works. I'm trying it out like this: A' ...
1
vote
2answers
99 views

How can I compute the dot product of an arbitrary number of matrices?

First I make an example with three matrices. M[1] = {{1, 2}, {3, 4}}; M[2] = {{1.1, 2.1}, {3.1, 4.1}}; M[3] = {{1.2, 2.2}, {3.2, 4.2}}; I want to calculate <...
1
vote
1answer
76 views

Problem with MousePosition after rotating a graphic

i've been doing a dynamic matrix plot using MousePosition but i need to rotate the plot 45°. but when i do that the MousePosition lose coordinates. Any idea of how to do the rotation keeping ...
6
votes
2answers
189 views

Catastrophic loss of accuracy in Orthogonalize

Context In connection to this question I am interested in orthogonalizing known matrices. As a test case, let us consider the definite positive $15 \times 15$ matrix ...
0
votes
1answer
38 views

Why SVD cannot recover the original matrix and suffer from numerical instability? [closed]

I have a matrix in mathematica that looks like $m= \left( \begin{array}{cccc} -i & 0 & 1 & 0 \\ 0 & -i & 0 & -1 \\ 1 & 0 & -i & 0 \\ 0 & -1 & 0 & -...
1
vote
2answers
34 views

Add value to nonzero elements of symbolic matrix

I would like to add a certain placeholder O to any nonzero element of a matrix. The matrix has elements which are not number but complicated symbolic expressions. ...
3
votes
3answers
146 views

using DeleteCases to delete vectors with particular index as 0

Assume I have a set of vectors set = {{0,1,1,0,1}, {1,0,1,1,1}, {1,1,1,1,0},{1,0,0,1,0}}. I want to delete the vectors which have the last entry as 0. In the ...
0
votes
1answer
46 views

How to write a command that produces such a matrix that takes n as an argument, where every node has probability 1/m [closed]

Please help in answering the questions above on mathematica. Which commands do I use to answer the question?
0
votes
1answer
25 views

Looping Constructs to create a set of varibale matrices

I am trying to create an $ n \times n $ matrix, which has cosine terms. I would like to select the values of the arguments of cosine terms from a random set of values that I have generated. My code ...
0
votes
2answers
58 views

Enter formula in matrix forms

Hello I am a new Mathematica user and I have to finish a school project using it. I have the following Matrix Form, I need to calculate the growth rate of the following data by year. The growth rate ...
1
vote
1answer
226 views

Bottom-most left-most entries in a sparse array

I have a list bdrs of SparseArrays, which represent the boundary matrices of a chain complex $R^{d_0}\overset{\partial_1}{\...
0
votes
2answers
65 views

How to show the whole table

I have this code ...
2
votes
1answer
118 views

Indices of nonzero rows in a sparse array

Given $A\!\in\!\mathbb{Z}^{m\times n}$ stored as a=SparseArray[{...},{m,n}], how can I obtain the list of all indices $i\!\in\!\{1,\ldots,m\}$ for which the $i$-th ...
4
votes
1answer
151 views

Delete zeros from a sparse array [duplicate]

Why doesn't SparseArray automatically remove zero entries? The code ...
1
vote
1answer
90 views

Why is part of the output “Null”? [closed]

Whenever I execute the code, portions of the output are null. How can I fix this? I am not sure the extent to which the result is invalid because I am not entirely familiar with the null output, ...
2
votes
1answer
93 views

Why does it say “objects of unequal length”?

This is my code: ...
2
votes
1answer
404 views

Change of basis in Mathematica

I'm trying to set up a change of basis matrix from the base V -> W with the RowReduce function that's built into Mathematica. I am then supposed to verify the result by taking the product of the ...
1
vote
3answers
180 views

How to collect eigenvectors corresponding to only real eigenvalues?

I have a set of eigenvalues which consists of real and imaginary values. Among these, I have one purely positive real eigenvalue and one purely negative real eigenvalue. How do I collect these two ...