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
3
votes
1answer
50 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}^...
29
votes
1answer
949 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
50 views

MatrixConditionNumber does not work in version 12.0

A = {{1., 0.}, {0., 2.}}; LinearAlgebra`MatrixConditionNumber[A]
4
votes
0answers
119 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
32 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
2answers
30 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
35 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
135 views

How do you solve a Lyapunov equation with given parameters? [closed]

The following matrix equation is a Lyapunov equation, $$ mA.x+ x.mA^T=-mC,$$ the matrix $mA$ is given by $$ mA= \begin{pmatrix} \frac {\gamma}{2} & \omega_{m} & 0 & 0\...
5
votes
4answers
193 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
31 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
347 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(...
5
votes
1answer
82 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
97 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
58 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
67 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
22 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 ...
0
votes
0answers
14 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
103 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
24 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
70 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
30 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
45 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 ...
1
vote
0answers
27 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
vote
1answer
66 views

How to interchange columns of a matrix? [duplicate]

Suppose I have a matrix M={{1,2,3},{4,5,6},{7,8,9}}//MatrixForm What code do I write to interchange columns and make it into ...
3
votes
1answer
117 views

Possible speed improvement for numerical linear algebra?

I have a question about further optimising a numerical linear algebra calculation. I've trawled through many useful posts on this site and have ended up with something quite efficient - I was ...
4
votes
1answer
183 views

Inconsistent results from Wolfram Cloud [closed]

More specifically, I was using the "no sign-in" option of Wolfram Programming Lab. I was trying to solve a matrix problem, with the following code: ...
0
votes
1answer
60 views

How do I treat polynomials as vectors?

From time to time I find myself in the following situation. I have generated a list of polynomials from some ring $R=\mathbb R[x_1,\ldots,x_n]$ and now I wish to view these polynomials as vectors in ...
0
votes
1answer
22 views

Computing Jacobian of $T(z,t) = (zt, z(1-t))$ [closed]

For $T: \mathbb{R}^2 \rightarrow \mathbb{R}^2$ s.t. $T(z,t) = (tz, (1-t)z)$, how does one use Mathematica to compute the Jacobian matrix of $T$ (to then compute its determinant)? Suppose $(z,t)$ are ...
33
votes
2answers
688 views

Eigenvalues broken in Version 12.0

Bug introduced in 12.0. The following code calculates the eigenvalues of a certain complex matrix, which come in pairs of opposite complex numbers. Therefore one can check whether the sum of all ...
0
votes
2answers
43 views

Solve linear system where unknowns are functions

I have the following linear system ...
1
vote
1answer
56 views

Why doesn't the matrix rank decrease in this case?

Consider the square matrix $M(k)$ of dimension 6 $ M(k) = \frac{1}{\sqrt{2}}\begin{bmatrix} 0 & 0 & 1 & i & 0 & 0\\ 0 & 0 & 0 & 0 & ie^{-ik} & e^{-ik} \\ 0 &...
1
vote
1answer
63 views

Duplicate RowReduce

Writing: Ab = {{1, 2, 3, 4, 2}, {4, 3, 5, 6, 3}, {1, 6, 7, 8, 4}, {9, 1, 2, 3, 2}}; RowReduce[Ab] I get: {{1, 0, 0, 0, 1/16}, {0, 1, 0,...
0
votes
1answer
39 views

Simplifying an expression involving a matrix and functions of it

I have implemented the following two matrices in Mathematica in order to compute s, but I don't know how I can further simplify the resulting expressions, e.g., ...
0
votes
0answers
32 views

Contradictions in PositiveDefiniteQ, Det and Inverse in Mathematica

A few words before the working example. Below we find 2 functions which should theoretically transform any matrix to its closest Symmetric Positive Definite (SPD) matrix: ...
0
votes
1answer
79 views

Obtaining eigenvectors without using Eigenvectors

Introduction I am trying to obtain the eigenvectors of a unitary matrix $M(k)$ which depends on a parameter k. This matrix $M(k)$ has dimension 6, and while for general matrices of dimension 6 it's ...
1
vote
0answers
56 views

Is linear algebra over $\mathbb{F}_2$ or a finite field possible? [closed]

I was interested in using Mathematica to do linear algebra over $\mathbb{F}_2$ in the context of solving for the code space of linear codes given a parity check matrix in $\mathbb{F}_2$. I've searched ...
2
votes
1answer
62 views

Efficient computation of matrices involving large sums of KroneckerDelta's

I was wondering if one could benefit from Mathematica's rich linear algebra methods for diagonalizing 2nd rank tensors. Namely, in the context of systems (fluids) comprised of capsule-like particles, ...
0
votes
1answer
47 views

Infinite linear system [closed]

Can Mathematica solve infinite linear systems? For example, if we have a infinite differential system, with recurrence, is it possible to solve it with Mathematica?
0
votes
1answer
89 views

An example of symmetric, real entry matrix with non-real eigenvalues, according to Mathematica. Is this a bug?

The following matrix is symmetric and all entries are real, ...
1
vote
2answers
44 views

How can I use the Solve command to find an eigenvector corresponding to a specific eigenvalue?

I have the following matrix in Mathematica: L={{0, 0, (111/190), (79/190)}, {0.16, 0, 0, 0}, {0, 0.12, 0, 0}, {0, 0, 0.19, 0}} Then using ...
4
votes
1answer
44 views

Strange bug in LUP Decomposition

I have written LU decomposition with partial pivot, but for some matrices, the entry L[[1,1]] isn't equal to 1 like it should be,...
1
vote
1answer
73 views

Drawing from InverseWishartMatrixDistribution. A machine precision error?

I'm drawing from the Inverse-Wishart Distribution, but I got the following error message: ...
2
votes
4answers
135 views

Skipping indices in a product

I have a matrix $A$ for which I want to compute the quantity $T\lambda_j = \Pi_{\lambda_i\ne \lambda_j} \frac{A - \lambda_i I}{\lambda_j-\lambda_i}$, where $\lambda_i$ ($\lambda_j$) denote the ...
0
votes
1answer
41 views

Performing a simple operation with operators [closed]

I have a map defined as $\qquad \Phi(X) = a^2\, Tr[X] |0\rangle \langle 0| + b^2\, Tr[X] |1\rangle \langle 1| + a\,b\, Tr[\sigma_z X] |0\rangle \langle 1| + a\,b\, Tr[\sigma_z X] |1\rangle \langle ...
1
vote
1answer
88 views

How to write the equation into matrix form [closed]

$[(a+k_i)^2+(b+k_j)^2]X_{i,j}-\sum_{m,n}V_{m,n}X_{i-m,j-n}=\mu X_{i,j}$. where $-N\le i,j\le N$ Here we can set $ N=10,a =1, b=1$ and $V_{m,n}$ is the matrix element of $V$. Once I write the ...
-1
votes
2answers
164 views

Solving inequality using matrix form condition

*answer is $x=(10,5)^T$ (a,b) is inner product. x and y is 2d vector. Find $\bar{x}$ within the area by the systems of inequality,$K(x)$ s.t. About inner product of vector F(x) and (y-x),$F(\...
4
votes
2answers
90 views

Element-wise multiplication of matrices with different dimension

I am interested in efficient element-wise multiplication of matrices with different dimension. Here is my solution: Matrix 1 with dim = {3, 4, 4} ...
6
votes
4answers
235 views

Identifying points in the frontier of a set

Let me start with an example. Let $$\mathbf{A}=\begin{bmatrix}3&1\\2&3\\1&5\end{bmatrix},$$ and let $Q=\{\mathbf{q}\vert\mathbf{q}\in\Bbb R^3_+ \land \sum_i^n q_i=1\}$ and $\alpha=\bigl(\...
4
votes
0answers
72 views

Orthogonal matrix decomposition of symmetric matrix?

If matrix mat is symmetric, we should be able to decompose it into eigenvalue matrix matJ and orthogonal matrix ...
2
votes
2answers
93 views

Unable to evaluate Eigenvalues and Eigenvectors for a matrix (2)

I have posted a similar question last year pertaining to this issue. Here's a link to my post together with the solution given: Unable to evaluate Eigenvalues and Eigenvectors for a matrix I have ...