Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

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

How to solve for matrix equation X . A . X^{T} = B?

I need to find a matrix $X$ such that it belongs to $O(D,D)$ and satisfies the equation $X A X^{T} = B$, where $A$ and $B$ are known. I have no idea how to easily do this in Mathematica. Any tips? ...
0
votes
0answers
24 views

How does one specify that an input variable is an integer?

Essentially, I want to combine 4 square matrices using the ArrayFlatten command. However, I am specifying the matrix dimensions as an input variable as follows, ...
1
vote
0answers
36 views

Grouping vectors into groups of 3 by attribute

Three groups are given, each with eight $3 \times3$-vectors: ...
0
votes
1answer
37 views

How to generate random matrices with contraints?

I have a matrix mat = {{Sqrt[(1 + a0 + a3)/2], (a1 - I a2)/Sqrt[2 (1 + a0 + a3)]}, {0, Sqrt[(1 + a0 - a3)/2 - (a1^2 + a2^2)/(2 (1 + a0 + a3))]}}; How can I randomly ...
0
votes
0answers
32 views

A linear algebra problem about the multiplication count for given matrixs [closed]

This is a problem from Introduction to Linear Algebra 4th edition Problem: Section 2.4. Problem 36: Suppose A is m by n, B is n by p, and C is p by q. Then the multiplication count for (AB)C is mnp + ...
5
votes
3answers
94 views

Find transformations for two non-square matrices $A$ and $B$

Given two matrices $A$ and $B$: What transformation needs to be applied to transform matrix $A$ into matrix $B$? ...
4
votes
2answers
158 views

Vectors do not define a plane when constructing a RotationMatrix

The following code: RotationMatrix[{{0, 1, 0}, {0, -1, 0}}] Gives an assertion message: ...
1
vote
1answer
75 views

How to write a matrix in a different basis by using Mathematica

I have these two 4x4 matrix ...
1
vote
2answers
66 views

How to dynamically define matrix with blocks in subdiagonals?

...
2
votes
0answers
38 views

Reducing to Irreducible Representations

Group Theory Background / Utilities Suppose I give you a list G of matrices which represent some group, in that the matrices are closed under multiplication. In ...
0
votes
0answers
34 views

Small problem with TensorReduce

Given: $eq=-\frac{1}{2} \text{$\varpi $1}^T.\text{J1}.\text{$\varpi $1}-\frac{1}{2} \Omega^T.\text{jp}.\Omega+\frac{1}{2}\left(\text{Jp}+\text{Jp}^T\right)^T.\Omega$ where $J1$, $jp$ and $Jp$ - $3 \...
0
votes
2answers
80 views

Equation solving to find a matrix

If I have the vector z={y1+2*y2+y3,y1+y2,y1+y2+y3} , and y={y1,y2,y3} and m=Array[a,{3,3}]. ...
0
votes
0answers
35 views

High-dimensional second-order differential matrix equations

