Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

1
vote
2answers
17 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 $4xn$ matrix by joining a specified number ...
4
votes
5answers
221 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
33 views

Inverting a lengthy matrix

I have a rather lengthy 10X10 matrix that I want to invert it. The matrix reads: ...
3
votes
2answers
96 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} & &...
2
votes
1answer
42 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 ...
0
votes
0answers
46 views

How can I convert a vector to a matrix? [on hold]

I have an eigen vector, λ1, and I want to convert it to a matrix for use. How can i do this? ...
3
votes
1answer
23 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 \...
2
votes
1answer
75 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
35 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
687 views
5
votes
2answers
101 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
70 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
74 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
63 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 ...
4
votes
1answer
77 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 x 15 matrix mat ...
0
votes
1answer
32 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
31 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
111 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
24 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
54 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
123 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
54 views

How to show the whole table

I have this code ...
1
vote
1answer
26 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 ...
0
votes
0answers
77 views

Solving the eigenvalue system [migrated]

$Au_{m,n}+Bu_{m-10,n-10}+Cu_{m+10,n+10}+Du_{m,n-10}+Eu_{m-10,n}=\lambda u_{m,n}$ where $A=0.01(m^2+n^2),\quad B=0.1(m+n),\quad C=0.1(m-n),\quad D=0.1 m, \quad E=0.1 n$. and $m,n$ range from $[-50,50]$...
4
votes
1answer
82 views

Delete zeros from a sparse array [duplicate]

Why doesn't SparseArray automatically remove zero entries? The code ...
1
vote
1answer
38 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, ...
1
vote
1answer
32 views

Why does it say “objects of unequal length”?

This is my code: ...
2
votes
1answer
116 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
80 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 ...
0
votes
1answer
27 views

Solving an equation involving a determinant (including spherical recursive functions)does not compute

I'm trying to solve this matrix to get a resulting function that depends on the variable Q (or if impossible, H3). When I try to to that I get two results: if I try to solve for Q, it doesn't show ...
1
vote
1answer
33 views

Find Transformation Matrix for Vectors of Functions, and Restrict Results of Solve Function

I have two vectors v,w which have a rather simple linear transformation A.v=w. My goal is to obtain ...
0
votes
2answers
51 views

Problem with FindShortestTour function

I'm new to Mathematica but I've read some documentation and guides and, unfortunately, haven't found a solution. There's the following matrix in the task: And I have to solve this TSP problem ...
0
votes
2answers
65 views

How to make a matrices of matrices (or block matrix)

I'm trying to construct a matrix H[i,j] that satisfies the "If" condition, in this case, if i==f then the main diagonal has a matrix stored, and also, the other non diagonal terms that are matrices ...
3
votes
3answers
517 views

Iteration on a matrix

I want to update "matrix1" 100 times. "matrix3" will be new "matrix1" and it will iterate 100 times. Should I use a loop or function? First iteration is: ...
0
votes
0answers
45 views

JordanDecomposition: Error Mesage eivn

I want to calculate the JordanDecomposition of the follwoing matrix: That is ...
-1
votes
1answer
33 views

I need to replace specific text in matrix

I have this matrix. ...
0
votes
2answers
56 views

Generate Random Symmetric positive definite matrix

Is there any way to create a random symmetric positive definite matrix ?
1
vote
0answers
52 views

Tensor Contraction Speed Up (Matrix Product States)

I'm recently trying to implement some tensor contractions in Mathematica for use in Matrix Product State algorithms. Here's the operation I want to perform $$ M^{\sigma_{i}\sigma_{i}'[i]}_{(b_{i-1},...
5
votes
2answers
124 views

Fast element-wise division of matrix, generated from vector with `Outer`, and another matrix

m = {a, b, c}; n = {{e, r, t}, {y, u, i}, {g, h, j}}; k = Outer[Divide, m, m]; k/n gives ...
2
votes
2answers
52 views

How to reduce the determinant of a matrix to its simplest form

I have a $ 12\times 12 $ matrix, of which I have taken the determinant. And I get a very big expression with three unknowns K1, ...
3
votes
2answers
83 views

Working Iterative formula for a system of equations

I have been given a project, I need to show the use of a version of Newton's method to solve these non-linear equations. The version of Newton's method I am required to use is: $ X_{n+1} = X_n - J^{(-...
2
votes
0answers
51 views

How can I perform the modified Cholesky factorization/Decomposition in Mathematica?

How to "Modified" Cholesky Decomposition in Mathematica? what I mean: V = L . D . Transpose[L] V is p*p(row is p,columns is p) non-negative definite matrix, D is diag[$d\small1$,$d\small2$,$d\...
4
votes
1answer
148 views

Solving the eigenvalue problem for a double well potential using a 1D particle in a box as a basis set

My first question is how would I go about getting the 1D particle in a box eigenfunctions using matrix techniques and how would I use the particle in a box eigenfunctions as a basis set for the ...
1
vote
1answer
38 views

Hessian matrix product in Taylor expansion of vector function

I am trying to get the 2nd order coefficient of the Taylor expansion at $\pmb{x}=\pmb{0}$ of ...
1
vote
1answer
62 views

Partial trace and Partial Transposition of a matrix easily? [closed]

Could someone help me to understand as to how to compute the partial trace and partial-transposition of an arbitrary matrix? I mean, is there any code to carry out these operations in Mathematica? ...
3
votes
3answers
77 views

Replacing a column of a matrix

I want to replace a column of a matrix. The best I've been able to come up with is ...
0
votes
1answer
114 views

Constructing a matrix from different blocks

Suppose I have a symbolic matrix called MAIN as follows $$ \begin{matrix} H_{00} & H_{01} & \ldots & H_{0n}\\ H_{10} & H_{11}& \ldots & H_{1n}\\ \vdots & \vdots & \...
0
votes
0answers
14 views

How to transform a real matrix with complex eigenvalues into a positive definite real matrix?

If the matrix had real eigenvalues, I would substitute the negative eigenvalues by a small positive number. However, I have complex eigenvalues... How should I proceed to transform the original ...