Questions tagged [linear-algebra]

Questions about Mathematica functionality related to manipulating vector spaces and linear mappings between such spaces. This includes determination of matrix properties, matrix transformations, decompositions, and factoring.

Filter by
Sorted by
Tagged with
7
votes
2answers
219 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 ...
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
36 views

Trying to extract the Eigen values and Eigen vector of a matrix

I have a Matrix A, which is a function of ω. I wanted to find the eigenvalues and eigenvectors of this matrix, how to do it. I have used the EigenSystem function ...
5
votes
3answers
398 views

Defining a big matrix for iterative algorithm

I need to solve this system of equations with Seidel and Jacobi methods, so I tried to define a big matrix in Wolfram. I have read documentation, and I wrote the following command that should help me,...
3
votes
1answer
198 views

Solve the vector-matrix equation. Minimize the length of the desired n-dimensional vector

There is the following vector-matrix equation: $$\mathbf x^\top\mathbf M\mathbf x=\begin{bmatrix}x_1&x_2&x_3\end{bmatrix}\begin{bmatrix}a&b&c\\d&e&f\\g&h&i\end{bmatrix}...
7
votes
1answer
137 views

Efficiently calculating matrix exponential of a recursively generated matrix

Given a matrix $A$ of size $N \times N$, I want to evaluate the function \begin{equation} F(t) = |\operatorname{Tr}(\exp(-i A t))|^2 \end{equation} as a function of $t$. Here, $A[n]$ is constructed ...
0
votes
1answer
32 views

Retrieve the independent variables from a linear replacement list

Is there a good way to convert a linear replacement list into a list of the independent variables? For example, I would like to take {n1->n3+n4, n2->n3+2n4} and get {n3,n4}, the variables that n1 and ...
1
vote
1answer
42 views

How to check if 0 polynomial lies in span of some polynomials?

I have lot of polynomials like this ...
10
votes
2answers
230 views

Solving “Lyapunov-like” equation AX+X'B=C

Is there some way I can solve the following equation with $d-by-d$ matrices in Mathematica in reasonable time? $$AX+X'B=C$$ My solution below calls linsolve on $d^2,d^2$ matrix, which is too ...
2
votes
1answer
46 views

Efficient Linear Operators on SparseArrays

I have a rank four SparseArray of dimension {40, 40, 40, 40}. I wish to apply a linear operator to it, whose form I know abstractly. That is, I have a simple closed form for the action of the operator ...
1
vote
1answer
93 views

(Row?) reduction of a system of equations

For a mathematical problem I am trying to solve, I have (say) $(N+1)$ inhomogeneous linear equations in $M$ variables of the form $$\sum_{a=1}^{M}c_{i a}p_{a} = \xi_{i} \quad \text{ where } i=1,\...
8
votes
1answer
201 views

Solving underdetermined Lyapunov equations?

I'm wondering if there's an efficient way to get a solution (ie, LeastSquaressolution) for Lyapunov equation $AX+XA=C$ with symmetric positive definite $ A $ and $ ...
1
vote
0answers
35 views

Getting a non zero determinant of matrix R, when the Rank of R is not equal to Dimension of R

I have a square matrix whose dimensions is 9 cross 9, when I extract the rank of the matrix R, I am getting rank as 6. I have constructed R matrix by minimizing the Lagrangian Lg with respect to a[1].....
0
votes
0answers
30 views

Sequential production of Eigenvectors?

I have to deal with very large matrices in Mathematica (dimensions $10^4\times10^4$ at least). Obtaining the eigenvalues of these matrices is not so difficult since, it is not memory intensive or ...
0
votes
0answers
32 views

How to solve this set of linear equations

I am trying to solve six linear equations, for which a solution exists (since it can be recovered by Matlab). I am trying to reproduce it here. I have the following MWE: ...
0
votes
2answers
96 views

Matrix equation solving

I am new to Mathematica and I try to apply the solution given to this problem. So I have: $$A = \begin{pmatrix}50 & 3 & 10 & 2\\\ 3 & 60 & 7 & 1\\\ 10 & 7 & 55 & 4\...
0
votes
0answers
41 views

Normalized eigenvectors are different depending on when the limit is calculated

I have this code: ...
2
votes
1answer
137 views

Plot feasible region of a high-dimensional LP only along some dimensions

