Questions tagged [matrix]
Questions on the manipulation of matrices in Mathematica.
3,342
questions
5
votes
1
answer
68
views
How to find the common eigenvectors of these commuting matrices?
Given matrices P and Q defined as
P = {{x - I y, z}, {z, x + I y}}; Q = {{0, 1}, {1, 0}};
...
5
votes
1
answer
87
views
Minimizing computational time for a quantum walk problem
Any suggestions as to how to speed up the computational time for this quantum walk problem which is coded using a normalized SparseArray coin operator as follows:
...
2
votes
2
answers
119
views
Entering matrices interactively
I am looking for a way to enter an m*n matrix interactively using a dialog or a Graphical User Interface(GUI). Further, I would like to use this matrix later for ...
0
votes
0
answers
36
views
Efficient evaluation of vector inner products [closed]
I have a situation where I'm trying to quickly evaluate elements of some matrix products. Let $A, B$ be two Hermitian random matrices, and suppose that we have solved the eigenvalue problem for $A$. I ...
2
votes
1
answer
79
views
Find possible solutions with matrix notation
Many years ago a friend of mine solved a product package problem for me. Now I am struggling to recreate the notation. The problem was there were product bundles including plane, hotel and car rental ...
1
vote
1
answer
57
views
Simple SDP using Hermitian matrices
I would like to run the following semidefinite program
$$ \textrm{Minimize}\,\, \textrm{tr}\big({AX}\big)\\
\textrm{subject to}\,\, X \geq B_1\,, X \geq B_2\,, $$
where $A$, $B_1$ and $B_2$ are ...
0
votes
0
answers
40
views
Hadamard’s Theorem from Gradshteyn and Ryzhik's handbook [migrated]
In the book http://fisica.ciens.ucv.ve/~svincenz/TISPISGIMR.pdf on page 1077 I found one interesting theorem:
I took an arbitrary matrix and tested this theorem. The result is the following:
...
3
votes
2
answers
123
views
How to correctly identify a series of adjacency matrices in a text?
I would like to read the strongly regular graphs on at most 64 vertices from http://www.maths.gla.ac.uk/~es/srgraphs.php
...
6
votes
1
answer
156
views
How to use Slater Type Orbitals as a basis functions in matrix method correctly?
This question is a continuation of my previous series of questions about basis functions.
I would like to find the minimum energy of Coulomb potential motion using matrix method.
$H=-\frac{1}{2}\Delta-...
3
votes
2
answers
179
views
Find a vector in the null space of a large dense matrix, where elements in the matrix are not directly accessible
I am working with Conjugate Gradient method to solve for $Ax = b$, where $A$ is an extremely large PSD and Singular matrix. I cannot directly access the elements of $A$, but I can compute $Av$ for any ...
-1
votes
0
answers
36
views
Obtain all possible state space equations in the circuit of Systemmodeler?
How to obtain the state space equation of the Buck circuit switch closing and opening in Mathematica when drawing this circuit on Systemmodeler only? Or can only draw the switch closed or open ...
0
votes
0
answers
82
views
Mathematica parses `Log[a,b]` as `Log[b]/Log[a]` automatically, before any rules
I use the following code to realize quaternions (this allows more flexibility than the quaternions package):
...
4
votes
3
answers
160
views
Compile code involving two matrix multiplications
Consider the following simple matrix operation ($a_j, b_j, z, w$ are matrices)
$$ w=\sum_j a_j\cdot z\cdot b_j$$
For performance reasons I am compiling the code
...
0
votes
1
answer
69
views
Use the RSolve command of Mathematica to solve difference equations in matrix form?
For example, if $A$ is a matrix, the following is its difference equation representation.
How can I rewrite the code to use the RSolve command correctly?
...
1
vote
0
answers
89
views
Why is the dot operator not just matrix multiplication?
It seems to me Mathematica does not have an inbuilt matrix multiplication operator. The dot operator fails as such, as is even noted under "Possible Issues" in its documentation it ...
3
votes
2
answers
60
views
How I delete one row and one column of a matrix? [duplicate]
I think the title says it all. I am looking for a function f[A_matrix, r_Integer, c_Integer] that will return the matrix A with the row r and column c deleted. I know how to delete rows but how about ...
0
votes
0
answers
48
views
How to perform Z transformation on this difference equation?
The difference equation is as follows:
$$E(i+1)=(I-AT)E(i)+1/2(AT)^2$$
Where, $E$ and $A$ are matrices.
This is part of the code I wrote using Mathematica:
...
6
votes
3
answers
442
views
Fast pairwise difference
I'm trying to construct a matrix $A_{ij}=X_i-Y_j$ where $X$ and $Y$ are vectors with thousands of real numbers. The fastest and closest thing I found is ...
1
vote
1
answer
77
views
Why is generating normalized random $1000 \times 1000$ matrices and plotting the eigenvalues so slow?
For each of the distributions $N(0,1)$ and $\pm 1$ equal probability and for each of $N \in \{5,10,20,50,100,200,1000\},$ I want to generate an $N \times N$ matrix with entries chosen from the ...
12
votes
3
answers
271
views
Efficient eigendecomposition of DPR1 matrices
I'm finding that the following bit is the bottleneck in my code
...
3
votes
2
answers
243
views
Givens rotation: What is the Mathematica equivalent to MATLAB's planerot function?
Matlab has a function called planerot which takes a two-component column vector $x$ as input and returns a $2 \times 2$ matrix $G$ and a two component column vector ...
2
votes
3
answers
299
views
Plotting a complex matrix with phase dependent color
I want to plot a complex matrix, i.e., a matrix with complex number entries. I want the matrix to be plotted as DiscretePlot3D as shown in the figure (top figure). But, I also want each bar to be ...
2
votes
1
answer
80
views
Why QR-decomposition returns transpose of Q?
In the documentary we read about QRDecomposition (Link)
QRDecomposition[m]
yields the QR decomposition for a numerical matrix m. The result is a list {q,r}, where ...
0
votes
0
answers
27
views
Why occur a giant increasing of absolute value of minimal eigenvalue with rise of the basis functions number?
I have the following code:
code 1
...
6
votes
1
answer
88
views
Schur decomposition: What is the Mathematica equivalent to MATLAB's rsf2csf function?
MATLAB has a function rsf2csf that can convert real Schur form to complex Schur form.
The description of the function can be found here.
How can I do this in ...
4
votes
1
answer
143
views
How to export a matrix with complex entries having arbitrary precision from Mathematica to Matlab?
I am trying to export a large matrix with complex entires having arbitrary precision (~ roughly 200 digits after the decimal point) from Mathematica to Matlab.
I have used ...
2
votes
1
answer
94
views
Partial pivoting in row reduction
I have a large $m \times 2m$ numerical matrix which I obtained from NullSpace. I expect that the matrix is equivalent under row operations to a sparse matrix with ...
5
votes
1
answer
73
views
How to Find a Weighing Matrix of Size n?
Weighting matrices appear in the statistical design of experiments (Weighting Matrices and Statistical Design of Experiments.
A weighting matrix is a generalization of Hadamard matrices, e.g.,
...
8
votes
4
answers
582
views
How can I "multiply" nested lists?
Given two nested lists
alist={{a,b,c},{d,e,f}}
blist={{r,s,t},{x,y,z}}
How can I get
...
2
votes
1
answer
117
views
Schmidt Measure of a Graph State
Based on the definition of the Schmidt measure in this work https://www.arxiv-vanity.com/papers/quant-ph/0307130/, the following code was set up, but appears to
generate errors. Is there a better way ...
1
vote
1
answer
114
views
Matrix difference equation
How to use Mathematica's RSolve command to solve the difference equation in matrix form?
RSolve[{a[n + 1] - 2 a[n] == 1, a[0] == 1}, a[n], n]
For example, the ...
0
votes
2
answers
70
views
How to find nontrivial solution for $\Psi$ in the given matrix equation? [closed]
I have the matrix equation $\mathbf M\mathbf \Psi=\mathbf 0$ where $\mathbf M$ and $\mathbf \Psi $ are given below. I check that that $\det \mathbf M=\mathbf 0$; that is,
...
0
votes
1
answer
60
views
Animating unit basis transformations
I am not sure if my mental block here is conceptual or mechanical (edit below suggests it is conceptual). Suppose I want to show all possible unit basis transforms of a matrix. There are 81 possible ...
8
votes
2
answers
345
views
Efficient way to store the terms of a summation in a list?
I have two matrices, A and B of the same dimension $Nr\times Nc$, with $Nr\gg Nc$.
Essentially, I am trying to put all the terms ...
3
votes
1
answer
63
views
What is the optimal way to get selected elements from a matrix?
I have a 2x2 matrix "M", and a list "ind" containing pairs of indices.
M = {{a, b, c}, {d, f, g}, {h, i, j}};
ind = {{1, 2}, {1, 1}, {3, 1}};
I ...
3
votes
2
answers
141
views
Generate real random matrix with some pure imaginary eigenvalues
I want to generate a random 4x4 matrix with real entries, one or some of whose eigenvalues is the pure imaginary number I or some other imaginary number.
NOTICE
The ...
1
vote
0
answers
42
views
Finding the similarity transformation between two symbol matrices
I have two symbol matrices mA and mB, which are similar matrices.
...
0
votes
1
answer
95
views
How to work on "Do" loop?
let's say
...
4
votes
1
answer
97
views
"Information about the undocumented function Internal`DiracGammaMatrix"
Searching for information on undocumented functions here, I found that there are no references about the use of the undocumented function Internal`DiracGammaMatrix.
Does anyone in the community have ...
3
votes
1
answer
75
views
Verifying matrix exponential identity
I wish to verify the following matrix exponential identity using Mathematica:
$$ \mathbb{e}^{i.x.\hat{n}.\sigma}= \cos{x}.\mathbb{I}+ i\sin{x}(\hat{n}.\sigma) $$
where $\mathbb{I}$ is the $2\times2$ ...
1
vote
0
answers
35
views
Method for MinimumBandwidthOrdering [closed]
MinimumBandwidthOrdering[m, Method -> "RCMD"]
What method is 'RCMD' in Mathematica?
Reverse Cuthill-McKee,
Reduced Canonical Matrix Diagram,
Restricted Minimum Column Degree,
other?
8
votes
1
answer
258
views
Creating a random symmetric matrix with a particular rank
The documentation about LinearAlgebra has a section on Constructing Matrices, but the examples of random matrices using RandomReal don't offer an obvios way to ...
0
votes
0
answers
29
views
Fast matrix evaluation with elements depending on ThreeJSymbols
Presentation of the problem
I want to evaluate a large matrix (~3000x3000) whose elements are given as a sum over wigner 3j symbols.
The matrix elements are defined as
...
4
votes
2
answers
130
views
Generating all possible 2x2 matrices with unique elements from 1 to 4
If I have a set A={1,2,3,4}, how do I generate all 2x2 matrices with different elements chosen from ...
0
votes
0
answers
49
views
Cells stuck at running after running after finding symbolic eigenvalues of a 4x4 matrix
I used the code below to calculate the eigenvalues of a 4x4 matrix symbolically.
...
2
votes
1
answer
113
views
Efficient memory usage while building a large sparse matrix
I am sure the following problem has been solved already, but I am unable to find any solution... Any help appreciated!
So I am building a pretty huge matrix (or tensor, actually) using
...
0
votes
0
answers
31
views
Expanding a large dynamic expression involving roots of a degree 4 polynomial
I am trying to find the eigenvalues of a 4x4 Matrix symbolically. Below is the code I am using,
...
2
votes
1
answer
68
views
Increase precision of matrix multiplication [closed]
I am computing U.U......U.x, where x is a vector, U a square matrix and the product involves N times U, i.e., (U^N).x if you like. One way to do this is
...
1
vote
1
answer
72
views
Matrix solving problem
I have a linear system like this:
$$\left[\begin{array}{l}x_2\\y_2\end{array}\right] = \left[\begin{array}{l}A_{11}&A_{12}\\A_{21}&A_{22}\end{array}\right]\left[\begin{array}{l}x_1\\y_1\end{...
3
votes
1
answer
89
views
How to find the derivative of one matrix with respect to another?
I have an expression from a continuum model,which looks somewhat like this excluding a few constants.
Here epsilon is the 3x3 strain tensor and sigma is 3x3 stress tensor. I wish to compute the ...