Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

Filter by
Sorted by
Tagged with
0 votes
2 answers
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: ...
Gae P's user avatar
  • 647
0 votes
0 answers
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 ...
Quantum Kid's user avatar
0 votes
2 answers
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$ ...
avnar's user avatar
  • 1
0 votes
0 answers
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 ...
Someone's user avatar
  • 175
1 vote
1 answer
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 ...
Mohammed Sabak's user avatar
9 votes
3 answers
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 ...
Rubens Vilhena Fonseca's user avatar
5 votes
2 answers
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-...
eldo's user avatar
  • 69.5k
0 votes
2 answers
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 ...
magg13__'s user avatar
3 votes
3 answers
198 views

Finite Differences:

I am having difficulty implementing finite differences in the correct columns of my code. ...
Rubens Vilhena Fonseca's user avatar
2 votes
3 answers
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: ...
Jee's user avatar
  • 386
12 votes
3 answers
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 ...
Yaroslav Bulatov's user avatar
0 votes
1 answer
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 ...
JohnnyB's user avatar
  • 95
7 votes
5 answers
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 ...
hroetsc's user avatar
  • 71
0 votes
0 answers
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 ...
mrejr923's user avatar
1 vote
0 answers
136 views

Cross product of a vector and a matrix

I defined a symbolic matrix with vector elements as: ...
Harken's user avatar
  • 105
5 votes
3 answers
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: ...
JohnnyB's user avatar
  • 95
0 votes
0 answers
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 ...
Erfan's user avatar
  • 159
1 vote
1 answer
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 ...
Russell Jay Hendel's user avatar
4 votes
2 answers
78 views

Speed up sparse Hermitian matrix-vector product

I am interested in speeding up as much as possible the dot product in the specific case of a multiplication of a $n\times n$ sparse hermitian matrix $H$ (where $n$ is typically large, let's say $\...
Matteo's user avatar
  • 283
0 votes
0 answers
27 views

Simplifying constant coefficient in a matrix [duplicate]

I made this matrix and now I need to simplify it.in my matrix a,k,and Subscript[u, 10] could be simplified, I used Simplify function for them but it seems to does not apply on it. this is my code : <...
Ali Bizhanpour's user avatar
0 votes
1 answer
39 views

Get explicit formula after matrix derivation with Mathematica

I want to calculate the derivative of a matrix with respect to a vector with mathematica, and I would like to know if it is possible to have a formula as an answer instead of an expanded matrix. For ...
ZchGarinch's user avatar
4 votes
1 answer
96 views

Efficient way of creating matrices from a very large array while avoiding singular values

I need to create matrix from a large array (>>10000 elements) for further use. I have tried Outer and ParallelTable commands, among which Outer seems to be faster when the array size is not so ...
user91411's user avatar
  • 400
4 votes
2 answers
74 views

How do I generate a table of cofactors from minors of a matrix?

I'm trying to figure out how to find the determinant of a 5x5 matrix by co-factor expansion in the second row. I have already calculated the minors of the matrix using ...
Lucas Conklin's user avatar
1 vote
1 answer
52 views

NonCommutativeMultiply in Matrix Multiplication

Is there a way to preserve the order of elements in the multiplication of matrices when the elements themselves are matrices? For example, if I have: ...
Matthew Crawford's user avatar
4 votes
1 answer
154 views

Writing a matrix as a linear combination of matrices

Suppose I have two matrices A and B. After some calculations, I arrive at a matrix M and ...
Ruben Campos Delgado's user avatar
1 vote
0 answers
29 views

NDSolve with matrix variables and SymplecticPartitionedRungeKutta [closed]

I'm experimenting with solution of differential equations with matrix variables, where the right hand side is defined as a numerically evaluated function of a matrix. Here is a simple example: ...
Igor's user avatar
  • 303
4 votes
1 answer
157 views

Formulate and solve a system of linear, first-order ODEs in Mathematica

I know this code is wrong, but I am not sure why. I have a system of coupled differential equations. The model is given by the following equations: $\frac{dS_0} {dt} = (1 - \mu_0) \rho_0 S_0 \frac{S_\...
Ben Hardisty's user avatar
0 votes
0 answers
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: ...
user96773's user avatar
2 votes
1 answer
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, ...
homocomputeris's user avatar
1 vote
0 answers
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 ...
sudipta's user avatar
  • 63
0 votes
0 answers
65 views

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

Here is the code to produce a $9\times9$ matrix: ...
ZHENGYAO HUANG's user avatar
1 vote
1 answer
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 ...
Jacques's user avatar
  • 11
0 votes
0 answers
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 ...
pbp's user avatar
  • 1
1 vote
1 answer
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. ...
Arian's user avatar
  • 171
7 votes
5 answers
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 ...
Delaram Nematollahi's user avatar
2 votes
0 answers
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 ...
Hugh's user avatar
  • 16.4k
1 vote
0 answers
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 ...
Moo's user avatar
  • 3,270
1 vote
1 answer
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 ...
Richard Casey's user avatar
7 votes
3 answers
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 ...
David G. Stork's user avatar
3 votes
2 answers
179 views

Creating a sparse matrix

I would like to create the following sparse matrix \begin{equation} A = \begin{pmatrix} a1+b1 t & k-1 & 0 & \ldots &0 \\ a2^{2}+b2^{2} t & a1+b1t & k-2 & \ldots &0 \...
Shasa's user avatar
  • 1,043
6 votes
4 answers
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 ...
Morcus's user avatar
  • 309
6 votes
7 answers
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 ...
eldo's user avatar
  • 69.5k
0 votes
0 answers
56 views

How to adjust Do loop with conditions?

This code works as expected. ...
Tugrul Temel's user avatar
  • 6,203
-1 votes
1 answer
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 ...
dudulu's user avatar
  • 149
0 votes
1 answer
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$?...
narip's user avatar
  • 381
2 votes
2 answers
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: ...
benjaminchanming's user avatar
0 votes
0 answers
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 ...
Lucas Lopes's user avatar
0 votes
0 answers
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 ...
narip's user avatar
  • 381
0 votes
0 answers
83 views

Break symbolic eigenvalue calculation early

I am computing eigenvalues of matrices with single monomial entries (x,y,z, etc.) and for efficiency, need to truncate calculations early if any eigenvalues contain non-linear (x^{2}, \sqrt(x),x*y etc....
JJJJJJJJJJJJJJJJ's user avatar
4 votes
1 answer
144 views

How to solve a linear system with a close to zero eigenvalue?

The following is a small part of my research: I got a 4 by 4 matrix $\mathbf{M}$ of rank 3: ...
IntegralLover's user avatar

1
2 3 4 5
71