Questions on the manipulation of matrices in Mathematica.

learn more… | top users | synonyms (1)

0
votes
4answers
51 views

insert elements into 2 D array [duplicate]

say I have a 2 dimensionsal array like a={{1,2,3},{4,5,6},{7,8,9}} and a vector like v={10,11,12} I want the result to be ...
2
votes
1answer
78 views

Help on order of evaluation within plot function

it is my first time asking a question here so please let me know if there's anything I should be doing that I'm unaware of. I'm sure the answer to my question already exists on the site but I'm having ...
1
vote
0answers
47 views

Working with matrix

Considering the 3x3 matrix: m = {{0, -(I/Sqrt[2]), 0}, {I/Sqrt[2], 0, -(I/Sqrt[2])}, {0, I/Sqrt[2], 0}} How would I find its normalized vectors eigenvectors u_i ...
3
votes
0answers
69 views

Why does Eigenvalues work for a matrix $\{M\}$ but not $\{\{M\}\}$?

Suppose I have a matrix {{1, 2}, {3, 4}} which I'll call mat. In a blur of human error, I computed the eigenvalues of ...
-1
votes
1answer
64 views

Real and Imaginary matrix

I have a 2 by 2 matrix T: {{x, y}, {-y, x}} where x is the real part of some complex number and y is the imaginary part of something complex number. Let's say z1 = ...
1
vote
0answers
39 views

Getting the row/column reduction matrix of a matrix m

Is there a simple way to get the row reduction matrix for a matrix m? As in, a matrix a such that ...
2
votes
2answers
82 views

Building an $m \times n$ matrix from element-wise from two other such matches

I am a beginner with Mathematica. I have two matrices, s1 and s2, and I am building a third matrix from them. ...
2
votes
0answers
68 views

Unexpected behavior from applying ToRadicals to eigenvalues [closed]

I am trying to get the symbolic form of a $10 \times 10$ matrix (I know, that is generally too large). ...
0
votes
1answer
92 views

How to turn a subroutine into a function?

I've written a subroutine that takes in 6 matrices and after some manipulation returns back 3 new ones. I will use this subroutine fairly often in this notebook so I think it would be easier to turn ...
11
votes
1answer
155 views

Why FoldList 5 times faster than Apply for matrix multiplication? [duplicate]

Consider this list of $2\times 2$ matrices: list=RandomReal[{-2,2},{500,2,2}]; Now compare timings of Apply and ...
1
vote
0answers
97 views

Outer product using the quantum mathematica package

I am using the quantum Mathematica package and am trying to do computations that require me to use the outer (tensor) products of Pauli matrices. I would define this as, for example, ...
2
votes
0answers
45 views

Optimization for iterating and plotting a matrix product and its elements?

I have an iterative matrix product of this type Since i didnt knew how to do it, I explicitly wrote the product as {Ayn + Bxn, Cyn + Dxn} and evaluated it with the NestList construct ...
11
votes
4answers
486 views

How do I extract a matrix of only positive numbers given a set of assumptions?

I want to divide a matrix: mat = {{a, 0, -b}, {d, a, 0}, {0, 0, -a}} with the following assumptions: ...
0
votes
1answer
50 views

Overriding Subscript operator creates its own variables?

I tried to override the Subscript operator to make matrix indexing a bit more "user-friendly" in complex expressions with the following code according to the ...
5
votes
1answer
80 views

GaussianMatrix function issue

Here is my implementation of the built-in GaussianMatrix function. ...
10
votes
10answers
683 views

Matrix indexed by one number

I'm trying to find a generic way (for arbitrary dimensions) to create a matrix like so a[1] a[2] a[3] a[4] i.e where it is indexed by one number, instead of say ...
1
vote
0answers
82 views

How to speed up the construction of a large matrix

As a part of a physics problem that I'm working on, I need to construct a rather large matrix. The matrix is a real symmetric $2^{m}\times 2^{m}$ matrix for some integer $m$, which we would like to ...
3
votes
2answers
89 views

Perform matrix/tensor contractions more efficiently

