Stack Exchange Network

Stack Exchange network consists of 175 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 [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.

23
votes
2answers
379 views

Eigenvalues broken in Version 12.0

The following code calculates the eigenvalues of a certain complex matrix, which come in pairs of opposite complex numbers. The code plots the real part of adding each pair. So the correct plot should ...
0
votes
0answers
33 views

Why do I get the following error? [on hold]

I am using LinearSolve function to obtain a set of solutions. When I run it outside of the For loop, it gives answers without any errors.
0
votes
2answers
42 views

Solve linear system where unknowns are functions

I have the following linear system ...
1
vote
1answer
54 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
59 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
37 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
71 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
47 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
54 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
44 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
88 views
1
vote
2answers
38 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
43 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
70 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
131 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
37 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
80 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
137 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
63 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
224 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
64 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
90 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 ...
1
vote
1answer
37 views

Why do I keep getting the same time from the Timing function?

I am running a gamblers problem solution where I am testing the timing involved in solving the Ax = b equation for matrices of n=100, 1000, 10000, and 100000. For some reason I keep getting the same ...
3
votes
1answer
35 views

How can I create a large matrix without running into hangs or recursion errors?

I'm trying to create a probability matrix, starting by creating a 100,000 by 100,000 identity matrix. However, when I try to create this using: ...
2
votes
1answer
49 views

Reduce returns false on equation solvable by LInearSolve [closed]

I was looking for general solutions of an equation I already solved for specific values with LinearSolve, but using Reduce returned False. Here's the code: ...
2
votes
1answer
63 views

How can I tell if a matrix is ill-conditioned or Singular by using the Eigensystem function(or LUDecomposition)?

I'm using the Eigensystem function, and I'm trying figure out whether or not it is singular or ill-conditioned. I'm using the function as so: ...
12
votes
2answers
786 views

Solving “Resistance between two nodes on a grid” problem in Mathematica

In the context of resistor networks and finding the (equivalent) resistance between two arbitrary nodes, I am trying to learn how to write a generic approach in Mathematica, generic as in an approach ...
0
votes
0answers
40 views

SymFullRankQ - a function that calculates the conditions for a matrix to be full rank

I found in this article references to a function that manages to do this: is used to find the conditions for the symbolic matrix E to have full rank This is actually very interesting and useful. ...
4
votes
2answers
241 views

Numerical value of Determinant far from what it is supposed to be

I have a large matrix with numerical components and want to set the determinant to zero using the parameter h (see below). Naively, I would have expected that ...
4
votes
1answer
85 views

Using Non-Negative Matrix Factorization (NNMF)

I am trying to understand NNMF (Non-Negative Matrix Factorization). This is not a built-in function in Mathematica, but there is a package that implements it, which is refered to in this post. The ...
1
vote
1answer
34 views

Find coefficient in a linear combination

It's a very simple problem, but I don't find the way to solve it with Mathematica. let's say $A=a+b$, $B=3a$, $G=b$. I want to find at least one (if any) solution to $x A+ y B=G$ for $x,y$. I tried ...
5
votes
2answers
272 views

All possible A of Ax=b with constraints on A

I have a linear problem that I want to solve but the method is quite different from normal, the problem is still Ax=b. However, in this instant I have A being unknown, apart from the fact that each ...
0
votes
1answer
53 views

Strange answer for Eigenvalues of a 4x4 matrix [duplicate]

I am getting these strange eigenvalues of this simple looking 4-dimensional matrix: ...
0
votes
0answers
27 views

Linear dependency of vectors of functions

I would like to find a symbolic way to obtain a Q-function (Boolean output) for the following problem. I have the following inputs: ...
0
votes
1answer
39 views

How to prove rank(A+) is no more than rank(A)? [closed]

look here my friend. How to prove the following equation? Or give a counter-example. Thank you so much $$\text{rank}(A^+)\leq \text{rank}(A)$$ where $\text{rank}(A^+)$ represents the positive ...
2
votes
2answers
53 views

Normalize a vector: error [duplicate]

I have this simple example in which I am trying to write a column vector (ket vector) and then I want to normalize it. It seems that ther is something wrong, leading to an error message "The first ...
1
vote
0answers
26 views

Gauss elimination, reordering rows based on pivot values

I'm trying to create a code for Gauss elimination such that if there's a zero pivot during elimination, the equation will be reordered with the next row with a non-zero element and if it can't do that ...
-2
votes
1answer
52 views

Mathematica Plot [closed]

How can I plot List in Mathematica
0
votes
1answer
85 views

Triple product in spherical coordinates

Given six real numbers $a,b,c,d,e,f$ (say between $0$ and $\pi$) I would like to express the following determinant in a compact and "reasonable" way: $$ \det \begin{bmatrix} \sin a \cos b & \sin ...
4
votes
2answers
388 views

Using LinearSolve instead of Inverse does not give a good enough precision

If I want to calculate $B^{-1}A$, then instead of using Inverse, I should in theory just be able to use LinearSolve[B,A]. Now ...
1
vote
2answers
60 views

Different Value for LU Decomposition [duplicate]

When I try to LU decompose a matrix m, I get a different result in mathematica than an online calculator. Mathematica also gives me values that is different from my own derived values for the elements ...
0
votes
1answer
68 views

Determinant of the symbolic matrix is giving very large expression

I have a symbolic matrix of size 16 by 16. I tried to get the determinant of this symbolic matrix, but it turned out to be a very large expression. How to make this expression concise so that it ...
2
votes
0answers
49 views

“Learning” to parameterize Hermitian matrices with a basis using neural networks

I'm interested in using neural networks to "learn" how to write down Hermitian matrices, specifically those which are defined over spaces with a specific tensor product structure. The simplest example ...
1
vote
2answers
66 views

Eigenvalues error: “The method ”Banded“ accepts only sparse matrices with elements that are machine-real or machine-complex numbers”

I'm having one issue with the Eigenvalues function in some code priorly discussed here. There the example is tridiagonal, but here, let us consider this simple ...
8
votes
1answer
471 views

3.4 GHz Ryzen 5 slower to diagonalise large matrix than Intel i5-6300U 2.4 GHz

Sorry that this is quite a specific question but I need to diagonalise large matrices for the problem I'm trying to solve and can't for the life of me work out what's going on: I was expecting that ...
7
votes
2answers
747 views

How to optimize Mathematica code that depends on eigenvalues of big matrices and big sums?

I've been using Mathematica recently to generate some plots of a few functions. I've been able to get it right after a few questions here. The resulting code, which works, is this: ...
2
votes
0answers
58 views

Memory leak in SmithDecomposition?

While trying to compute a large number of Smith decompositions in Mathematica 11.0 under Windows 10, my computer keeps running out of memory for no apparent reason. Here is a self-contained example ...
1
vote
0answers
57 views

Integrating wavefunctions over a sphere

I am attempting to numerically solve the inner product of two particles and an electric dipole interaction potential. I am incredibly limited in my skills, and need to know how I can begin setting the ...
3
votes
1answer
51 views

Is it possible to solve for a matrix $ m $ satisfying $ m\cdot x=b $, given the vectors $ x $ and $ b $?

At first I thought it should be LinearSolve, which however turns out aiming at x, given m ...