I have a question on the possibility of using Mathematica to plot a convex closed region satisfying a linear system of equalities and inequalities. Let me first present the linear system. Let $x\...
4
votes
2answers
952 views

Two matrices that are not similar have (almost) same eigenvalues [closed]

I have two matrices $$ A=\begin{pmatrix} a & 0 & 0 \\ 0 & b & 0 \\ 0 & 0 & c \end{pmatrix} \quad \text{ and } \quad B=\begin{pmatrix} d & e & f \\ d & e &...
0
votes
1answer
91 views

How can I get the Eigen system of a certain matrix? [closed]

How can I get Eigen system of c, where c = a - iota * b? Please help me to find the Eigen system in a nice form. ...
8
votes
1answer
184 views

Getting scores from PCA

I'm not super familiar with Principal Component Analysis, but from what I understand, it sorts a vector in order of decreasing variance, and uses that to transform the vector to correlate variables ...
3
votes
0answers
75 views

Derivative of eigenvalues

I work with 4x4 Hermitian matrices (r). I want to calculate a derivative of a function f[t,r] (ff[t_,r_]=1/2*D[f[t,r],t]), where the function f depends on the absolute value of the eigenvalues of r. ...
8
votes
1answer
232 views

Finding the null space of a large sparse matrix

I am trying to compute the null space of a large $n\times n$ sparse matrix. No matter how large the dimension of the matrix is, it will always look like as below: The figure on the left shows the ...
3
votes
2answers
786 views

Problem with Eigenvectors

When I want to calculate eigenvectors of the following matrix in Mathematica the only answer it gives me is zero vector, anybody knows how to fix this? here's my matrix : \begin{equation} X=\left(\...
0
votes
1answer
134 views

Can I diagonalize a 512 by 512 matrix? [closed]

...with Mathematica? Or is this going to be impossible? I don't want to start work if it is hopeless. I've already solved the problem on a smaller scale, which involved an 8x8 matrix. ...
6
votes
2answers
113 views

Fast algorithm for finding all solutions of simple equation involving only addition of terms from list

I have a list $X=\{n_1,n_2,n_3,n_4, \dots, n_i\}$ with $n_i \in \mathbb{C}$, an integer $m \in \mathbb{N}$ and $S \in \mathbb{C}$. My question is how to find all solution to the equation $$\sum_{j=1}^...
35
votes
1answer
1k views

How to fit a linear model in the Bayesian way in Mathematica?

Basically, I'm looking for the Bayesian equivalent of LinearModelFit. As of the moment of writing, Mathematica has no real (documented) built-in functionality for ...
5
votes
1answer
73 views

MatrixConditionNumber does not work in version 12.0

