1
$\begingroup$

For example, given $\lambda_1 = 1, \lambda_2 = 2, \lambda_3 = 3$, what's the best way to generate all the upper triangular matrix ($3\times 3$) whose singular values are $\lambda_i$?

Note:Given a matrix $A$, if the eigenvalues of $A^HA$ are $\lambda_i \geq 0$, then $\sqrt{\lambda_i}$ are the singular values of $A$. $A^H$ is the conjugate transpose of $A$. Generally, If $B = U A V$ where $U,V$ are all unitary matrix, then $B$ have the same singular values of $A$.

$\endgroup$
0

2 Answers 2

5
$\begingroup$

One can proof that QRDecomposition[m][[2]] returns the upper triangular matrix with the same singular values

e = {1, 2, 3};
n = Length[e];

q := Orthogonalize[RandomReal[NormalDistribution[], {n, n}] + 
    I RandomReal[NormalDistribution[], {n, n}]];

r = QRDecomposition[q.DiagonalMatrix[e].q][[2]];

SingularValueDecomposition[r][[2]] // Diagonal
(* {3., 2., 1.} *)

MatrixForm@Chop[r]

enter image description here

Here q is the generator of the random unitary matrix (note the := sign).

$\endgroup$
8
  • $\begingroup$ Thanks! Generally, If $B = U A V$ where $U,V$ are all unitary matrix, then $B$ have the same singular values of $A$. But here only consider the case q.DiagonalMatrix[e].q. $\endgroup$ Dec 15, 2013 at 2:35
  • $\begingroup$ e*q suffices, because QRDecomposition[eq = e*q][[2]] == QRDecomposition[q.eq][[2]]. $\endgroup$ Dec 15, 2013 at 8:42
  • $\begingroup$ My earlier comment was made too hastily, before actually checking. The two versions of r are not necessarily equal, because r is determined only to within a multiplier of ±1 for each row. The test is And @@ MapThread[#1 == #2 || #1 == -#2 &, {r1, r2}]. $\endgroup$ Dec 15, 2013 at 10:43
  • $\begingroup$ @EdenHarder I think that q.DiagonalMatrix[e].q is the general case. It is equivalent to $UAV$ with the diagonal matrix $A$. Each q is different because I use the delayed set (:=). $\endgroup$
    – ybeltukov
    Dec 15, 2013 at 13:17
  • 2
    $\begingroup$ The QR decompositions of $AV$ and $UAV$ give equivalent $R$ matrices, so $U$ is not necessary. n = Length[e = {1, 2, 3}]; q := Orthogonalize[RandomReal[NormalDistribution[], {n, n}] + I*RandomReal[NormalDistribution[], {n, n}]]; r1 = Last@QRDecomposition[eq = e*q]; r2 = Last@QRDecomposition[q.eq]; And @@ MapThread[#1 == #2 || #1 == -#2 &, {r1, r2}] (* True *) $\endgroup$ Dec 16, 2013 at 0:56
3
$\begingroup$

Not a full answer but perhaps something you can work from. Thinking of a matrix as the action it does on the unit sphere $\{Ax ,\|x\| == 1\}$ which is an ellipsoid centered at 0, as it is the image of a linear transformation. The singular values represent the length of the semiaxes, the only freedom that remains is picking the orthonormal basis representing the direction of the semiaxes. Whatever is picked it should be possible to upper triangularize.

unitSphere[θ_, ϕ_] := {Cos[θ] Sin[ϕ], Sin[θ] Sin[ϕ], Cos[ϕ]};
λ = {1, 2, 3};
Manipulate[
 (* Start with diagonal matrix and rotate the entire thing *)
 m = RotationMatrix[{{0, 0, 1}, unitSphere[θ, ϕ]}].DiagonalMatrix[λ];
 {u, w, v} = SingularValueDecomposition[m];

 Show[
  ParametricPlot3D[
   m.unitSphere[a, b], {a, 0, 2 Pi}, {b, 0, Pi}, PlotStyle -> Opacity[0.3], Mesh -> None],
  Graphics3D[{Arrow[{{0, 0, 0}, #}] & /@ Transpose[u.w]}],
  PlotRange -> {{-3, 3}, {-3, 3}, {-3, 3}},
  PlotLabel -> Diagonal[w]
  ],
 {θ, 0, 2 Pi}, {ϕ, 0, Pi}]

rotating

$\endgroup$
1
  • $\begingroup$ Thanks! I also want to reduce the variables. $\endgroup$ Dec 15, 2013 at 3:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.