Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

Filter by
Sorted by
Tagged with
5
votes
3answers
177 views

How can I get all 4x4 submatrices of an nxn matrix?

I have a square matrix, I need to extract all possible combinations of 4x4 submatrices, where n>4. For example in the case of a 6x6 matrix, there are 15 4x4 submatrices. I need the list of all 4x4 ...
5
votes
2answers
321 views

How to reduce the λ-matrix to Smith Standard Form

A = {{1 - λ, 2 λ - 1, λ}, {λ, λ^2, -λ}, {1 + λ^2, λ^3 + λ - 1, -λ^2}} How to reduce the above λ-matrix to the following Smith standard form: ...
1
vote
0answers
44 views

Find vectors describing two interconnected pyramids in Euclidean space

I need the help of competent linear algebra specialists in Mathematica. In the Euclidean space, two tetrahedrons are turned at different angles. Their vertices coincide with the beginning of the base ...
1
vote
1answer
30 views

Exporting column vector as matrix in latex via “Copy as” doesn't always work. Example with vector

I want the simplest way of exporting matrices, and vector from mathematica to Latex. Usually, I display my matrices in MatrixForm and copy as Latex to paste in my latex document. However it seems it ...
4
votes
3answers
120 views

Cell-adjacency Graph of a Square Mesh

Consider the list of points pts = {{1, 1}, {1, 2}, {2, 1}, {2, 2}} I want to use them to define a 2x2 square mesh using ...
1
vote
2answers
58 views

Keep important eigenvectors according to the important eigenvalues except one unimportant eigenvalue

I have an iteration whose steps extract a matrix with any possible dimension for example 3*3, 6*6, ...
4
votes
1answer
228 views

Adjacency Matrix of Sierprinski matrix

how can i make adjacency matrix of sierprinski graphs?
0
votes
2answers
64 views

Nested For Do Table cycle problems

I got England and German soccer data with the following: ...
2
votes
1answer
43 views

Inverse of matrix up to some order

Let $A(t,s)$ be a matrix of any size (potentially large), whose entries are polynomials functions wrt $(t,s)$ of order $N$. I would like to compute the inverse $X$ of $A$ up to the order $N$ that is $...
0
votes
1answer
30 views

How can I use a matrix element to plot with ParametricPlot? [closed]

This is a completely simplified example to demonstrate the issue. I have a matrix, it contains an uninitialized variable. I need to extract that element of the matrix and use in to plot a parametric ...
2
votes
2answers
96 views

Is there any faster alternative for matrix exponential?

Lets define matrix $M$ as ...
6
votes
4answers
355 views

How can I generate random matrices with certain requirements for the entries?

I would like to generate random 9x9 matrices, which contain only the digits 1-9, each one appearing exactly ...
1
vote
1answer
89 views

Solving the matrix quadratic equation: A.X.X + B.X + C == 0 analytically

I'm having difficulty figuring out how to solve a matrix quadratic of the form, $AXX + BX = -C$ analytically for $X$. Where $A$, $X$, $B$, and $C$ are $N \times N$ matrices. I tried using ...
0
votes
2answers
102 views

How can I transform my calculation into a function?

I have written the following code, which serves my purpose. However, I like to have a Mathematica function such as ...
0
votes
0answers
35 views

Finding the Eigenvalues for big matrices

To start I have the following matrix (not so big) I want to find the Eigenvalues in terms of kx and ky. I tried to use the classical ...
3
votes
3answers
230 views

How to join many tables side by side?

I have function for table $t$ t[n_] := Table[i*n, {i, 1, 3}]; For example t[1]=(1, 2, 3), t[2]=(2, 4, 6), and t[3]=(3, 6, 9) To join $n=3$ tables side by side ...
1
vote
1answer
55 views

How to use Collect in Mathematica [closed]

