# Tag Info

17

The comments by both Michael E2 and J. M. ♦ are already an excellent answer, so this is just my attempt at summarizing. Undocumented means just what it says: there need not be any reference pages or usage messages, or any other kind of documentation. There are many undocumented functions and if you follow MSE regularly, you will encounter them often. Using ...

17

LinearSolve[] actually computes a permuted Cholesky decomposition; that is, it performs the decomposition $\mathbf P^\top\mathbf A\mathbf P=\mathbf G^\top\mathbf G$. To extract $\mathbf P$ and $\mathbf G$, we need to use some undocumented properties. Here's a demo: mat = SparseArray[{Band[{2, 1}] -> -1., Band[{1, 1}] -> 2., Band[{1, ...

9

It seems like RandomReal[1., 2] is automatically a packed array, whereas {1., 2.} is not. Notice; (Outer[Times, list1, DeveloperToPackedArray@{1., 2.}];) // AbsoluteTiming // First (* 0.032425 *) whereas (Outer[Times, list1, {1., 2.}];) // AbsoluteTiming // First (* 0.542086 *) Also: list1 = DeveloperFromPackedArray@RandomReal[1., 1000000]; ...

8

In this comment, it is noted that LatticeReduce[] is now using the Nguyen-Stehle variant of LLL, so any results you might see from LatticeReduce[] can be different from a "classical" implementation of LLL. Having said this, LatticeReduce[] does take options, but through a not too transparent interface: SetSystemOptions["LatticeReduceOptions" -> ...

7

You are new, and this is a difficult problem you have been working on. So I'll try to point out some ways to make things easier. (1) Try to make the code as simple as possible. Little things help. I'll show a few in a moment. (2) Don't use things like n for matrices. (3) Don't use upper cases things that look like built-in functions, for example Rules, as ...

6

How should I know the correct order of arguments without trying several times? You can't, usually. A lot of the undocumented usage that you see on this site will have been worked out by trial and error. Sometimes it is fruitless - I have explored plenty of interesting-sounding internal functions and got nowhere. Are there detailed usage information of ...

6

Quick fix: Plot[Sort@m2[x], {x, -1, 1}]

6

For normal matrices: Find the unitary matrices $P$ and $S$ that diagonalize $\tilde{B}$ and $B$. $D=P^{-1}\tilde{B}P\\ D'=S^{-1}BS\\ \tilde{B}=PS^{-1}BSP^{-1}\\ => U=PS^{-1}$ B1 = {{2, 1}, {-1, -1}}; B2 = {{-2, 5}, {-1, 3}}; P = Transpose@Eigenvectors@B1; S = Transpose@Eigenvectors@B2; U = P.Inverse@S; B1 == Simplify[U.B2.Inverse@U] True

5

Before using MatrixRank remove columns/rows consisting of zeros only. Also, when a row/column contains precisely 1 non-zero element, delete the corresponding column/row that contains the non-zero element and count one rank. mat = D[Union@Flatten@CoefficientList[f,{z0,z1,z2}], {coefficients}] rank[m_] := Module[{rank = 0, mat = m, c1, c2}, ...

3

I'm kicking myself for not thinking of ybeltukov's answer, but here's mine. It's another (less efficient) way of sorting, but this has the advantage of preserving colorings. pts = Table[m2[x], {x, -1., 1, 1/32.}]; Do[ pts[[i]] = MinimalBy[ Permutations[pts[[i]]], Norm[Abs[pts[[i - 1]] - #]] & ][[1]], {i, 2, Length[pts]} ]; ...

3

Let me first start with a cleaned up version of your evol2: Clear@evol3 evol3[mat_, initial_, ti_, tf_] := Module[{dt = (tf - ti)/10, res = col[initial]}, Do[res = MatrixExp[-I*mat, res], {t, ti, tf, dt}]; squ[res]]; Note that you don't need the complicated way to substitute numerical values for t, as Do uses Block internally which does this for ...

3

Perhaps SolveAlways is what you want. It shows that there is no linear combination of the w's that yields the particular linear combination of the a's, assuming they're independent: Block[{w1 = a1 + a2, w2 = a2 + a3, w3 = a3 + a4, w4 = a4 + a5}, SolveAlways[ a*w1 + b*w2 + c*w3 + d*w4 == a1 + a2 + a3 - a4 - a5, {a1, a2, a3, a4, a5}] ] (* {} *) But ...

2

The problem resides in the fact that I was minimizing over a matrix not a number. This can be done, however, over the sum of the total matrix elements, by using the line: FinalFunct[a1_, a2_, a3_, b1_, b2_, b3_, c1_, c2_, c3_] := Sum[StateDifference[a1, a2, a3, b1, b2, b3, c1, c2,c3][[k]][[k]], {k, 1, Length[StateDifference[a1, a2, a3, b1, b2, b3, c1, c2, ...

2

I'm not sure whether this works on more complex situations, but if you just define it as a function, it appears to give what you are looking for: m[x_] := Eigenvalues[M] Plot[m[x], {x, -1, 1}]

2

The question is not clear. However, I will state the assumptions and try to answer. Assumption: Kinv is the inverse of the matrix K When you refer to KK you meant the matrix K Answer: The matrix K is of dimension 12X12, which can be checked using Dimensions[K]. The inverse of the matrix will also be of dimension 12X12. While taking the dot product, ...

2

Not sure about what you want, but perhaps: f[v_] := v Sign[v[[-1]]]/GCD @@ v v0 = {-2, 2, 4, 6, 2, 2}; f@v0 (* {-1, 1, 2, 3, 1, 1} *)

1

If I had interpreted you correctly, here's my attempt to do the figures here: n = 269; k = 10; mat = RandomVariate[GaussianUnitaryMatrixDistribution[n]]; eig = Sort[Eigenvalues[mat], LessEqual]; {p, q} = MinMax[eig]; h = (q - p)/k; bins = BinLists[eig, {p, q, h}]; zer = Im[N[ZetaZero[Range[n]]]]; {zp, zq} = MinMax[zer]; zh = (zq - zp)/k; zbins = ...

1

Say you have two vectors (I'll just make length-5 for demonstration) concatenated into a matrix a. a = RandomInteger[{0, 10}, {5, 2}]; m = NullSpace[Transpose[a]]; {MatrixForm[m], MatrixForm[a]} The Matrix m contains rows that are orthogonal to the two vectors, as you can see since m.a is the zero matrix. Hence m is a matrix whose null space is ...

1

After Reading anderstoods Comment on the Original Post I realized that I had actually constructed the projector on the space orthogonal to the span of the vectors. This led me to the simpler version. Again, if you know that your vectors are linearly independent, you don't have to kick out the vectors. But I like orthogonalizing first. v = ...

1

Let me at least show you how to avoid the Do loop while I think about other possible improvements. The idiomatic way is to use Fold. Here is my version: evol3[mat_, initial_, ti_, tf_] := Module[{dt = (tf - ti)/10, res = col[initial], ar = ArrayRules[mat]}, squ[Fold[ MatrixExp[-I*SparseArray[ar /. t -> #2, Dimensions[mat]], #1] &, ...

1

The eigenvectors space of a normal matrix are orthogonal. So in this case you can use Orthogonalize to get a set of orthogonal eigenvectors. H = {{1, 1 + I}, {1 - I, 1}}; {Lambda, SA} = Eigensystem[H] UA = Orthogonalize[SA] UAT = Transpose[UA]; DiagonalMatrix[Lambda] == ConjugateTranspose[UAT].H.UAT

Only top voted, non community-wiki answers of a minimum length are eligible