Problem: explicit index contractions for matrices using the Sum command take too long, and I want to improve the performance for complicated computations. Let me ...
0
votes
1answer
86 views

problem in solving equation

this happened to me when I try to get (f) which should equal sqrt(3)/2 is there any problem in my formula or what? ...
3
votes
1answer
83 views

Plotting eigenvalues smoothly

I am trying to plot how the eigenvalues of a matrix change by changing a given a parameter t. Of course the ordering of the eigenvalues does not matter mathematically but it does when I want to make ...
1
vote
1answer
72 views

Creating a transformation matrix with respect to given bases? [closed]

Let's say I have a linear transformation $T:V\to W$, along with some bases $\{v_1,v_2\}$ and $\{w_1,w_2,w_3\}$ of each respectively. Let's say all the information I have about the transformation and ...
2
votes
1answer
59 views

Efficiently Invert a Square, Block Diagonal Matrix

I am generating an n x n matrix where n is specified by DIM: ...
3
votes
1answer
59 views

Extending matrix (x,y-axis + data) via Interpolation. Looking for elegant & efficient way to write

Please, feel free to edit the title, if necessary. Hi, this is my code working, but actually, the size of my real dataset is 100x100. So, this is very inefficient way. What would be the most ...
3
votes
3answers
144 views

How can I assign matrix values in below form? [closed]

I want to create matrix as the below fig. shows. How can I do it with a do-loop, for-loop, if-loop, or any other way? Thanks a lot...
1
vote
1answer
79 views

Replacing negative components of a matrix with zeros [closed]

How can I replace the negative components of a matrix with zeros?
0
votes
0answers
24 views

Finding the percent difference between elements of a matrix and a list/vector [duplicate]

I have a large matrix of 24 columns, 11 rows, and a vector in the form of a one column, 11 row table. What would be the best method of finding the percent difference between each element of the matrix ...
1
vote
4answers
152 views

Non-rectangular pick of elements of a matrix

How to pick elements of a matrix that are inside a circle centered at the center of the matrix?
2
votes
3answers
145 views

How to write the Taylor expansion of the sum of several matrices?

When $A$ and $B$ are matrices, we have the following Taylor expansion for the inversion function together with basic information on convergence: $$ (A+B)^{-1}=A^{-1}-A^{-1}BA^{-1}+A^{-1}BA^{-1}BA^{-1}-...
1
vote
2answers
63 views

Trouble implementing logarithmic matrix norm

I wanted to write a quick function that calculates the logarithmic matrix norm with respect to the spectral norm. The formula is $$ \mu_2(A) = \lambda_\mathrm{max}\left(\frac{A + A^T}2\right). $$ So ...
4
votes
1answer
68 views

Creating a tensor from matrices

I have 3 nxn matrices that I'd like to combine into a nxnx3 tensor. Basically, I want a new nxn matrix where each element is a 3 tuple of the elements of the other 3 matrices at that same position. ...
3
votes
2answers
107 views

Matrix Diagonalization programming

I have a very simple problem, with me misunderstanding the use of Modules and Functions in general, in mathematica. I have a function of which I want to input a Matrix, and in the function I want ...
3
votes
2answers
137 views

Summing matrix products

I need to compute a double sum over a weighted matrix product: $L[M]=\sum_{i,j}^{N}\Lambda[[i]]\;\omega[[i]].M.\omega^{\dagger}[[j]]$. $\Lambda$ is a list of with N complex values(weights) and $\...
0
votes
0answers
93 views

How to Extract and Rearrange Elements in Doubly-Nested Lists

Hopefully any easy problem for you guys to help me with! I'm currently having an issue with writing some Mathematica code that will extract the each nth element in each array within a matrix, and then ...
6
votes
1answer
457 views

What does it mean when Mathematica returns a zero “eigenvector”? [closed]

