Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

Filter by
Sorted by
Tagged with
1
vote
1answer
24 views

syntax error when defining a list of matrices: “…cannot be followed by..”

I am literally just defining a list of matrices, but seem to run into the following error when adding the last matrix. (so to be clear, I get no error when I take out the last matrix entry). What's ...
1
vote
0answers
30 views

Computing matrix eigenvalues with units

I apologize if this is a basic question or if I am not giving enough detail. I'm trying to solve for the eigenvalues of a matrix with matrix elements that have units. ...
3
votes
1answer
47 views

Using the elements of one Matrix to form a new Matrix with specified rules

Given a matrix [a], how to get matrices [b] and [c] based on the following two rules? rule [a]->[b]: Strike out corresponding term in [a] and take product of the remaining two terms in the same ...
1
vote
2answers
110 views

Finding the square root of a 7*7 matrix with real entries

Suppose that I have the following symbolic 7*7 matrix ...
1
vote
2answers
60 views

How to reorganize matrix according to location requirements

I want to specify a location replacement for matrix reorganization. For example, when I specify the location replacement rule to be {1, 2, 3, 4} -> {2, 3, 0, 0} ...
0
votes
0answers
31 views

Using NCAlgebra for Matrix Calculus

I have the following expression: $$ F = \| \mathbf{1} \text{diag}(G)^\top P S+(\mathbf{1} \text{diag}(G)^\top P S)^\top - 2 S^\top P^\top G P S - D \|_F^2 $$ where $S\in \mathbb{R}^{M\times N}$, $P\in ...
3
votes
1answer
44 views

How do I get specific subgraphs from my adjacency graph/matrix under certain conditions?

I have the following set of code which creates a random symmetric matrix (elements 0 and 1) and a labeled adjacency graph. A 0 corresponds to no edge and a 1 corresponds to an edge. ...
1
vote
0answers
31 views

settings elements of matrix of functions

I have a work flow that involves initially specifying a matrix function (or a matrix of functions), e.g. f[x_]:={{Exp[x],Sin[x]},{Cos[x],Log[x]}} This works well ...
6
votes
2answers
176 views

How do I combine multiple matrices into a single adjacency graph?

I'm sort of new to Mathematica and have been working on a project that involves simulating newtwork changes in the form of matrices. I have the following lines of code: ...
0
votes
1answer
32 views

Grouping complicated polynomial with respect to vectors/matrix

i recently wrote a code which computes the trace of a general 2-qubit density matrix to the fourth power (i´m studying physics :D), in terms of two bloch vectors and a matrix of the correlations. Here ...
1
vote
1answer
60 views

Trace of density matrix

Hi friends of Mathematica, i´m a physics student and try to calculate Tr[rho^4] for a general two qubit system analytically. Since this is a very long calculation, ...
1
vote
0answers
26 views

Sign of a determinant based on sign conditions

New user here. I want to sign a determinant, using known qualitative conditions on the components. any help appreciated. dummy example below. thanks. ...
4
votes
2answers
147 views

Replacing parts of a Matrix with lists

I want to use lists to easily replace parts of a matrix. As an example, I want to replace the code ...
1
vote
0answers
53 views

What is the symbol for Matrix inverse operator? [closed]

