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
2
votes
2answers
50 views

Tensor contraction

How do I let mathematica compute a tensor contraction like $\delta_{ab}\delta_{bc}$ with an output $\delta_{ac}$ efficiently? I tried TensorContract and TensorReduce but they were not helpful. ...
0
votes
1answer
44 views

QR-Decomposition [closed]

I should make a program in which with help of QR-decomposition find approximation of x^sinx shaped a+bLnx+c*e^x for a values x € ...
1
vote
1answer
54 views

Finding a Numerical Solution to a Linear Combination Inequality

Can I use Mathematica to find a value for $\alpha$ that satisfies the below linear combination inequality? If so, how? $$ \begin{bmatrix} -1 \\ -1 \\ -1 \end{bmatrix} < \begin{bmatrix} g_1 \\ \...
1
vote
2answers
56 views

Plotting an integer-valued function

Consider the quantity $$H=n-1-\sum_{i\ne j} R_{ij}, $$where $R$ is a random $n\times n$ Hermitian matrix with trace $1$. The code that generates it was kindly provided by a user in another question of ...
3
votes
1answer
68 views

Defining a sum on the elements of a matrix

I am interested in defining the quantity $$H=n-1-\sum_{i\ne j} R_{ij}, $$where $R$ is a random $n\times n$ Hermitian matrix (as a side question: how should I go about adding the condition $\rm{Tr}(R)=...
0
votes
0answers
24 views

Matrices of Machine- or Arbitrary-Precision Real Numbers Error While Using Arnoldi for Large Sparse Matrix [closed]

I'm trying to use the built in Arnoldi method in Mathematica to compute the first 1440 eigenvalues of a large sparse matrix. After importing ...
5
votes
0answers
61 views

Computing log-determinant?

Mathematica does-not have a function to compute the log-det of matrix? Naively computing Log[Det[M]] can be numerically unstable.
3
votes
1answer
81 views

Diagonalizing a symbolic matrix

I am trying to diagonalize the following matrix \begin{equation} \left(\begin{array}{cccc} { \frac{1-K\left(x_{2}^{2}+x_{3}^{2}\right)}{1-K|x|^{2}}} & { \frac{K x_{1} x_{2}}{1-K |x|^{2} }} & { ...
2
votes
0answers
73 views

What's a quick test to see if an $n \times n$ matrix is diagonal and/or proporitional to the identity matrix? [closed]

As the title indicates, I want to test whether an $n \times n$ matrix (numeric, symbolic,..) is diagonal and/or proportional to the $n \times n$ identity matrix. I, of course, can test whether the $n^...
3
votes
1answer
59 views

Is this a correct implementation of the principal-leading-minors test for positive-semidefiniteness?

I am asking this question in response to comments by mikado and Daniel Lichtblau on my question Maximize a six-dimensional function subject to joint positive-semidefiniteness constraints I gave two ...
2
votes
0answers
85 views

Converting complex equations to matrix form

My question is a continuation of the topic: How to convert equation to vector (matrix) form? It is necessary to separate the components of equations into vectors and matrices and a combination of ...
5
votes
2answers
143 views

Enumerating $4 \times 4$ matrices satisfying parity constraints

I've encountered a problem, which requires computer aid, but it seems a little above my Mathematica prowess because it requires counting objects satisfying some simple conditions. It seems doable, ...
1
vote
1answer
53 views

How to feed a list of disks to RegionUnion

I have a bit of code which creates a list of disks (I'm exploring Gershgorin circles) based on a matrix tm. ...
8
votes
3answers
356 views

How can I get all 4 × 4 submatrices of an n × n matrix?

I have a square matrix, I need to extract all possible combinations of 4 × 4 submatrices, where $n > 4$. For example in the case of a 6 × 6 matrix, there are 15 4 × 4 submatrices. I need the list ...
0
votes
1answer
31 views

Making substitution to an expressions with a list of numerical data [closed]

Suppose I have an expression similar to this: y=23.23*(h[x]^2)*(D[h[x],x])*(D[h[x],{x,3}])/(13.2+Cos[0.245x]) The actual expression is a lot more complicated, but ...
5
votes
2answers
346 views

How to reduce the λ-matrix to Smith Standard Form

A = {{1 - λ, 2 λ - 1, λ}, {λ, λ^2, -λ}, {1 + λ^2, λ^3 + λ - 1, -λ^2}} How to reduce the above λ-matrix to the following Smith standard form: ...
2
votes
2answers
84 views

`Solve` Performance Tuning

I'm facing a Problem in Mathematica, where I have to solve a large number of equations generated by an AppendTo. ...
2
votes
1answer
106 views

How to solve for Transpose[X] A X = B

I need to find a transformation matrix of the metric tensor but I don't know how to solve for X from Transpose[X]*A*X=B
4
votes
1answer
63 views

Using preconditioners efficiently

I am trying to numerically solve a linear system of equations of the form A x = a where A is really ill-conditioned and ...
1
vote
0answers
62 views

Why did LinearSolve give me two different results?

Given that I have a sparse array as follows: ...
2
votes
1answer
45 views

Inverse of matrix up to some order

Let $A(t,s)$ be a matrix of any size (potentially large), whose entries are polynomials functions wrt $(t,s)$ of order $N$. I would like to compute the inverse $X$ of $A$ up to the order $N$ that is $...
1
vote
1answer
88 views

Solving for a system of unknowns with Mathematica

I have the following code to solve a system of 3 equations for 3 unknowns: ...
6
votes
4answers
356 views

How can I generate random matrices with certain requirements for the entries?

I would like to generate random 9x9 matrices, which contain only the digits 1-9, each one appearing exactly ...
5
votes
1answer
72 views

Linear Algebra in Arbitrary Precision - SLOW

I am trying to implement an arbitrary precision algorithm, but I am not very familiar with Mathematica or arbitrary precision arithmetic. I was able to implement it but surprised by how much slower it ...
1
vote
0answers
23 views

Returning only part of a list after a function call to save memory [closed]

I need to get only V of a singular value decomposition of a matrix. In MATLAB I could write: ...
1
vote
0answers
29 views

Matrix rank triangular matrix [closed]

Does MatrixRank check whether a matrix is triangular? If not, what would be the best way to calculate a matrix rank of a (say upper)triangular matrix in the ...
1
vote
1answer
40 views

Is it posibble to insert/add an array (row or colums) in a matrix?

Assume we have an m by n a non-square matrix. My question is this, is it possible/allowed to insert an arbitrary array ( either row or column) in such matrix so that I can obtain a square matrix? Is ...
0
votes
0answers
17 views

Symbolically invert block matrix [duplicate]

In Mathematica, if I write something like: Inverse[{{a, b}, {c, d}}] I get the inverse: ...
-2
votes
1answer
48 views

Setting initial values in MMA's Gram-Schmidt process

How do you setup initial values in MMA's Gram-Schmidt process. Take this example: ...
11
votes
1answer
124 views

Minimizing expression over symmetric matrices

I'm trying to solve the following maximization problem over space of symmetric matrices A and positive definite H $$R=\max_{A\in S(R^d)}\frac{\text{tr}(HA)^2+2\text{tr}(HAHA)}{\text{tr}(AHA)}$$ So ...
0
votes
1answer
84 views

Verifying: How to express a given matrix as the outer product of two vectors? [closed]

The question posed here and here is: Is it possible to decompose a matrix $M_{m\times n}$ as the product of two vectors, i.e. $$M_{m\times n} = \vec{y}_{m\times 1}\times\vec{x}_{1\times n}+const.$$ ...
1
vote
1answer
70 views

Problem with QRDecomposition [closed]

I was using Mathematica for the QR decomposition method. But I got strange results. I wanted to find eigenvalues of a matrix, say ...
3
votes
1answer
119 views

Gaussian elimination for a Hilbert matrix

I have been asked to write the Mathematica code to solve a 25x25 Hilbert matrix. The built-in function LinearSolve would not work. I started my solution by coding ...
2
votes
2answers
98 views

Different result from utilizing of eigenvalues and eigenvectors commands

I have a matrix as a function of a parameter like ...
2
votes
1answer
69 views

How to speed up this code(Jordan Normal Form)

I want to calculate the number of unrepeated Jordan canonical forms of n * n matrices consisting of 0 and 1 How to speed up this code ...
5
votes
2answers
95 views

Efficient way of averaging over elements of one matrix based on another

Mathematical formulation of the problem with an example: Suppose we have the matrix $A$ given by $$A=\begin{pmatrix} 0 & 1 & 5\\ 1 & 0 & 5\\ 5 & 5 & 0 \end{pmatrix},$$...
1
vote
1answer
54 views

Hermite normal form and basis for the nullspace

Define the Hermite Normal form $H$ for a matrix $A\in Z^{n\times n}$ as following: $$H=UA$$ which in Mathematica is given as {u, h} = HermiteDecomposition[a] Then for a system of homogeneous ...
2
votes
1answer
78 views

Fastest way to compute determinants over (lists of) machine precision numbers

The below code is a code snippet of a larger project of mine. The project is mostly optimised but this part is not. I'm struggling to improve it, the code takes a really long time to evaluate for what ...
5
votes
2answers
235 views

How do I get actual values from a Jacobian matrix?

I have a Jacobian function: D[{Sqrt[x^2 + y^2], ArcTan[x, y]}, {{x, y}}] It gives me a matrix with the formulas I need for my transposition matrix: ...
0
votes
0answers
35 views

Is there a feasible computation?

I have to find the values of $p_1$ and $p_2$ which minimizes the expression $G$. However, when I took the partial differentiation of $G$ with respect to $p_1$ and $p_2$, the equations I obtained were ...
2
votes
1answer
68 views

Linear map of unit cube (generalized)

This question is a slight generalization of this question. Let M be a fixed rational m $\times$ ...
1
vote
1answer
57 views

Linear map of unit cube

Let c be a vector of n constants and X = Table[Symbol["x" <> ToString[i]], {i, n}] be ...
8
votes
4answers
311 views

Simplify makes Mathematica forget that a matrix is Hermitian

Using Simplify with certain trivial assumptions makes Mathematica forget that a given matrix is Hermitian. See the minimal example below: ...
3
votes
1answer
45 views

Evaluating Toeplitz determinant [closed]

How can one evaluate $-\text{log}~ \text{Det}(I_{i-j}(x))$ where $x>200$ and $I_{\nu}(x)$ is the modified Bessel function of first kind and $i,j = 1 \cdots 100$ and the determinant is take of the ...
3
votes
1answer
86 views

Efficiently computing current flow betweenness centrality for graphs

Definitions: Given a graph $G=(V,E),$ the current flow betweenness is a node-wise measure that captures the fraction of current through a given node with a unit source (s) sink (t) supply $b_{st}$ (1 ...
0
votes
1answer
53 views

How do I split up a list of data points into invervals and assign values to those intervals?

So I have a data set for chess and our goal is to plot the difference between the rating difference versus white's win rate. I want to subdivide the x-axis into intervals like (-10, 0) (10,20) (20,30)...
1
vote
2answers
162 views

Finding specific eigenvalues

Given an $n\times n$ matrix $Q$ (with e.g. $n\approx10^4$) I am only interested in the 3rd smallest eigenvalue of $Q,$ and not the entire spectrum (assume all eigenvalues are real, e.g. a Hermitian ...
1
vote
1answer
70 views

Parabolic Mirror - proving focal length

I would like to prove that there is a focal length in the parabolic mirror. I wrote script, but it's not working, can you guys see what I did wrong? ...
1
vote
0answers
33 views

Need help with understanding a question concerning the power iteration method [closed]

I just need help understanding a question. I was given the question Use the power iteration method to estimate the spectral radius for (I - B A) given a tridiagonal coefficient matrix. Although,...
7
votes
2answers
215 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 ...

1 2 3 4 5 22