For example, I ask Mathematica to compute the eigenvectors of $\left(\begin{array}{cccc} 1 & 1 & 0 & 0 \\ 0 & 1 & 0 & 0 \\ 0 & 0 & 5 & -4 \\ 0 & 0 & 4 & ...
1
vote
3answers
90 views

Percent Difference between elements from 2 matrices

If i have a 22 by 25 table of values which depend on n and r, and a list of values that depends on r that is a 22 by 1 matrix, how can I find the percent difference between each element, by row in the ...
0
votes
2answers
60 views

Plotting plane from a matrix or data table

After weeks collecting data I've decided to pass my results through Wolfram Alpha and see what it gets. The results are amazingly useful, specially the plane generated by linear regression. It is ...
3
votes
2answers
157 views

Zigzag ordered encoding of DCT co-efficients

I am doing DCT steganography. I have obtained a matrix of DCT co-efficient. I now want to perform zig-zag ordered encoding. The matrix is as follows ...
3
votes
0answers
89 views

How to force Series[] to compute expansions by considering non commutative multiplication?

I wish to compute the Taylor series expansion of the following iteration method $x_{k+1}=x_k-f'(x_k)^{-1}f(x_k)$ up to four terms of error ($e_k=x_k-\alpha$). When this is a scalar iteration, I very ...
0
votes
1answer
45 views

Plotting results of 'Do' loop in contour graph

I want to plot the results of a 'do' loop as a contour graph: ...
3
votes
1answer
153 views

How can I optimize the search between two lists, one that is changing length?

I'm trying to identify unique arrays by comparing two lists, one which is growing in length. The number of elements in the list grows as 2^n^2, where ...
6
votes
1answer
127 views

Issue in Det[…] when computing determinants of polynomials?

When I form a matrix of at least size $12 \times 12$ of second order polynomials in $w$ and I calculate the determinant of that, I get something that is a rational expression in $w$. Since the ...
1
vote
2answers
95 views

Plot values of an $m\times n$ matrix on the complex plane with color varying along $m$

Let's say I have a complex valued matrix $\begin{pmatrix}1+I&2+2I&3+3I\\4+4I&5+5I&6+6I\end{pmatrix}$ represented by a list: ...
4
votes
1answer
64 views

How to create overlapped block matrices and simplify the result

This is sort of a duplicate of Creating overlapped block matrices, but the question wasn't fully answered since the OP never returned to clarify. I am using Kuba's answer for FEM, but I have been ...
0
votes
1answer
58 views

Make Function from matrix [closed]

I have a set of excel data (time v temperature). When I extract it to mathematica it creates a matrix. I want to put the temperatures into a function that is time dependent, so is there a way to use ...
0
votes
1answer
133 views

Solving linear system with constraints

I need to come up with a solution for a rather, odd situation. Let's say I have an $M \times N$ matrix called ${\bf A}$, and I would like to solve it for ${\bf x}$ where $b_1 \le {\bf A} {\bf x} \le ...
1
vote
3answers
86 views

How to convert a matrix into a sparse matrix [duplicate]

If I have a matrix: row 1)1 0 0 4 row 2)0 0 0 0 row 3)5 1 0 0 row 4)0 5 0 0 row 5)0 0 0 9 How would I put it in a sparse matrix format: ...
7
votes
1answer
92 views

A few tuples at a time?

I want to generate $n$ by $n$ binary arrays, and then reduce the output from those arrays by performing a number of permutations and eliminating duplicates. The problem is that the number of arrays ...
5
votes
2answers
248 views

Speed-up the computation of this sum of small matrices

Given a matrix mat with a large number of rows (a few thousands) and a few columns (between 2 and 10), I'd like to compute the sum of the "small" matrices obtained ...
0
votes
0answers
44 views

Problem with stress transformation using InputField [duplicate]

I want to write a code for application of the transformation matrix onto a second-order stress tensor. I have a problem with showing the results. My steps are as follows: 1) I create a Grid with ...
-3
votes
1answer
47 views

Singular matrices with index 1 [closed]

If $A\in \mathbb{R}^{n\times n}$, the index of $A$ is the smallest integer $k$ such that $rank(A^{k+1})==rank(A^k)$ I want to find a singular (id est $\det(A) == 0$) and non symmetric matrix $A$ ...