I tried to take inverse of a matrix A using Inverse[A] and it gave me the right result. But when I tried using notation form A-1 by using typesetting superscript, it gives me wrong result (element ...
6
votes
1answer
55 views

Force two distance matrices to use and show a common legend

I have two distance matrices. Both are comparing two entities in the same way. I create each matrix using ...
0
votes
0answers
35 views

Root expressions inside Eigenvalues [duplicate]

I need the eigenvalues of this matrix as a function of Ny. When I tried whith a simpler matrix (4 x 4), it worked, but now, with this 25 x 25 matrix it returns what is shown in picture bellow: The ...
0
votes
0answers
31 views

Redefine a function on certain values

This question is related to Zero-dimensional matrices, in particular to the answer https://mathematica.stackexchange.com/a/39543/42722. In Mathematica $0 \times n$-matrices are not well-defined, so I ...
5
votes
4answers
107 views

Grouping and repeating the grouped rows inside a matrix

I'm interested in finding the quickest way of grouping the rows of a large matrix in sub-groups based on the position of non-zero elements in the first column and then repeating them number of times ...
5
votes
1answer
51 views

Create block matrix with secondary diagonals using Band function

Given matrices m1, ... , mk and matrices n1, ... , nk-1, I would like to define a block matrix $$ m=\left( \begin{array}{rrrr}m1 ...
6
votes
1answer
131 views

Eigensystem of arbitrary 4x4 Matrix

While doing a computation, I needed to take numerical derivatives of eigenvectors of a 4x4 hermitian matrix with respect to a parameter. I ran into the issue of phase jumps -- a random phase ...
4
votes
2answers
112 views

How to get all the elements in the opposite diagonal of an element

I want to specify an element in a matrix and get all the elements in the diagonal of the element. For example: $$\left( \begin{array}{cccc} 1 & 2 & 3 & 4 \\ 5 & 6 & 7 & 8 \\ ...
5
votes
3answers
123 views

How to randomly generate a positive semidefinite matrix?

How would I randomly generate a positive semidefinite matrix? I'm aware how to generate a random $n\times n$ matrix with real values between -1 and 1 with ...
0
votes
3answers
61 views

create a rank 1 matrix from two vectors

I've seen the answers 1 and 2 about the transposition and creation of rank $m$ matrices. What I'd like to do is first create a random vector, which I know how to do with ...
3
votes
1answer
54 views

Matrix rank of triangular integer matrix powers. Can it be speed up?

I need to determine ranks of the powers of a triangular $0$-diagonal integer matrix of a high dimension. Doing this I noted that the time Mathematica needs to ...
6
votes
3answers
349 views

How do I modify a symmetric matrix while maintaining symmetry?

I'm trying to figure out how to create a For loop for a symmetric matrix. I have a 5 $ \times $ 5 symmetric matrix consisting of 1's and 0's and I'm trying to ...
1
vote
0answers
53 views

Determinant of the tensor matrix in Mathematica? [closed]

I have a data: As an example, it looks like this: Then, when I try to take Det[]: How we can find determinant value of these kind of matrices ?
7
votes
1answer
145 views

Fastest way of numerically creating a list of dot products

I have a list of numerical complex 2x2 matrices list = {M[4,3],T[3],M[3,2],T[2],M[2,1],T[1]} (in reality this list contains over 1000 matrices and I have to do ...
3
votes
1answer
151 views

Having trouble solving a complicated system of equations

I've been trying to solve a system of three equations using the 4th as a parameter, but it hasn't been working. Mathematica just seems to run indefinitely even if I set a given value for the parameter....
1
vote
1answer
43 views

Using MinimumBandwidthOrdering to restructure a correlation matrix

I am trying to restructure a correlation matrix such that the variables with the strongest correlations are grouped together Needs["GraphUtilities`"] These are ...
4
votes
1answer
84 views

Performing Hessenberg decomposition on a symbolic matrix

I am trying to calculate the Hessenberg decomposition of a symbolic matrix $$ A= \begin{pmatrix} 0 & -\mathrm ia & 0 & b \cos x \\ \mathrm ia & 0 & \mathrm ic \sin x & 0 \\ 0 &...
2
votes
1answer
43 views

Manipulation of LeviCivita symbol

I have a matrix in element form as: $$A_{ij}= \sum_{m,n=1}^3\epsilon_{jmn} B_{im} C_{jn}$$ where $B$ & $C$ are also $3\times 3$ matrices. How should I use Levi-Civita symbol in Mathematica so that ...
4
votes
1answer
64 views

Generating vectors with small inner products in a large vector space

I want to generate a large number $k$ of vectors of norm 1 in a $d$ dimensional vector space such that $k>d$. I want these vectors to have inner products as small as possible. A crude way is to ...
1
vote
1answer
75 views

Solve::ivar: (a11+I a12)^2 is not a valid variable [closed]

I have tried ...
1
vote
0answers
38 views

Finding a matrix solution directly with Mathematica

I have two matrices say M={{a,b,c},{b,d,f},{c,f,e}} and G={{A,0,B},{0,B,A},{A,B,B}} Now I have done ...
1
vote
1answer
55 views

How to set same Variables with different Values [closed]

I have a pipe with different insulation sections and a fluid flowing through. I need to calculate the fluid Temperature at the end of every section, to estimate the temperature for the next section. I ...
2
votes
3answers
82 views

How can I evaluate a matrix for a set of values?

I'm trying to evaluate a system, that depends on two variables, in a specific set of values. I will write an example, but my system is more complicated. ...
1
vote
0answers
84 views

Plotting the surface spectral function

I'm not 100% sure if I should be posting this in the physics stack exchange but, I am pretty new to Mathematica, just installed it five weeks ago, and I am having a little trouble implementing the ...
1
vote
0answers
78 views

Help speeding up matrix exponent of $ 16 \times 16 $ symbolic matrix

I am trying to run the following script which involves the MatrixExp of t times a 16x16 matrix with one variable, ...
2
votes
1answer
45 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
3answers
75 views

Find minimum with matrix positive-definiteness constraint

Say I wish to find the minimum value of the determinant of a symmetric matrix under the condition that the matrix be positive definite. So I attempt: ...
1
vote
0answers
30 views

Errors in NDSolve for complex matrices

This is the problem. It is quite simple, and looks unwieldy only because I had to rewrite quaternions as complex matrices. ...
1
vote
0answers
47 views

$ x $ and $ y $ coordinates in ListLinePlot [closed]

I'm trying to make a ListLinePlot with my randomly generated data, and I want one vector to be the x coordinates of the graph, ...
5
votes
2answers
87 views

Apply Outer to list of matrices and vectors

I have a list, M, of square $ n \times n $ matrices, {M1, M2, M3, ...}, and a list, V, of $ ...
4
votes
2answers
202 views

Create a matrix from the rows of another, and calculate the rank of the new matrix

This may be a very basic question, so apologies in advance, I'm a first-time Mathematica & StackExchange user! I have a 7x3 matrix X with all rows being unique in a 2D-list format. For example:...
1
vote
0answers
77 views

How to use MatrixPlot as a DensityPlot?

I have a 1000x1000 matrix the MatrixPlot of which gives this graph: The code is ...
7
votes
0answers
91 views

Computing log-determinant?

Mathematica does-not have a function to compute the log-det of matrix? Naively computing Log[Det[M]] can be numerically unstable.
3
votes
1answer
103 views

Cryptic NDSolve::nlnum when working with matrices

This problem was initially formulated in quaternions, but I had to rewrite them to complex matrices (as they seem to be supported better). Possibly introducing some errors along the way. So the ...
3
votes
1answer
104 views

Diagonalizing a symbolic matrix

I am trying to diagonalize the following matrix \begin{equation} \left(\begin{array}{cccc} { \frac{1-K\left(x_{2}^{2}+x_{3}^{2}\right)}{1-K|x|^{2}}} & { \frac{K x_{1} x_{2}}{1-K |x|^{2} }} & { ...
1
vote
1answer
48 views

The Matrix formula of this hamilton is different from that found in the paper

I am trying to rewrite the following Hamiltonian in the matrix form, but I get different results. In this article, the Hamiltonian that represents a three-qubit Heisenberg spin chain and its matrix ...
3
votes
1answer
102 views

Efficient way to evaluate numerically product sines functions

I'm trying to perform integration of the following matrix. ...

1 2 3
4
5
52