Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

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

Accelerating sum over permutations of matrix elements

I am trying to short-cut the use of a CoefficientArrays call by manually calculating the resulting matrix of coefficients myself (this avoids using symbolic arrays ...
user avatar
-3 votes
0 answers
25 views

General symbolic computations of matrices using Schur complement

Suppose $A,B$ are $n \times n$ square matrices of the form $A = \left[C_{1}\middle|\frac{I}{0\dots0}\right], B= \left[C_{2}\middle|\frac{I}{0\dots0}\right]$. Say $C_{1} \rightarrow a_{i}$ and $C_{2} \...
user avatar
  • 165
0 votes
1 answer
32 views

Table size/dimension error

I'm trying to create a table of the form ...
user avatar
3 votes
0 answers
44 views

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 <...
user avatar
0 votes
1 answer
95 views

Plot eigenvalues of a matrix with two variables [closed]

I am trying to plot eigenvalues E(kx,ky) of the matrix [mat] depends on two variables kx and ky and of course n its dimension , and the matrix elements a, b and c depend on cos(kx) ; cos (ky) and cos(...
user avatar
  • 19
0 votes
0 answers
33 views

LyapunovSolve does not give me the correct answer

I am trying to solve an equation using LyapunovSolve, but it does not give me the correct answer. The correct answer should be a 6*6 matrix while by utilizing the Dimension command, it shows me {2}. ...
user avatar
-4 votes
1 answer
67 views

Constructing NxN tridiagonal block diagonal matrix with N is a variable [closed]

Hi please can someone help me writing a program of generating a tridiagonal block matrix with dimension of NxN where N is a variable can be 50, 100, 200, 300...etc , Well I don't know how I'm a ...
user avatar
  • 19
0 votes
1 answer
46 views

Solve eigen-matrix equation

When I read an article by Garbe, where have an eigenmatrix $$B M_i + M_i B^T=\lambda_iM_i$$ and have the following eigenmatrices and eigenvalues: $$ M_0=\begin{bmatrix} 0 & 1 \\ -1 & 0\end{...
user avatar
2 votes
0 answers
127 views
+50

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 ...
user avatar
  • 571
2 votes
1 answer
82 views

Calculating power series of quantum operators on kets

I am using the "Quantum" add-on package to perform some quantum mechanical calculations using SU(1,1) generators. The code that I've developed reads ...
user avatar
  • 655
0 votes
0 answers
41 views

How to compile a matrix with mixed values?

Consider some matrix matrix = {{a,,...,b,...},...}, where a,b are some strings (like "Name"), ... inside the row corresponds to numbers, and ... are ...
user avatar
  • 4,038
2 votes
1 answer
61 views

Calculating the matrix product of the elements of a table

I am trying to compute the matrix product of all the elements of a table of the following form : ...
user avatar
1 vote
1 answer
92 views

Manipulating a Haar random unitary matrix and computing probabilities

I am new to Mathematica and its many features. Here is a problem that I was trying to model. Consider a $4 \times 4$ Haar random unitary $U$. Define by $|00\rangle \langle 00|$ the following matrix: \...
user avatar
4 votes
1 answer
47 views

Proper usage of Assuming statement

I want to evaluate a command under an assumption, and thought Assuming was the right way to go. Suppose we want to calculate a Matrix rank. Following the second ...
user avatar
  • 251
0 votes
1 answer
46 views

How to make a matrix a set of variables to be manipulated?

I have the following f[xx_, xy_, yx_, yy] := {{xx, xy}, {yx, yy}}; f[a_] = f[xx, xy, yx, yy] but I don't want to write all the variables for future applications, I ...
user avatar
0 votes
2 answers
53 views

How to make matrix elements variables [closed]

I have the following matrix mat := {{xx, xy}, {yx, yy}}; I want to be able to manipulate the matrix elements with the manipulate function ...
user avatar
0 votes
1 answer
48 views

Converting a list of values to a criterion

Say I have a list of 4 integers valList = { v[1], v[2], v[3], v[4] } whose values may or may not be equal to one another. Now I would like to extract all rows from ...
user avatar
  • 1,032
6 votes
1 answer
163 views

VectorAround problem

I am trying to replicate an example give here of correlated variables (it's similar to a more complex problem I'm working on). I've included the example data and method for convenience: ...
user avatar
  • 424
5 votes
1 answer
165 views

Efficient computation of a matrix times its transpose

Let m be a huge matrix and say I want to calculate m.Transpose[m]. The result will be a symmetric matrix, and so it feels like ...
user avatar
  • 1,032
2 votes
1 answer
83 views

Minimize Sum of Hamming Distances

Problem: Given an $n \times m$ matrix with binary values $(0,1)$, find a binary vector that minimizes the sum of Hamming Distances to the rows. Example: If the matrix is {{$1,1,1$},{$0,0,0$},{$1,0,1$}}...
user avatar
  • 33
3 votes
1 answer
104 views

Proof of symbolic matrix

For any n-order matrix A, B, H $[A, B] \stackrel{\text { def }}{=} A B-B A$ Try to prove: (1) $\left[k_{1} \boldsymbol{A}+k_{2} \boldsymbol{B}, \boldsymbol{H}\right]=k_{1}[\boldsymbol{A}, \boldsymbol{...
user avatar
  • 1,407
1 vote
0 answers
32 views

Power of trigonometric function matrix [closed]

Calculate the m-power of the following trigonometric function matrix (m>0): $\boldsymbol{A}=\left(\begin{array}{cc}\cos \varphi & -\sin \varphi \\ \sin \varphi & \cos \varphi\end{array}\...
user avatar
  • 1,407
0 votes
0 answers
48 views

Droping a row from a matrix [duplicate]

I want to drop a row from a matrix but the output seems to be: MatrixForm[] My code: ...
user avatar
  • 1
1 vote
0 answers
36 views

SemiDefiniteOptimization - The matrix is not symmetric error [closed]

I get the following error, SemidefiniteOptimization::herm: The matrix {{0.00256497,0.00128248,0.00128248,0.00128248,0.00128248,2.4286110^-17,6.9388910^-18},{0.00128248,0.00128248,-0.0362029,-0....
user avatar
  • 422
4 votes
3 answers
217 views

Plotting resolvent of the matrix

I'm trying to reproduce resolvent plot of circulant matrix, page 59 of Mark Embree's slides Straightforward solution below, relying on ComplexPlot3D is below. It ...
user avatar
2 votes
1 answer
62 views

Sorting of a list of lists - i.e. list of matrices - what is the order of the sort determined by?

In the documentation we have: Sort[list] sorts the elements of list into canonical order. Maybe I am missing something but what does "canonical order" mean for sorting a list of matrices? ...
user avatar
  • 525
9 votes
1 answer
288 views

Eigendecomposition of a matrix with a variable

I have an issue with a decomposition of a matrix $B$ that is positive semidefinite and that depends on a parameter $x$. Writing $\lambda_i\geq0$ the eigenvalues and $\psi_i$ the corresponding ...
user avatar
  • 93
5 votes
3 answers
204 views

matrix Crop (remove leading and trailing zeroes in matrix)

I have some matrices that have 0's around them, for example, give such a matrix MatrixForm[ mat = ArrayPad[{{1, 2, 3}, {0, 0, 0}, {7, 8, 0}}, {{1, 2}, {2, 3}}]] \...
user avatar
  • 5,102
1 vote
1 answer
57 views

How to make an inverse operation to `KroneckerProduct[A, IdentityMatrix[m]]` (simplify matrix)?

The operation KroneckerProduct[A, IdentityMatrix[m]] expands the matrix A in the following way (depending on order of ...
user avatar
  • 2,911
0 votes
1 answer
58 views

How to untensor a tensor?

What should I do to convert a matrix of matrices to a non-nested matrix? $\left( \begin{array}{cc} \left( \begin{array}{cc} {a_1} & {b_1} \\ {c_1} & {d_1} \\ \end{array} \right) & \left(...
user avatar
  • 2,911
1 vote
3 answers
86 views

How can I realize this matrix product (dot product of matrices of different orders)?

The matrix multiplication of square matrices of different order is often claimed to be impossible. Yet, if the order of one matrix is divisible by the order of the other, a natural multiplication rule ...
user avatar
  • 2,911
5 votes
1 answer
147 views

Finding eigenvectors of a symbolic matrix

I have a $2\times 2$ symbolic matrix for which I want to compute the eigenvalues. It is given as: Clear[a, b, m] m={{a, b}, {b, -a}} and it spits out the ...
user avatar
  • 151
3 votes
1 answer
157 views

Matrix Integro-differential equation

I'm trying to solve this integro-differential equation to obtain the density matrix elements $\rho$. $ \frac{d\rho}{dt}=-i[H_{0}(t),\rho(t)]-A^{2}\Big[H_{1},\int_{t1}^{t}e^{-B(t-s)}\Big(e^{-i\int_{s}^{...
user avatar
4 votes
1 answer
77 views

How can I have Mathematica solve the curve equation when nested functions are involved?

In the context of Quantum Computing, I am investigating curves that illustrate an error propagation during qubit rotations on a Blochsphere (I asked a related question in the same context here and ...
user avatar
7 votes
8 answers
437 views

How to replace anti diagonal elements of a matrix

I want to assign new values to the anti-diagonal elements of a square matrix m with the values of its diagonal elements. For that, I want to make use of ...
user avatar
  • 319
6 votes
1 answer
90 views

Does converting large 3D matrices to VERY large 2D matrices affect speed of operations done on the matix?

Novice question! Does the dimensionality of a matrix affect the speed of operations performed on it (or the speed of retrieval of values from it) IF the total number of elements in the matrices are ...
user avatar
  • 185
1 vote
1 answer
80 views

Convert List to Matrix [closed]

I have the lists in matrix form, as shown in the screenshot fig.2 below. I would like to convert it to pure matrix like fig.1 Edited: For example: ...
user avatar
  • 143
4 votes
1 answer
159 views

Nonnegative Least Squares Algorithm (NNLS) [closed]

Can anyone optimize the code below which is developed in an old version of Mathematica (2003) both in terms of efficiency and adaption to the latest versions of Mathematica? Description of the code: ...
user avatar
1 vote
0 answers
83 views

Solve 2x2 complex unitary matrix with constains using Solve does not work

I have a 2x2 complex-valued matrix, $U=\pmatrix{U_{1,1}e^{i\theta_{1,1}}&U_{1,2}e^{i\theta_{1,2}}\\ U_{2,1}e^{i\theta_{2,1}}&U_{2,2}e^{i\theta_{2,2}}}$ which I must impose two ...
user avatar
0 votes
0 answers
41 views

Matrix row addition inside NDSolve

I'm using NDSolve and my variables are matrix elements so that the equations to be solved are in matrix form. Here is the MWE ...
user avatar
  • 1
2 votes
2 answers
96 views

Solution to a linear equation with minimum rank

Suppose I have a linear equation, $X.M=A$, for given matrices $M$ and $A$. I can use FindInstance to produce a solution $X$. How can I add the constraint that $X$ has the least rank? Indeed, I could ...
user avatar
0 votes
0 answers
50 views

How to express elemental operations in matrix form?

I ran the following code: X = Array[x, {5, 4}]; W = Array[w, {4, 3}]; Y = Array[y, {5, 3}]; D[Norm[X.W-Y, "Frobenius"]^2, {W}]//MatrixForm However, mma ...
user avatar
  • 1
2 votes
0 answers
60 views

In an element of a matrix, can I refer in an element to its own row or column? [closed]

In an expression inside the matrix, can I obtain the indices of the element where this expression is located? Also, can I refer to other elements of that same matrix, like in spreadsheets?
user avatar
  • 2,911
3 votes
2 answers
204 views

How to obtain independent variables from a set of linear constraints

I have a question, how to obtain independent variables from a set of linear constraints. Let me illuminate this by a simple example, we have 5 variables and 3 linear constraints, $x1+x2+2*(x3+x4)+x5=...
user avatar
0 votes
0 answers
48 views

How to use Manipulate for Finite Differences

I want to improve my code using the command Manipulate and being able to see the calculus of averages as the indexes l and u are moved. I did a simple example of a 4x4 matrix with the boundary ...
user avatar
1 vote
2 answers
93 views

How can I generate a tridiagonal block matrix? [duplicate]

$$\begin{pmatrix}C&D&&&&\\D&C&D&&&\\&\ddots&\ddots&\ddots&&\\&&&D&C&D\\&&&&D&C\end{pmatrix}$$ I want ...
user avatar
4 votes
1 answer
102 views

How to export a matrix in mathematica to some format so that I can read it in python using numpy array

I have a matrix in mathemtica which contains numericals and one symbol in it. I am trying to export this matix into some format so that I can able to read this matix in python. Below is the matix: <...
user avatar
0 votes
0 answers
18 views

Not getting evaluated output [duplicate]

I just started using Mathematica. When doing the matrix calculation I encountered some problem, output is not evaluated instead it just gives the input as the output. Example:
user avatar
0 votes
1 answer
38 views

Generalised KroneckerProduct that works like Outer[] [closed]

Is there a Mathematica function that works like this: Function[f, A, B] where f is a function with two arguments, and ...
user avatar
  • 103
14 votes
1 answer
384 views

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

Here is my problem: I'm diagonalizing some matrices using Eigensystem[] to obtain eigenvalues and eigenvectors and I'm diagonalizing the same matrices using a ...
user avatar
  • 151

1
2 3 4 5
64