A = {{1., 0.}, {0., 2.}}; LinearAlgebra`MatrixConditionNumber[A]
4
votes
0answers
143 views

Speed improvements and confusion for MapThread and Dot

I have a question / confusion over improving the speed of MapThread[Dot,...] for lists of tensors. My problem involves taking two lists of tensors and then ...
1
vote
1answer
39 views

Identification of linear combinations in a matrix

I have a matrix R which is having a dimension of 20 cross 20. When I extracted the rank of this matrix I got 16. I just wanted to which are these four rows are or columns which are dependent on each ...
1
vote
1answer
85 views

Phase choice for Singular Value Decomposition

I'm using SingularValueDecomposition to find the unitary matrices that diagonalize a given matrix (that I have). This decomposition is unique, up to multiplication for an arbitrary phase of each ...
1
vote
2answers
38 views

Checking if a system of linear equations admits a positive solution

How can I use Mathematica to check if a system of the form $A x > 0$ admits a solution $x\geq 0$ where $A$ is a $m \times n$ matrix and $x \in \mathbb{R}^n$. All inequalities are to be understood ...
0
votes
1answer
48 views

Conditions to make unitary a given matrix

Suppose I have some symmetric matrix W = {{c[1, 1], c[1, 2], c[1, 3]}, {c[1, 2], c[2, 2],c[2, 3]}, {c[1, 3], c[2, 3], c[3, 3]}}; where the c's are complex and I ...
1
vote
1answer
185 views

How do you avoid Null in matrix? [closed]

The following matrix equation is a Lyapunov equation, $$ mA.x+ x.mA^T=-mC,$$ the matrix $mA$ is given by $$ ...
5
votes
4answers
282 views

Maximum of determinant of $n\times n$-matrix with elements 0 and 1

Generalizing https://math.stackexchange.com/questions/3265627/largest-value-of-a-third-order-determinant-whose-elements-are-0-or-1 I'd like to propose two related problems (a) find the maximum value ...
0
votes
0answers
36 views

Ordering of Eigenvectors [duplicate]

I am interested in computing the derivatives of the eigenvalues of a certain $n\times n$ Hermitian matrix $M(t)$. I know I can do this easily since I know the exact expression for $\dot{M}$, and the ...
18
votes
3answers
398 views

Generate coefficient array from general formula of linear equation system

This is a problem coming out in the implementation of finite difference method (FDM). Here is a toy example. Suppose we want to solve the boundary value problem (BVP) $$y''(x)=\sin(x),\ y(0)=0,\ y(...
4
votes
2answers
228 views

Help with coding a matrix

I have a $n \times n$ matrix $A$ with a full set of eigenvalues $\lambda$ including repetitions. I want to create the following $i \times i$ matrix: $$\left(\sum_{a=2}^i (a-1) |a-1⟩⟨a| \right) + \...
5
votes
1answer
89 views

Efficient way to sum over an index repeated more than twice

I'm looking for an efficient way of computing sums of the type $$D_{jk} = \sum_{i=1}^n A_{ij} B_{ik} C_{i}$$ for large numerical matrices $A$, $B$ and $C$. Here is a slow solution: ...
4
votes
1answer
106 views

Selecting unique column position of a non-zero value for each row of a matrix

I have a matrix in this case of 3x11, but I want this to work for any dimension matrix. I want per row a column position on a non-zero value in that row, but that this value should be different than a ...
0
votes
1answer
63 views

Sum of powers of zero [duplicate]

I would like to calculate the following sum Sum[0^(k-a), {k, 0, Nin}] for a positive integer $a$. With considering $0^0=1$, my expected answer of the sum is $1$, ...
0
votes
2answers
110 views

How to get eigenvectors of a 4x4 matrix? [closed]

MatrixForm[m = {{2, 9, 0}, {3, 8, 9}, {3, 9, 1}}] Eigensystem[m] I am facing problem in finding eigenvectors using ...
0
votes
0answers
25 views

Two coordinate rotations and a translation to for a 4x4 matrix

I am looking to do ewo coordinate rotations and a translation. I'd like the new coordinate system to be shifted by x,y,z (in the directions of the same name) and then rotated by theta in the x hat ...
1
vote
0answers
19 views

Solve, store, and access eigenvalues and eigenstates of M[x,y], for various points {x,y}

I'm interested in solving a position dependent eigenvalue problem for matrix M[x,y], where {x,y} is some discretized set of points. I may need to access the eigenstates and eigenvalues multiple times ...
5
votes
2answers
299 views

Lowest Magnitude Eigenvalues of Large Sparse Matrices

I am trying to find the first three lowest eigenvalues of large sparse matrices of size range $10^3 - 10^5$. The matrices depend on some parameter $x$, so I first construct the matrices and then use ...
0
votes
0answers
54 views

Inverse of Sparse Diagonal Array not Sparse

Kind of bummed that when I take the inverse of a matrix that is a diagonal sparse array, the result in not a sparse array. Further, the time to compute the inverse is the same as the time to compute ...
0
votes
3answers
80 views

Expand and Simplify do not work for NonCommutativeMultiply

Expand and Simplify do not work for NonCommutativeMultiply[] then how do we expand an expression like (a+b)**(a-b) ?
0
votes
0answers
34 views

Solving equations, checking linear dependency of equations

I have the following input and try to do solve the equations for in total four unknowns. When I run the input only "solutions" for two of the four unknowns are given in the output. I am not quite sure,...
2
votes
1answer
91 views

Is there a method to preserve order when matrix multiplying in Mathematica?

I know that commutativity can be preserved in Mathematica by using ** i.e. a*b can get printed as b a but if I use a**b then it will always be printed as a b. However, I am not able to implement ...
2
votes
1answer
95 views

Bug in SmithDecomposition?

While trying to calculate the SmithDecomposition of an integer 293x329 matrix with less than 3000 non-zero elements in the range -4 to 3 several errors occur, none of them which seem to make any sense ...

1 2
3
4 5
23