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
0 answers
25 views

General symbolic computations of matrices using Schur complement

Suppose $A,B$ are $n \times n$ square matrices of the form $A = \left[C_{1}\middle|\frac{I}{0\dots0}\right], B= \left[C_{2}\middle|\frac{I}{0\dots0}\right]$. Say $C_{1} \rightarrow a_{i}$ and $C_{2} \...
2 votes
1 answer
110 views

In NMinimize, how to incorporate constraints on positive semidefiniteness of a matrix which is not the matrix variable being optimised?

The problem I want to solve the following problem for symmetric matrix $X$: $$ \begin{aligned} \min_{X\succ 0} \; & -\log(\det(X)) & \\ \text{subject to} \; & \begin{pmatrix} X &...
3 votes
0 answers
44 views

First few smallest eigenvalues of a large dense symmetric matrix

I construct a large (say 2000x2000) matrix M whose entries are real random variables drawn from a certain distribution. Most of these values will be nonzero, so <...
8 votes
1 answer
209 views

Why Mathematica is treating the product of (specified) real variable as complex?

For the given matrix ...
4 votes
1 answer
183 views

LinearSolve[] doesn't give a solution

I am using LinearSolve[] to solve equations that theoretically should admit a unique solution, but somehow it is giving error message saying that For instance, if ...
2 votes
0 answers
42 views

VandermondeSolve changes, InterpolatingFunctionToPiecewise breaks

I just notice ResourceFunction["InterpolatingFunctionToPiecewise"] is broken in v13.1. (Perhaps it's in v13.0, I'm not sure. ) Here's a sample: ...
-4 votes
1 answer
67 views

Constructing NxN tridiagonal block diagonal matrix with N is a variable [closed]

Hi please can someone help me writing a program of generating a tridiagonal block matrix with dimension of NxN where N is a variable can be 50, 100, 200, 300...etc , Well I don't know how I'm a ...
0 votes
1 answer
46 views

Solve eigen-matrix equation