I am working on Lagrangian derived high-dimensional motion equations for a robot in matrix form. The structure of such an equation is known: $M(q)\ddot{q}+C(q,\dot{q})\dot{q}+G(q)=0$ where $q=[\dot{\...
0
votes
1answer
31 views

Real antisymmetric matrix implementation

$x$ is a real antisymmetric matrix and is defined as: ...
1
vote
2answers
51 views

Transform a Matrix as an expression

If I have a matrix that I know it can be written as (xi.xi)*KroneckerProduct(H,xi), where xi and H are vectors. Is there a way to obtain this expression from a given matrix?
7
votes
1answer
111 views

Kronecker Square Roots

I'm interested in computing the 'Kronecker Square Root' $\mathbf{A}_{n\times n}$ of a matrix $\mathbf{M}_{n^2\times n^2}=\mathbf{A}\otimes\mathbf{A}$. In case it doesn't exist, I'd like to find the ...
0
votes
1answer
61 views

Derivative matrix by vector in Mathematica

This is an excerpt from the article https://www.sciencedirect.com/science/article/abs/pii/S0094114X10000418. How do I write this using vector-matrix operations (...
0
votes
1answer
40 views

Derivative of Kronecker product by vector in Mathematica

I'm struggling with the following problem. It is necessary to find the derivative expression with respect to the vector $u$: $r(u,v)=[(u-v)(u-v)^T]\begin{pmatrix} 1\\ 1\\ 1 \end{pmatrix}=[(u-v)\otimes ...
4
votes
0answers
37 views

Finding matrix in Krylov subspace (Lanczos method)

The Lanczos method for finding the smallest eigenvalue of a hermiteian matrix $H$ is based on the construction of a vector subspace (Krylov space) where one can build a matrix $H_{Krylov}$ which is ...
1
vote
0answers
31 views

Find the ratio of two volumes of 6 x 6 positive-definite symmetric matrices

Consider the class $A$ of $6 \times 6$ positive definite matrices with real entries and unit trace (that is, the sum of the six diagonal entries is 1). (In quantum information-theoretic parlance, this ...
1
vote
3answers
93 views

How to replace the number of each element of a matrix with a subscript?

I want to get the matrix as Figure 2. There should be two ways to achieve the result. There is a matrix as Figure 1, and change it to the form of Figure 2. Generating the matrix as Figure 2 directly....
0
votes
0answers
20 views

Nintegrate Using coordinates specified by a matrix

How to do a 3D Nintegrate over a function while specifying the co-ordinates to be used? I have the coordinates in a n*3 matrix and want integral to be performed over those points only.
1
vote
1answer
62 views

Quadratic form derivative in Mathematica

How to correctly differentiate quadratic form by vector in Mathematica, i.e.: $Q=\omega^T I_{p} \omega$ $\frac{dQ}{d\omega}= ??? $ ...
0
votes
2answers
57 views

Plotting points of matrix

I have a matrix with 'n' rows and 3 columns where the first two columns are the X and Y values and the third column is f(x,y). All values are numeric. I want to do a 2D-plot where third column gives ...
1
vote
1answer
49 views

Delete rows from 3D matrix and convert it to 2D matrix

I have a 3d matrix of dimension $11 \times 1000 \times 3$. I need to remove the first 10 rows from all 2D matrix so that the output is $11 \times 990 \times 3$. After that I need to convert it into a ...
1
vote
2answers
49 views

Find Columns That Match Row Vectors in a Matrix

Suppose I have the following matrix whose row elements are given by the data listed below. ...
10
votes
2answers
334 views

Arbitrary lattice graph in 2D

My purpose is to generate a graph representing a lattice, where the vertices are essentially the lattice sites. This lattice has to be periodic. That means the opposite boundaries are identical. MWE ...
3
votes
2answers
83 views

AceGen: Keep full symmetric matrix

I am using AceGen to compile a subroutine for MATLAB. The subroutine involves several steps of linear algebra that yields a number of symmetric matrices. However, when using AceGen there seems to be ...
1
vote
1answer
77 views

Solving an equation matrix with NDSolve

Imagine I want to solve the following matrix system of equations $$ \begin{pmatrix} \dot{x}_{11} & \dot{x}_{12} & \dot{x}_{13}\\ \dot{x}_{21} & \dot{x}_{22} & \dot{x}_{23}\\ \dot{x}_{...
2
votes
1answer
87 views

Weighted partitions of a matrix

***Made an important edit to make the "partition" part of the question more clear Let $m,n$ be positive integers. Denote $\left[ m\right] \equiv \{ 1,\ldots ,m\}$. Let $$\mathbf{w} \equiv \...
0
votes
0answers
41 views

On the diagonalization of matrices and strange results [duplicate]

I'm trying to implement the following calculation in mathematica $$U^{(0)}(\mu,m) = V\left(\left[\frac{\alpha_S(m)}{\alpha_S(\mu)}\right]^{\frac{\gamma^{(0)}}{2\beta_0}}\right)_DV^{-1}$$ where $\gamma^...
2
votes
1answer
81 views

Symmetric matrix from a vector

There is a function VectorToSymmetricMatrix that does the following: ...
1
vote
0answers
42 views

Compute the correlation of eigenvalues of a Gaussian Random Matrix

Background Let $M$ be a $N\times N$ random symmetric matrix, which is drawn from a Gaussian distribution of mean $\mu=0$ and variance $\sigma^2=1/N$. The first level correlation is defined by: \begin{...
3
votes
3answers
216 views

Make matrixes with numbered name

Suppose I have two matrixes M1 = {{0, 0}, {0, 0}} M2 = {{0, 0}, {0, 0}} Now I wanna have $N$ matrixes in this form called M1, M2, M3, M4,...MN How to code to ...
4
votes
1answer
121 views

Eigenvalue and SparseArray

This the code of Hofstadter spectrum for square lattice using Mathematica ...
0
votes
0answers
37 views

Bug in FunctionLayer for matrix products

I am trying to figure out if this is a bug or if I do not understand something about FunctionLayer. For reference this is: Mathematica v12.3.0.0 Define the matrices:...
1
vote
0answers
51 views

Solving a matrix differential equation by using a function that takes a matrix as its argument

I have a function g of the form g[y_]:=A.y.B where y is a 2-by-2 matrix whose elements are ...
12
votes
1answer
303 views

Most efficient way to shift arrays

I would like to know what would be the most efficient way to shift numerical 2D arrays along its dimensions as follows: (A = Partition[Range[9], 3])//TableForm $$\...
1
vote
2answers
96 views

Given A and B, how to find C if A = CBC?

Given A={{0,1,1,0},{1,0,0,-1},{-1,0,0,1},{0,1,1,0}} and B={{0,1,0,0},{0,0,0,0},{0,0,0,1},{0,0,0,0}} and ...
2
votes
1answer
67 views

Why does the integration of this symbolic matrix slow down after compilation?

There's a symbolic matrix as the following. Why does the integration of the symbolic matrix slow down after compilation? How to eliminate the error information in red? Thanks. Note: The sample matrix ...
0
votes
0answers
37 views

Using a matrix as input in KarhunenLoeveDecomposition

I have a matrix which contains realizations of a random variable. I want to perform the Karhunen-Loève decomposition over it. I also have a Matlab code with KL implemented. I have tried to do it as <...
4
votes
1answer
134 views

How to speed up the calculation process of a symbolic matrix?

There are a symbolic matrix and a real number list. I'm going to replace the symbols of the matrix with all the elements of the list, and then to get the Eigenvalues...
0
votes
1answer
33 views

How to make first component of eigenvectors on grid real and normalize using Map and Normalize? [closed]

I am trying to use the following approach: How get eigenvectors without phase jump? to apply the same conditions to an array of complex-valued Mathematica eigenvectors. The matrix solved for is a <...
-2
votes
1answer
50 views

I want To adjust this code for below Matrix [closed]

may I ask for help to rewrite below code without using Function mode and only work for This Matrix $$ \begin{pmatrix} {1,2,3\\4,5,6\\7,8,9} \end{pmatrix}$$ and my code is: ...
7
votes
3answers
247 views

Generating a weighted oriented lattice

I have a periodic lattice, and I would like to associate some phase parameters connecting to the neighbors that can be thought of as a hopping parameter. Now the choice of these phase parameters is ...
1
vote
1answer
48 views

Error in plotting a quantity involving integral!

With my limited knowledge of Mathematica, I tried but could not figure out the issues in the following few-line code: ...
2
votes
1answer
152 views

Create a matrix without definition of dimensions

is it possible to define a matrix without giving its dimensions in Mathematica, e.g. First line: mattest[[1,2]] = 1; Second line: ...
3
votes
2answers
151 views

Creating a matrix

I have a function as follows: f[x_, t_] := x + t; Table[{x, t, f[x, t]}, {x, 0, 1}, {t, 0, 2}] When I write MatrixForm[%], I ...
0
votes
0answers
23 views

Use the plot information as an input in some math calculations

If i want to have X and y axis numbers in matrix to use them for math calculation how should I do it here? If I had ...
2
votes
1answer
171 views

Diagonal matrix command in Mathematica

How to find the corresponding Mathematica commands for diagonal matrix operation in Matlab, e.g. AA=rand(3,3); Step 1.) finding the diagonal elements, and export ...

1
2 3 4 5
59