For an input $n$, I have $n^2$ variables uu[1,1],...uu[1,n],...,[n,1],...,uu[n,n]. I have an equation that is linear in these (e.g. ...
1
vote
1answer
52 views

How to “undo” an outer product

I have a matrix which is formed from the outer product of two complex vectors. There is some noise as well. How can I get the best estimate of the complex vector? Here is a case without noise for a ...
3
votes
2answers
99 views

Print command in matrices to generate inactive numbers

I would like to generate a matrix with elements that come from a print command and are numbers and then multiply the first matrix by another one, element by element. However, I would like the ...
4
votes
3answers
424 views

Generating all 2x2 matrices with entries from 0 to 3 whose det is 1 with mod 2 arithmetic

I am trying to make a list of 2x2 matrices whose entries are all possible permutations of 0,1,2 and det=1 mod 2 arithmetic. First I tried to create a Table like this ...
0
votes
1answer
31 views

How to make a tensor product into matrix?

TensorProduct[PauliMatrix[1], DiagonalMatrix[{1, 1}]] // TableForm created a tensor, which could be flatten to table form. However, how to make the tensor into a ...
0
votes
1answer
104 views

How can I convert my MATLAB code into WL code?

I am working in MATLAB and want to convert the following snippet into WL code to run on Mathematica. ...
1
vote
0answers
28 views

Matrix rank triangular matrix [closed]

Does MatrixRank check whether a matrix is triangular? If not, what would be the best way to calculate a matrix rank of a (say upper)triangular matrix in the ...
1
vote
1answer
35 views

Is it posibble to insert/add an array (row or colums) in a matrix?

Assume we have an m by n a non-square matrix. My question is this, is it possible/allowed to insert an arbitrary array ( either row or column) in such matrix so that I can obtain a square matrix? Is ...
10
votes
3answers
839 views

Merging 4 matrices to one matrix

I am struggling with the task to merge four matrices as presented below. Since the matrices A-D contain more than just four entries it would be too complex to do it by hand. Is there a simple or ...
6
votes
2answers
151 views

Build a matrix from the coordinates of its elements and complete it with zeros

Suppose that I have a data set data (input): ...
0
votes
1answer
43 views

How to turn a matrix into a 'function'? [duplicate]

I have some codes to turn a set of equations into a matrix. Suppose the matrix Lis expressed in terms of variables $\epsilon$, $K$, $M$, and I want to make a ...
1
vote
2answers
61 views

Problems with spectral decompositon of a $4 \times 4$ matrix [duplicate]

Given a matrix $M$ with eigenvalues $\lambda_1, \lambda_2, \lambda_3,\lambda_4$ and the corresponding eigenvectors $|v1\rangle,|v2\rangle,|v3\rangle,|v4\rangle$. One can write $ M = \lambda_1 |v1\...
3
votes
1answer
72 views

Proving the positive semidefiniteness of a 6X6 symbolic matrix

Specifically, I want to check the positive semidefiniteness of the following 6X6 symbolic matrix ...
0
votes
0answers
17 views

Symbolically invert block matrix [duplicate]

In Mathematica, if I write something like: Inverse[{{a, b}, {c, d}}] I get the inverse: ...
1
vote
1answer
73 views

Crisis in vector notation [closed]

How to write a vector in Mathematica so that one can perform the common operations such as Transpose and Normalize. For example, {1, 1} can be normalized but not ...
0
votes
0answers
51 views

How do i transform a Matrix into a List? [duplicate]

Like the title says i want to transform a Matrix into a list so i can use LinearSolve what's the way to do it? ...
0
votes
3answers
115 views

Create a Vandermonde matrix

I want to create a $n \times n$ Vandermonde matrix. How could I set up a matrix, vMatrix so I can just use ...
11
votes
1answer
121 views

Minimizing expression over symmetric matrices

I'm trying to solve the following maximization problem over space of symmetric matrices A and positive definite H $$R=\max_{A\in S(R^d)}\frac{\text{tr}(HA)^2+2\text{tr}(HAHA)}{\text{tr}(AHA)}$$ So ...
0
votes
1answer
78 views

Verifying: How to express a given matrix as the outer product of two vectors? [closed]

The question posed here and here is: Is it possible to decompose a matrix $M_{m\times n}$ as the product of two vectors, i.e. $$M_{m\times n} = \vec{y}_{m\times 1}\times\vec{x}_{1\times n}+const.$$ ...
3
votes
1answer
112 views

Gaussian elimination for a Hilbert matrix

I have been asked to write the Mathematica code to solve a 25x25 Hilbert matrix. The built-in function LinearSolve would not work. I started my solution by coding ...
1
vote
0answers
54 views

Error when trying to solve elastic PDEs using FEM: “Compile::argcompten: The comparison, LessEqual, is invalid for tensor arguments.”

I'm trying to solve the following linear elastic problem: The pairs of numbers beside each node is the coordinates in meters. The loads are in Newtons. The part of codes that probably have no ...
4
votes
1answer
194 views

Creating block diagonal matrix identity and one Pauli matrix

I want to create a matrix of the form: $X_\alpha = 1\otimes 1\otimes 1 ...\otimes X \otimes ... \otimes 1$ where $X$ is the Pauli $x$ matrix and is the $\alpha$th factor, and $1$ is the $2\times 2$ ...
2
votes
2answers
62 views

How can I concisely define a matrix-form partial derivative operator?

I have a vector $\boldsymbol{u}(x,y) = \begin{bmatrix} u_x(x,y) \\ u_y(x,y) \\ \end{bmatrix}.$ I would like to get $\boldsymbol{\sigma}(x,y) = \begin{bmatrix} \sigma_x \\ \sigma_y \\ \tau_{xy}...
5
votes
1answer
222 views

Pass arguments to the list of functions?

Suppose I have a list of functions: functions = {f, g, h, ...} And all of those functions are in form of f[x_ , y_]. For ...
0
votes
0answers
20 views

Using Eigensystem to solve eigenvalue problem [duplicate]

I'm trying to solve an eigenvalue problem of the form: $\textbf{A}\vec{x}=\lambda \textbf{B}\vec{x}$, where A and B are square matrices, $\lambda$ are the eigenvalues and $\vec{x}$ the eigenfunctions. ...
2
votes
1answer
131 views

How to write ODE for matrices?

This problem must have been encountered by many people but I could not find a neat solution googling. Many problems in mathematical physics can be written as a matrix ordinary differential equation (...
5
votes
2answers
84 views

Efficient way of averaging over elements of one matrix based on another

Mathematical formulation of the problem with an example: Suppose we have the matrix $A$ given by $$A=\begin{pmatrix} 0 & 1 & 5\\ 1 & 0 & 5\\ 5 & 5 & 0 \end{pmatrix},$$...
1
vote
1answer
54 views

Hermite normal form and basis for the nullspace

Define the Hermite Normal form $H$ for a matrix $A\in Z^{n\times n}$ as following: $$H=UA$$ which in Mathematica is given as {u, h} = HermiteDecomposition[a] Then for a system of homogeneous ...
3
votes
0answers
70 views

Hafnian of a matrix

Is there a Mathematica built-in function for the calculation of the Hafnian of a matrix? I am interested in the function as it appears naturally in the calculation of moments of a multivariate ...
2
votes
1answer
78 views

Fastest way to compute determinants over (lists of) machine precision numbers

The below code is a code snippet of a larger project of mine. The project is mostly optimised but this part is not. I'm struggling to improve it, the code takes a really long time to evaluate for what ...
5
votes
2answers
234 views

How do I get actual values from a Jacobian matrix?

I have a Jacobian function: D[{Sqrt[x^2 + y^2], ArcTan[x, y]}, {{x, y}}] It gives me a matrix with the formulas I need for my transposition matrix: ...
1
vote
1answer
95 views

solve equation by explain n*n matrix or equation team

I want to solve n equation which has n root with Gauss-Elimination Method. I indicated root formulation and methodology in picture. But I don't know that how can I do this. Should I explain n*n matrix?...
2
votes
1answer
39 views

How can I create SparseArray by imposing conditions?

I have two lists: one for directed links list1 and another list2 for the values associated with the links. ...
0
votes
0answers
26 views

Construct a generalised Kronecker sum

I would like to construct a Kronecker sum function in Mathematica that is similar to the answers to this post, but a more generalised construction. Presume I have a set of $2\times 2$ matrices ...