# Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

3,532 questions
Filter by
Sorted by
Tagged with
42 views

### Automatic matrix operations with parameters obtained by random numbers

I have matrix T defined by 2 parameters: T = {{0, 0, 0},{0, 0, a},{0, a, b}}; These 2 parameters are randomly generated by means: ...
• 647
80 views

### Why won't my matrix remain Hermitian?

I have a $4\times 4$ Hermitian matrix called $A_{x}$ whose elements are labelled $a_{ij}$ $(i,j = 1, 2, 3, 4)$. (See definitions below.) The $a_{ij}$'s are functions of two variables $x$ and $y$ and ...
• 121
55 views

### Get transformation matrix from transformations

I want to find a matrix corresponding to certain transformations I already know. Basically I have a set of vectors $x_i$ and I need the matrix $m$ that transforms $x_i$ to another set of vectors $b_i$ ...
37 views

### Mathematica returning the numbers in the upper diagonal of a matrix as a list [closed]

I defined a function in Mathematica, where given $a_2,h,t$ is supposed to return a matrix of a certain dimension which depends on these values. My problem is that everything works fine except for the ...
• 175
1 vote
53 views

### Defining a symbolic block matrix

I'm a total beginner in Mathematica and I have been struggling with defining the following symbolic matrix with entries in $\mathbb{Z}_2$ Here, $\mathbb{1}_{m_i}$ and $\mathbb{0}_{m_i}$ stand for the ...
1k views

### Taxicab Geometry

According to taxicab geometry, there are 1226 possible paths from A(2,5) to B(7,9), all with a distance of 9 units, |2-7|+|9-5|=9. I wanted to write a code where I could be obtaining the plots of some ...
491 views

### Fill a matrix with randomly placed elements that are a certain distance apart

Problem statement I want to populate a matrix of points with randomly placed elements, here denoted as x. In all matrix rows there must be an equal number of x-...
• 69.5k
54 views

### How to use FoldList for matrix multiplication?

I'm trying to use FoldList to create successive matrices that depend on a changing parameter n, so the transition matrices are ...
• 15
198 views

### Finite Differences:

I am having difficulty implementing finite differences in the correct columns of my code. ...
486 views

### Why is Mathematica not simplifying eigenvalues?

For matrix A = {{x*Exp[I*y], z}, {z, x*Exp[(-I)*y]}}; , Mathematica yields the following eigenvalues: ...
• 386
435 views

### Visualizing diagrams needed to compute $\operatorname{Tr}(A^3 (A^T)^3)$

I'm looking for help getting Mathematica code to construct diagrammatic expressions like the following, obtained by River Li as a way to compute $\operatorname{Tr}(A^2 (A^T)^2)$ for $d\times d$ matrix ...
• 7,793
59 views

### Generate all commutators and anti-commutators up to a certain order of a list of matrices

I am given a list of matrices. At first order I want to evaluate the commutators and anti-commutators of all pairs in the list and return a new list that contains two lists: one containing all ...
• 95
325 views

### Element-wise vector-matrix exponentiation

I would like to exponentiate the vector x = {x1,x2} element-wise with the non-square matrix A = {{1,0},{1,1},{0,1}} so that the ...
• 71
32 views

### Evaluating determinant with entries from ./ output

I generate 16 values (this is a differential equation shooting method problem) from this kind of evaluation, y41 = Evaluate[y4[tf1] /. torsolve4]; When I use them in Det[], it does not work because ...
1 vote
136 views

### Cross product of a vector and a matrix

I defined a symbolic matrix with vector elements as: ...
• 105
120 views

### Tally elements in a list of matrices up to an overall sign

I have a list of matrices like the following one with 6 elements: ...
• 95
31 views

### Modeling with different outputs size

I have lists of input and output. I want to perform the prediction operation but my outputs are different for each input and this causes an error. Can someone help me to write the model in such a way ...
• 159
1 vote
37 views

### Strange errors of exceeding RecursionLimit in a function with two arguments, one set delayed and one fixed

INTRODUCTION Hi. I feel a bit embarrased asking this question as the answer may be staring me in the face and there are at least two other stackexchange articles related to it. MINIMAL WORKING EXAMPLE ...
78 views

61 views

### Total applied to the lists: length of the object

My goal is to evaluate the total of each line of the following list: ...
146 views

### How to correctly replace scalars with matrices?

How can a scalar be replaced with a matrix to perform operations on the matrix, not its elements? For example, ...
1 vote
83 views

### How to efficiently calculate matrix operations when the elements are defined as functions?

