New answers tagged linear-algebra
1
Im trying to find the eigenvectors of an 11*11 matrix but can't get it to recognise my data [closed]
mydata={{1,2},{3,7}};
Eigenvectors[mydata]
{{-(7/3) + 1/3 (4 + Sqrt[15]), 1}, {-(7/3) + 1/3 (4 - Sqrt[15]), 1}}
5
Taking a page from kptnw's fine answer, here's one possibility:
Cross[Unevaluated /@ PauliMatrix[Range[3]], Range[3]]
3
Another idea to shorten the notation for the cross product in the special case where you have a Pauli matrix vector as the first argument is this:
ClearAll[OverVector];
OverVector /: Cross[OverVector[σ], x_?VectorQ] :=
x.LeviCivitaTensor[3].PauliMatrix[Range[3]]
Cross[OverVector[σ], {x, y, z}]
(*
==> {{{-y, -I z}, {I z, y}}, {{x, -z}, {-z, -x}}, {{0, ...
9
As $P$ is explicitly constructed from eigenvectors of a self-adjoint matrix, it is unitary, i.e $P P^\dagger = I\qquad$ where the $\dagger$ is the conjugate transpose (or Hermitian conjugate, if you prefer). So, calculating the inverse is simply ConjugateTranspose[P] which is much faster than calculating it using Inverse. That said, you have to ensure that ...
6
The idea behind the Jordan normal form does the trick, even though JordanDecomposition does not. (Incidentally, this suggests there may be a more reliable, stable algorithm to obtain Jordan decompositions than is implemented in Mathematica...) The resulting solution is very short, efficient, and numerically stable when applied to floating-point matrices. ...
2
Here is the bad type of example mentioned in comments by @whuber.
SeedRandom[1111];
n = 3; p =
SparseArray[{Band[{1, 1}] -> 0, Band[{1, 2}] -> 1}, {n, n}]; q =
Rationalize[RandomReal[{0, 1}, {n, n}], 10^-3]; a = Inverse[q].p.q;
na = N[a];
Badiosity check:
MatrixRank[MatrixPower[na, #]] & /@ Range[Length@na]
(* Out[318]= {2, 1, 3} *)
To ...
2
Augmenting the matrix with the identity matrix keeps track of the row reduction. Thus, row-reduce just the first three columns of the matrix and use the augmentation to row-reduce the original matrix in the same way:
(a = RandomInteger[{-5, 5}, {5, 4}]) // MatrixForm
$$\left(
\begin{array}{cccc}
-4 & 0 & -4 & -2 \\
-2 & -3 & 1 ...
2
I believe this is correct but I'm running out of time to check it or develop it further. I believe Szabolcs intented to write != where he wrote ==, but there is still the matter from starting with power zero.
Update #3:
f1 = {#, MatrixRank@#} &;
f2[m_][{_, {a2_, r2_}, n_}] := {{a2, r2}, f1[m.a2], n + 1}
f3[m_] := NestWhile[f2[m], {{-1, -1}, f1 @ ...
3
Try this:
Length@NestWhileList[A.# &, A, MatrixRank[#] != MatrixRank[#2] &, 2] - 1
This'll keep multiplying $A$ together and checking the matrix rank at each step.
8
64 bit Mathematica does not have any practical limits on this. What limits you is the speed of your computer and the available memory. A $k\times k$ matrix will take a bit more than $8\times k^2 / 1024^3$ gigabytes of memory, so you see that a $10^6 \times 10^6$ matrix needs ~7500 GB of memory to store. You probably don't have that much in your computer.
...
3
I'd like to consider this problem from geometric view.
Suppose your original matrix is $m=(r_1,r_2,r_3)^\text{T}$, where $r_i$ are row vectors:
mm = {{x, x z, w - 2 x}, {w z^3, x y, z}, {y^2 - z^3, w + x, x^5 + z}};
So,
The condition for $\text{rank}(m)=1$
The rank-1 condition should be $r_i\times r_j=0 \land r_j\times r_k=0 \land r_k\times r_i=0 $:
...
4
I'm not sure how useful it will be (because there are lots of possibilities), but one way to attack this problem is to observe that M loses rank exactly when the determinant goes to zero. So you can use Solve to investigate. With
M[x_, y_, z_, w_]:={{x, x z, w - 2 x}, {w z^3, x y, z}, {y^2 - z^3, x + w, z + x^5}};
you can try
Solve[Det[M[x, y, z, w]] == ...
2
M[x_,y_,z_,w_]:={{x,x z,w-2x},{w z^3,x y,z},{y^2-z^3,x+w,z+x^5}}
MR[x_, y_, z_, w_]:=MatrixRank[M[x,y,z,w]]
For example
MR[1,2,3,4]
1
Possibly what you want is the "U" part of an LU factorization. I'll illustrate using the same example as in another response. The code is pretty much straight out of the documentation for LUDecomposition.
m = {{1, 2, 3, 1, 0, 0}, {4, 5, 6, 0, 1, 0}, {7, 8, 9, 0, 0, 1}};
{lu, perm, cond} = LUDecomposition[m]
(* Out[227]= {{{1, 2, 3, 1, 0, 0}, {4, -3, -6, ...
0
I learned from this thread that you can use HermiteDecomposition. For example:
m = {{1, 2, 3, 1, 0, 0}, {4, 5, 6, 0, 1, 0}, {7, 8, 9, 0, 0, 1}};
{u,r}=HermiteDecomposition[m];
r//MatrixForm
MatrixForm/@{RowReduce[r],RowReduce[m]}
(Please see comments for more details about what r really is, turns out it's not necessarily the upper triangular)
Top 50 recent answers are included

