# Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

2,558 questions
Filter by
Sorted by
Tagged with
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 ...
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): ...
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 ...
64 views

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 ...
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. ...
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 (...
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},$$...
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 ...
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 ...
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 ...
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: ...
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?...
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. ...
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 ...
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: ...
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 ...
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? ...
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: ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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? ...
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 ...
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 ...
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): ...
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 ...
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 ...
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 ...
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 \\ ...
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, ...
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 ...
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 ...