Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

Filter by
Sorted by
Tagged with
10
votes
3answers
845 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
156 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
54 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
64 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
87 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
18 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
78 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
211 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
130 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
140 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
160 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
60 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
204 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
65 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
228 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
178 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 (...
4
votes
2answers
102 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
63 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 ...
2
votes
0answers
78 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
81 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
245 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
106 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
41 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
31 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 ...
1
vote
1answer
55 views

How do I solve a large system of differential equations with indexed functions?

I strongly suspect that matrix methods are the right answer here, but I am having trouble visualizing how to set it up. Imagine a large number of coupled functions: ...
1
vote
1answer
79 views

Problem when solving Kalman filter in Mathematica: How to define a spectral density matrix and calculate the covariance matrix?

I am reading the classic book on state-space control theory by Bernard Friedland. In order to strengthen my understanding of Kalman filter, I want to reproduce Example 11A (Inverted pendulum on page ...
0
votes
0answers
53 views

Prove that a sum is bounded

I have a matrix called x[n_,m_]: and I have to evaluate the next expresion: but the code has errors. How can I fix it? ...
8
votes
4answers
325 views

Simplify makes Mathematica forget that a matrix is Hermitian

Using Simplify with certain trivial assumptions makes Mathematica forget that a given matrix is Hermitian. See the minimal example below: ...
2
votes
2answers
88 views

How to overlay MatrixPlot with GridGraph?

I have a Matrixplot and a grid graph and I want to overlay them. But when I use show[g1,g2], it did come out what I wanted. I wonder how can I overlay them and make them like this? To make the points ...
3
votes
1answer
49 views

Evaluating Toeplitz determinant [closed]

How can one evaluate $-\text{log}~ \text{Det}(I_{i-j}(x))$ where $x>200$ and $I_{\nu}(x)$ is the modified Bessel function of first kind and $i,j = 1 \cdots 100$ and the determinant is take of the ...
4
votes
2answers
87 views

Create a $N\times N$ random matrix with correlated off-diagonal elements

I am working on spectral distribution of random matrices. I need to use simulations and I have been switching between MATLAB and Mathematica. I wish to perform all my computations on Mathematica. In ...
2
votes
1answer
82 views

Gauss Jordan code for mathematica

I want to find the inverse of the matrix using a unit matrix. I know it's done directly using Inverse, but I need to write a simple code. I can't write because I'm just starting to learn. How can I ...
2
votes
0answers
35 views

What kind of performance should I expect out of Eigensystem using FEAST?

I'm numerically solving a time-independent Schrödinger equation using Eigensystem's FEAST method. It takes a lot longer than I ...
4
votes
2answers
94 views

Replace the diagonal of a list of matrices

I want to replace the diagonal of a square list of matrices with another list of matrices. What is the fastest and most efficient way to do so. (I will need to do this for very large arrays) Small ...
1
vote
2answers
210 views

Finding specific eigenvalues

Given an $n\times n$ matrix $Q$ (with e.g. $n\approx10^4$) I am only interested in the 3rd smallest eigenvalue of $Q,$ and not the entire spectrum (assume all eigenvalues are real, e.g. a Hermitian ...
4
votes
2answers
251 views

Sum of all matrix entries

For large $n\times n$ symmetric matrices $T,$ where $n\approx10000,$ is there an efficient way of computing the total sum $S$ of its entries in Mathematica without having to loop over all its entries? ...
2
votes
2answers
71 views

Triangular matrices with conditions

I would like to generate a lower triangular matrix that has checkmarks in the non-zero entries. The way that I created this matrix is the following ...
7
votes
2answers
220 views

Fastest way to update rows of an array of SparseArrays

I have an array of sparse arrays (check update 3 below for a concrete example that has the same qualitative features as what I use in my real code) , say ...
6
votes
3answers
516 views

Joining matrices together

Given the following matrices (where $n$ can be any integer number, It is just for a general dimension of my space): ...
0
votes
3answers
123 views

listing matrices with some special constraint

Let we have list = {{4, 4, 4, 4}, {-4, 4, 4, 4}, {4, -4, 4, 4}, {4, 4, -4, 4}, {4,4, 4, -4}, {-4, -4, 4, 4}, {-4, -4, -4, 4}, {-4, -4, -4, -4}} I would like to first obtain the list of all ...
0
votes
0answers
31 views

Not really sure what am I doing wrong in Newton Euler iterative method

I am trying to perform iterative newton Euler method for dynamics of an RP manipulator. I have the DH table, inertia vectors and was able to get the value of wdot[i] (angular acceleration) but having ...
1
vote
0answers
40 views

Inverse[m1 m2] not equivalent to Inverse[m2] Inverse[m1], m1,m2 are 3x3 matrices, why? [closed]

I would like to use Mathematica to show that $(AB)^{-1} = B^{-1}A^{-1}$ I used ...
2
votes
1answer
89 views

Quadratic form for specific formula as matrix reprezentation [closed]

So I have problem for specific formula to create Quadratic_form form from $$y = 3 + x_1 - 2 x_4 + 2 x_3 x_4 + x_2 (-x_3 + x_4) $$ as matrix \begin{bmatrix} 1 & 0 & 0 & 0 \\ ...
0
votes
0answers
34 views

HermitianMatrixQ Ignores Assuming, $Assumptions

HermitianMatrixQ seems to ignore a variety of ways I tried to help it get the right answer. For example, ...
0
votes
1answer
62 views

Why sum of two simple matrix is not in correct way? [closed]

clear[a]; a = List[{0, 1, 2}, {1, 2, 3}, {2, 3, 4}] a // MatrixForm; M2 = Transpose[a] // MatrixForm; a + M2 I am trying to run this code for ...
0
votes
2answers
26 views

Create symmetric array of function values

I have function B[i,j] where i,j are integers. Then I create array: b = Array[B, {3,3}] now I set values of ...
3
votes
3answers
136 views

easiest way to construct the following determinant

What is the easiest way to construct the following determinant?] p is variable, I want to vary value of p each time and get the appropriate determinant.
0
votes
0answers
26 views

How to select multi vectors with particular condition

I have a matrix as: a01={{225., 1, 2, 3, 4}, {225.5, 2, 3, 4, 5}, {226., 3, 4, 5, 6}, {226.5, 4,5,6,7}} And I want to choose head: ...

1
3 4
5
6 7
52