When I read an article by Garbe, where have an eigenmatrix $$B M_i + M_i B^T=\lambda_iM_i$$ and have the following eigenmatrices and eigenvalues: $$ M_0=\begin{bmatrix} 0 & 1 \\ -1 & 0\end{...
8 votes
6 answers
15k views

How to find the index of a square matrix in Mathematica quickly?

Let $A$ be an $n\times n$ complex matrix. The smallest nonnegative integer $k$ such that $\mathrm{rank}(A^{k+1})=\mathrm{rank}(A^{k})$, is the index fo $A$ and denoted by $\mathrm{Ind}(A)$. I would ...
5 votes
1 answer
250 views

How to implement Drazin inverse?

Wolfram site says it will be implemented in the future as DrazinInverse[m] function. But what to do now?
4 votes
1 answer
364 views

Implementing positivity constraints over a six-dimensional hypercube

This question involves the same subject matter as my previous one (How can one achieve the most accurate estimates of certain six-dimensional integrals under specific constraints?), but with another (...
0 votes
1 answer
54 views

Cholesky with complete pivoting?

I'm looking for an implementation of Cholesky decomposition with complete pivoting. It is the lev3pchol.f function added in Lapack 3.2 (working note) It has an ...
4 votes
1 answer
47 views

Proper usage of Assuming statement

I want to evaluate a command under an assumption, and thought Assuming was the right way to go. Suppose we want to calculate a Matrix rank. Following the second ...
4 votes
4 answers
164 views

Cholesky/LDLt that works for singular matrices?

TLDR When given $A=X'X$ decomposition, user298737 works by relying on QRDecomposition on $X$. If we didn't have this decomposition, one could use QR to get full-rank part of $A$ and use Cholesky on ...
1 vote
1 answer
92 views

Manipulating a Haar random unitary matrix and computing probabilities

I am new to Mathematica and its many features. Here is a problem that I was trying to model. Consider a $4 \times 4$ Haar random unitary $U$. Define by $|00\rangle \langle 00|$ the following matrix: \...
0 votes
1 answer
60 views

Checking inner workings of a statement of linear algebra using Mathematica

Suppose $A,B \in M_{n}(\Bbb{R})$ such that $A = \left[C_{1}\middle|\frac{I}{0\dots0}\right], B= \left[C_{2}\middle|\frac{I}{0\dots0}\right]$ , where $A$ and $B$ have different first columns (...
2 votes
1 answer
676 views

solving linear systems with parameters

I am trying to solve simple, small linear systems, with parameters. I would like to have the result shown for various values of the parameter. RowReduce[], ...
3 votes
2 answers
294 views

How to solve this equation with rank relation of matrix

It has been known that matrix A is equivalent to matrix B, and I want to find the possible value of parameter ...
15 votes
6 answers
2k views

How to solve this matrix equation

How to solve the following matrix equation? Solve[MatrixRank[{{1, x, 3}, {2, 4, 5}, {2, 4, x}}] == 2, x, Reals]
1 vote
2 answers
424 views

How to code a sum in Mathematica and how to solve it?

I'm trying to find the coefficients of the Radau IIA Runge Kutta Implicit scheme. Those Runge Kutta schemes have Butcher tableau consisting of Cs, As, and Bs. article I have already computed the Cs as ...
1 vote
0 answers
76 views

How does Mathematica compute PseudoInverse? [closed]

What is the algorithm that is used in computing the PseudoInverse in Mathematica?
9 votes
3 answers
9k views

How do I keep the right ordering of eigenvalues using Eigensystem?

I'm having an issue with the Eigensystem command. I need to diagonalize a bunch of 3 by 3 complex valued matrices, but more importantly, I need to keep the exact ...
5 votes
2 answers
89 views

Mathematica code for Gram Schmidt Orthogonalization for a general Inner Product (in particular, weighted Bergman spaces)

I am trying to write a Mathematica code to find an orthonormal basis of the weighted Bergman space defined by: $$A^2(\varOmega) = \Big\{f \in \operatorname{Hol}(\varOmega) \; \Big| \; \|f\|= \...
6 votes
1 answer
392 views

LeastSquare Solution for the Continuous Time Lyapunov Equation

I have been working with a problem which involves solving the continuous time Lyapunov equation $$A R + R A^\top = G$$ for the symmetric positive definite matrix $R$. Here $A$ is real, invertible ...
4 votes
1 answer
68 views

How to keep unnecessary parentheses in TraditionalForm?

My goal is to keep the parentheses in the following code sample: TraditionalForm@HoldForm[(CenterDot[a, b])] The problem is that Mathematica still removes the ...
3 votes
3 answers
268 views

Visualizing action of matrix

One can visualize linear transformation $P$ by animating action of $P^k$ for k between 0 and 1. Below is an attempt that does this with points. Ideally I would also like to visualize effect on the ...
0 votes
1 answer
63 views

Finding the transformation to get a matrix from another matrix

I have two symbolic matrices, with the same eigensystems, with arbitrary elements that read ...
3 votes
1 answer
104 views

Proof of symbolic matrix

For any n-order matrix A, B, H $[A, B] \stackrel{\text { def }}{=} A B-B A$ Try to prove: (1) $\left[k_{1} \boldsymbol{A}+k_{2} \boldsymbol{B}, \boldsymbol{H}\right]=k_{1}[\boldsymbol{A}, \boldsymbol{...
6 votes
1 answer
148 views

Algorithm for the resolvent of a matrix, and LUBackSubstitution

Suppose A is a complex n x n matrix where n is quite big, given as a numeric array. For many ...
16 votes
4 answers
3k views

Plot MATLAB icon

I started to explore this on a whim and haven't succeeded yet… Some introduction for the icon is found here and here, but I can't understand it very well. (I admit that, though playing with ...
4 votes
3 answers
217 views

Plotting resolvent of the matrix

I'm trying to reproduce resolvent plot of circulant matrix, page 59 of Mark Embree's slides Straightforward solution below, relying on ComplexPlot3D is below. It ...
3 votes
1 answer
327 views

Why ParallelTable is even slower than Table for large tensor construction?

I would like to create a large rank-4 tensor by using both Table and ParallelTable. What is actually constructed is given below: ...
9 votes
1 answer
288 views

Eigendecomposition of a matrix with a variable

I have an issue with a decomposition of a matrix $B$ that is positive semidefinite and that depends on a parameter $x$. Writing $\lambda_i\geq0$ the eigenvalues and $\psi_i$ the corresponding ...
-4 votes
2 answers
68 views

Least norm solution to a set of linear equations [closed]

Suppose I have a set of linear equations $M x = y$ where there are infinitely many solutions. I want to find a solution $x$ with the smallest $l_2$ norm $\|x\|_2$. Is there an efficient way to do this?...
2 votes
1 answer
199 views

How to expand a function as a linear combination of other functions?

I would like to be able to expand certain functions as linear combinations of other specified functions when I know that the original function can be represented in such a way e.g. we know that $\sin^{...
5 votes
1 answer
147 views

Finding eigenvectors of a symbolic matrix

I have a $2\times 2$ symbolic matrix for which I want to compute the eigenvalues. It is given as: Clear[a, b, m] m={{a, b}, {b, -a}} and it spits out the ...
3 votes
1 answer
157 views

Matrix Integro-differential equation

I'm trying to solve this integro-differential equation to obtain the density matrix elements $\rho$. $ \frac{d\rho}{dt}=-i[H_{0}(t),\rho(t)]-A^{2}\Big[H_{1},\int_{t1}^{t}e^{-B(t-s)}\Big(e^{-i\int_{s}^{...
2 votes
2 answers
96 views

Solution to a linear equation with minimum rank

Suppose I have a linear equation, $X.M=A$, for given matrices $M$ and $A$. I can use FindInstance to produce a solution $X$. How can I add the constraint that $X$ has the least rank? Indeed, I could ...
4 votes
1 answer
159 views

Nonnegative Least Squares Algorithm (NNLS) [closed]

Can anyone optimize the code below which is developed in an old version of Mathematica (2003) both in terms of efficiency and adaption to the latest versions of Mathematica? Description of the code: ...
5 votes
4 answers
286 views

Approximate strictly positive solution to a linear set of equations?

Consider a positive matrix M and a positive vector b, e.g. ...
0 votes
2 answers
117 views

How to solve this equation with matrix rank condition

It is known that quadratic form $f\left(x_{1}, x_{2}\right)=x_{1}^{2}-4 x_{1} x_{2}+4 x_{2}^{2}$ can be transformed into quadratic form $g\left(y_{1}, y_{2}\right)=a y_{1}^{2}+4 x_{1} x_{2}+6 y_{2}^{2}...
1 vote
0 answers
83 views

Solve 2x2 complex unitary matrix with constains using Solve does not work

I have a 2x2 complex-valued matrix, $U=\pmatrix{U_{1,1}e^{i\theta_{1,1}}&U_{1,2}e^{i\theta_{1,2}}\\ U_{2,1}e^{i\theta_{2,1}}&U_{2,2}e^{i\theta_{2,2}}}$ which I must impose two ...
37 votes
1 answer
2k views

Complex eigenvalues from a sparse Hermitian matrix

Bug introduced in 9.0 or earlier and persisting through 13.0.1. I notice in the following example that wrong complex eigenvalues are resulted if calculating from a Hermitian sparse matrix, which ...
1 vote
0 answers
51 views

Controlling accuracy for code

So I have a lot of trouble controlling precision and or accuracy with Mathematica. I have tried reading up for it but in the end I get even more confused. Here is my code, it is a little long but it ...
3 votes
2 answers
204 views

How to obtain independent variables from a set of linear constraints

I have a question, how to obtain independent variables from a set of linear constraints. Let me illuminate this by a simple example, we have 5 variables and 3 linear constraints, $x1+x2+2*(x3+x4)+x5=...
1 vote
2 answers
93 views

How can I generate a tridiagonal block matrix? [duplicate]

$$\begin{pmatrix}C&D&&&&\\D&C&D&&&\\&\ddots&\ddots&\ddots&&\\&&&D&C&D\\&&&&D&C\end{pmatrix}$$ I want ...
1 vote
1 answer
519 views

Plotting Invariant Manifolds of the Henon Map

Given the following map: \begin{align} & x_{n+1}=-y_n+2x_n^2 \\ & y_{n+1}=\beta x_n \end{align} for $β \in (0,1)$, $x_n \in \mathbb{R}, y_n \in \mathbb{R}$ (which is a one parameter version of ...
0 votes
0 answers
204 views

Eigenvalues not invariant after similarity transformation

I have two examples of matrices that undergo a similarity transformation: a random matrix, and an exclusion-process inspired matrix. The similarity transformation $\sigma$ is given by an $L \times L$ ...
0 votes
0 answers
33 views

Generate a random matrix with a condition on its eigenvalues

I can generate Radom matrices using mat = RandomReal[{-1, 1}, {2, 2}]; But how can I generate the mat matrix so that the ...
1 vote
0 answers
46 views

Solving a badly conditioned set of linear equations

I have a numerical high-precision badly conditioned over-constrained set of linear equations that I want to solve. I start out with m=616 equations and ...

1
2 3 4 5
30