I'm trying to calculate the one-body density matrix of a system of particles as described in this article, given in equations 14 and 15. Here, is my code but it seems very slow. Is there any efficient ...
• 63
65 views

### How to find linearly dependent eigenvectors of non-diagonalizable matrix (with exceptions)?

Here is the code to produce a $9\times9$ matrix: ...
1 vote
43 views

### How can I force a matrix with variables to be interpreted as singular?

I have a matrix M = {{0,1,b},{a,0,1},{1,c,0}}. For my work, I need to assume that $M$ is singular, i.e. $abc+1=0$. The issue is that I am trying to work out ...
• 11
39 views

### Simplify matrix expression with assumptions

I am trying to simplify complex matrix expressions with some assumptions (such as matrix is a rotation matrix). I am failing to do it properly. Find below the simplest example that reproduces the ...
• 1
1 vote
82 views

### Matrix equations in mathematica

I need to solve a matrix equation such as $A=S^{-1}A~S$ for a given matrix A. Suppose that the matrices are $3*3$ and A is diagonal. ...
• 171
250 views

### How to keep specific rows of a matrix based on their second element

Suppose I have the following list: list1 = {{a, 1, c, v, f}, {m, 2, s, f, a}, {s, 2, d, f, g}, {k, 3, g, f, a}, {l, 2, h, j, k}, {b, 1, n, m, d}} I need to ...
73 views

### Solve matrix of ODEs using NDSolve

I wish to solve an ordinary differential equation of matrices. This is a minimal working example I am working towards nonlinear equations. The accuracy of the solution is important for me. I have hit ...
• 16.4k
1 vote
54 views

### RQ / LQ / QL of general matrices implementation in Mathematica?

Does anyone know if there are Mathematica implementations for the LAPACK routines RQ, LQ and QL factorizations for general sized matrices? It would even be great if the RQ factorization allowed a user ...
• 3,270
1 vote
141 views

### How to rotate a 2-body system about various independent axes with body-fixed pivot points/rotation origins?

I am trying to simulate a jointed two-body system on Mathematica, consisting of these components: "Beam" and "Plate". I am constraining the system such that the beam is always ...
173 views

### Counting non-zero multiplications in large sparse matrix multiplications

Suppose I have several large, fixed, sparse matrices of real-valued entries. To make things simple, assume each is $n \times n$. I will multiply them, e.g., matA.matB.matC. Of course I can reduce ...
• 41.2k
179 views

### Creating a sparse matrix

I would like to create the following sparse matrix A = \begin{pmatrix} a1+b1 t & k-1 & 0 & \ldots &0 \\ a2^{2}+b2^{2} t & a1+b1t & k-2 & \ldots &0 \...
• 1,043
389 views

### Anti-diagonal matrix with alternating signs

I am having trouble modifying the code below so that the sign of the x alternate. That is, from the upper right corner it should read ...
• 309
945 views

### Select twins from a list of triples

list = {{1, 1, 1}, {1, 2, 3}, {1, 1, 2}, {1, 2, 1}, {2, 1, 1}, {2, 3, 2}, {4, 5, 6}}; To select sublists containing two equal elements ("twins") I ...
• 69.5k
56 views

### How to adjust Do loop with conditions?

This code works as expected. ...
• 6,203
57 views

### Mathematica can not recognize the wanted element in a matrix when doing a numeric integral, even though it is plotted on the last step? [closed]

As shown, function 'TestF' is defined via interpolation and maps a number to a 4 by 4 matrix. Its (3,3) element is plotted at step 141, but not recognized in the numeric integration within the same ...
• 149
57 views

### Permute subsystems of a matrix?

Suppose I have a matrix $M$ acts on the space $\mathbb C^4\otimes \mathbb C^2\otimes \mathbb C^4\otimes \mathbb C^3$. Is there a method to permute the 2nd subsystem of $M$ and the 4th subsystem of $M$?...
• 381
120 views

### Applying a Transformation Matrix to Entire Graphics Including Axes in Mathematica

I'm working with a Graphics object in Mathematica and I want to apply a transformation matrix to the entire object, including its axes. Here's a simplified version of my code: ...
67 views

### Mathematica overload memory constructing a matrix

I have the following list of {x,y} positions and I'm trying to connect the neighbors with a distance 1 a.u in a matrix, with the following ...
• 477
74 views

### Bug of PositiveSemidefiniteMatrixQ function?

The function PositiveSemidefiniteMatrixQ is used to decide whether the given matrix is positive semidefinite or not. A matrix $M$ is said to be positive ...
• 381
The following is a small part of my research: I got a 4 by 4 matrix $\mathbf{M}$ of rank 3: ...