Stack Exchange Network

Stack Exchange network consists of 174 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [matrix]

Questions on the manipulation of matrices in Mathematica.

3
votes
2answers
67 views

Working Iterative formula for a system of equations

I have been given a project, I need to show the use of a version of Newton's method to solve these non-linear equations. The version of Newton's method I am required to use is: $ X_{n+1} = X_n - J^{(-...
2
votes
0answers
45 views

How can I perform the modified Cholesky factorization/Decomposition in Mathematica?

How to "Modified" Cholesky Decomposition in Mathematica? what I mean: V = L . D . Transpose[L] V is p*p(row is p,columns is p) non-negative definite matrix, D is diag[$d\small1$,$d\small2$,$d\...
1
vote
1answer
106 views

Solving the eigenvalue problem for a double well potential using a 1D particle in a box as a basis set

My first question is how would I go about getting the 1D particle in a box eigenfunctions using matrix techniques and how would I use the particle in a box eigenfunctions as a basis set for the ...
1
vote
1answer
29 views

Hessian matrix product in Taylor expansion of vector function

I am trying to get the 2nd order coefficient of the Taylor expansion at $\pmb{x}=\pmb{0}$ of ...
1
vote
1answer
46 views

Partial trace and Partial Transposition of a matrix easily?

Could someone help me to understand as to how to compute the partial trace and partial-transposition of an arbitrary matrix? I mean, is there any code to carry out these operations in Mathematica? ...
3
votes
3answers
68 views

Replacing a column of a matrix

I want to replace a column of a matrix. The best I've been able to come up with is ...
0
votes
1answer
110 views

Constructing a matrix from different blocks

Suppose I have a symbolic matrix called MAIN as follows $$ \begin{matrix} H_{00} & H_{01} & \ldots & H_{0n}\\ H_{10} & H_{11}& \ldots & H_{1n}\\ \vdots & \vdots & \...
0
votes
0answers
11 views

How to transform a real matrix with complex eigenvalues into a positive definite real matrix?

If the matrix had real eigenvalues, I would substitute the negative eigenvalues by a small positive number. However, I have complex eigenvalues... How should I proceed to transform the original ...
1
vote
0answers
27 views

Dimension of Grid in CUDAFunctionLoad for Matrix Multiplication

I want to do nonsquare matrix multiplication using CUDA The input is two matrices: a and b ...
3
votes
2answers
146 views

How to drop certain elements in certain positions from a list using drop function

a = Table[i, {i, 1, 10}] Drop[a, {5, 8}] If go with the above procedure, It will delete all the elements from between position 5 to 8. How to drop elements which ...
0
votes
0answers
31 views

Find a matrix that are unitarily equal to the given matrix

I have four $5\times 5$ matrices, $P_i, Q_i$ ($i=1, 2$) as follows: $P_1=\begin{pmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & 1 & 0 & 0 & 0 \\ 0 & 0 & 0 & 0 & -...
1
vote
2answers
67 views

Max in every row and column in bimatrix game

I want to find the maximum value in each column by comparing only the first elements (-8 and 10) and (0 and -1) and maximum value in each row by comparing only the second elements {-8 and -10) and (0 ...
0
votes
1answer
17 views

How can I specify the region for every variable simultaneously in NMinimize?

I want to use NMinimize to find the unknown unitary matrix that solves a (possibly nonlinear) matrix equation. For example, the one that transforms the Pauli matrix ...
1
vote
1answer
28 views

Find a matrix $X$ that block-diagonalizes a particular group of matrices

Essentially, I want to find a single matrix $X$ such that conjugation by $X$ sends: $$\begin{bmatrix} 1 & 0 & 0 & 0 & 0 \\ 0 & -1 & 0 & 0 & 0 \\ 0 & 0 & 1 &...
4
votes
2answers
84 views

OpenCL compute large matrices

I am trying to compute a big matrix $C$, of size $M \times N$, using the elements of the input matrices $A$ and $B$. The matrix $A$ is of size $M\times4$ and the matrix $B$ is of the size $2\times N$. ...
1
vote
1answer
139 views

While loop (or alternative) to generate list of random submatrices satisfying condition

I'm trying to generate a list of random submatrices with matrix norm 0.1, however I'm getting stuck; currently my code looks like this, where I run over a while loop. ...
4
votes
1answer
50 views

Populate matrix from linear system

What is the strategy to populate a matrix from a linear system of equations? As a toy example, I have some scary, complicated math, that generates eq1 and ...
0
votes
0answers
56 views

How to obtain left and right eigenvectors of a general complex matrix with degenerate eigenvalues?

I'm looking to obtain the left and right eigenvectors of a general complex matrix. The left eigenvectors satisfy the equation: $\phi^L_i L = \lambda_i \phi^L_i$, with $\lambda_i$ being the $i$th ...
0
votes
3answers
26 views

Low precision from function returning matrix

Got a function depending on single parameter "t" defined below which returns a 2 by 2 matrix ...
1
vote
1answer
72 views

How to import complex .txt file to matrix in MMA for user defined keywords / database?

I am thinking about how can we import complex .txt file (Ansys/Abaqus) to MMA for the selected database? For example: txt file (input file): ...
1
vote
1answer
56 views

Derivative with respect to any element of a matrix

I try to evaluate $$ \frac{\partial s}{\partial A_{ab}} $$ where $$ s = \sum_{i} \sum_{j} A_{ij}$$ The result should be 1 regardless of $a$ and $b$. But the following code gives zero. ...
2
votes
2answers
33 views

Using ReplaceAll on matrix to produce new list of complete matrices

This seems like something simple but I can't find the answer. If I have as input: {{1, 2}, {3, d}} /. d -> {4, -4} Mathematica outputs: ...
2
votes
0answers
47 views

How to construct a time-dependent matrix quickly?

In the process of discretization of a 4D PDE, I need to construct a final sparse matrix $B$, which is very large (I denoted by $\text{size}$ here) and time-dependent, viz, some of its entries change ...
0
votes
1answer
65 views

Finding all the solutions of some matrix equations

I am trying to find all possible solutions to the following: A = ( { {a11, a12}, {a21, a22} } ); B = ( { {b11, b12}, {b21, b22} } ); A.A <...
1
vote
1answer
37 views

Finding a fundamental system of solutions of the homogeneous system [closed]

Hey guys im having problems with as the title says finding a fundamental system of solutions of the homogeneous system Vx = o Based on : Matrix ...
3
votes
1answer
49 views

Solving $\det{(A+\epsilon B)}=0$ for large, symmetric and dense $A$ and $B$

In an algorithm I am writing, I need to solve the equation $$ \det{(A+\epsilon B)} = 0, $$ for the smallest value of $\epsilon$, given large ($n$x$n$ ideally up to 150x150), dense and symmetric A ...
3
votes
4answers
154 views

Fast way to create $[ I_4\otimes e_1,\ \dots ,\ I_4 \otimes e_T]$?

Is there a fast way to construct this matrix? $\left[\begin{array}{c} I_4\otimes e_1\\ \vdots \\ I_4 \otimes e_T \end{array}\right]$ $e_i$ is the $i$-th column of the matrix $I_T$, $\otimes$ is the ...
2
votes
1answer
53 views

Inaccurate zero eigenvalues for 7*7 matrix [closed]

I have symbolic entries for all the elements of a 7*7 matrix. At the symbolic level Eigenvalues gives two zeroes and five others that are extremely complicated. At ...
5
votes
2answers
83 views

Plot values of matrixplot as well as the matrixplot itself inside Manipulate [duplicate]

Given a MatrixPlot inside a Manipulate, say some $M(t)$ where $M_{ij}$ real for all entries, is there a way to show the values ...
5
votes
3answers
100 views

Better code for reversing and joining matrices

I am writing a function to reverse a matrix and join the reversed version to the original one, making a new matrix which I call A. And after doing this, I reverse <...
2
votes
2answers
38 views

determining the coefficient matrix

We have a set of equations as a x + b y = c z + d w e x + f y = g z + h w We wish to have a matrix as below : How can we reach the ...
0
votes
0answers
35 views

Solving a system of linear equations in Mathematica regarding the errors of different methods

I have a system of equations, i.e. 0.62243x + 0.51824y = 0.70524 0.71497x + 0.59496y = 0.80996 I have 3 ways to solve this system (there are more but I am ...
0
votes
1answer
81 views

Max in every column and Min in every row

I have a matrix such as this mat ={{6, 5},{5, 4}} and I want to find the maximum in every column and minimum in every row. After that I have to get the same ...
0
votes
1answer
25 views

Eliminate the higher powers of eigenvalues of a matrix

I want to found de eigenvalue of following matrix ...
0
votes
0answers
19 views

Method option of function MatrixRank

By running ??MatrixRank, I see that it has an optional argument named Method. However, this argument is not in the ...
8
votes
1answer
420 views

Is there a faster way to vectorize a matrix than this?

I want to put all the columns stacked up, as a vector. The fastest code I could come up with was Transpose[{Flatten[Transpose[A]]}] Is there a faster way?
0
votes
0answers
73 views

Constructing a block diagonal matrix

I have a problem in transforming a matrix into a block diagonal matrix. My matrix has the form: Mat= \begin{array}{cccc} a & b & c & 0 \\ b & 0 & 0 & c \\ c & 0 & ...
2
votes
2answers
235 views

How do I write this matrix?

The following code gives 20 data as output. How can I make a 5*4 matrix by that data list?
3
votes
2answers
89 views

Programming with Mathematica Syntax - Dunford decomposition

I am always amazed while I am reading some solutions of problems in mathematical problems of this site with Mathematica. For instance, look at the problem 48. Whereas I am writing 100 lines of code ...
1
vote
2answers
43 views

Integrate over matrix elements

I wish to perform the integral $$ \int \prod_{i,j}dM_{ij}\exp\left(-Tr(M^2)\right) $$ where we integrate over the matrix elements of $M$. I tried ...
2
votes
2answers
51 views

How to write a matrix of $n\times 2$ where the first column is made of only 1's?

How to write a matrix of $n\times 2$ where the first column is made of only 1's? Suppose I have a vector x={.24,...,10}. How can I get this $\left( \begin{matrix} 1 & .24 \\ 1 & ...
0
votes
0answers
18 views

Matrix multiplication Q.W not working - Result=matrix Q . matrix W [duplicate]

When I write the code to do the dot product between two matrices, Mathematica does not compute it: How can I get the right matrix? EDIT Thank you for your willingness.
1
vote
2answers
54 views

How can I construct a matrix by programming in mathematica?

I want to write a matrix in Mathematica by programming. How can I write it? The matrix is : $ M= \begin{bmatrix} 0 & 0 & 1 & 0 & 0 & 0 & 0 & 0 & 0 & 0 & ...
7
votes
3answers
373 views

Extract the symmetric matrix built-in another matrix

Suppose that I have a matrix M: ...
1
vote
2answers
34 views

Build matrix from smaller matrices or rearange list of lists

Start with the fact that I am a new user of Mathematica, and this is my problem: I have a complex simbolic matrix A (rectangular, 14x14), and I want to build a matrix from its imagenary and real ...
0
votes
1answer
99 views

setting up a variable matrix

I am trying to set up a variable matrix, where I have a variable x that goes from 0 to 2 and a variable z that goes from 0 to 2. I have two other variables m and n that depend on both x and z. How ...
1
vote
3answers
93 views

Find k largest edges with unique nodes (kind of maximum weighted matching)

I have a weighted graph, and I am interested to find k largest edges with unique nodes. Currently, I do it in the following manner ...
3
votes
2answers
123 views

Problem about Inner product of matrix with two vectors

If A, B are two lists with length n and M is a n*n Matrices, then I want to compute the inner product of them ...
1
vote
0answers
65 views

Summation over gamma matrices in a spin connection with FeynCalc

I need to construct the following object $\Gamma_{\mu} = \frac{1}{8} \omega_{\mu}^{ab}[\gamma_{a},\gamma_{b}]$ where $\omega_{\mu}^{ab}$ is object with space-time index $\mu$ and vierbeins index $a, ...