Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

I have a simple 4x10 matrix of real integers (It's a Vandermonde matrix for x=1,2,...,10, if that's relevant) that I'm trying to do SVU decomposition on. When I use the SingularValueDecomposition command, the result is a huge mess of roots:

Code:

A = {{1, 1, 1, 1}, {1, 2, 4, 8}, {1, 3, 9, 27}, {1, 4, 16, 64}, {1, 5,
     25, 125}, {1, 6, 36, 216}, {1, 7, 49, 343}, {1, 8, 64, 512}, {1, 
    9, 81, 729}, {1, 10, 100, 1000}};
{U, S, V} = SingularValueDecomposition[A];
Print[U]
Print[S]

Output snippet:

{{(1-(12231648+1703130 Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]-7 Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]^2)/(11 (61776+14238 Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]+5 Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]^2))-(-64555920+589248 Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]-Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]^2)/(11 (61776+14238 Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]+5 Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]^2))-(5067979488-1475780856 Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]+2004123 Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]^2-Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]^3)/(605 (61776+14238 Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]+5 Root[1345481280-8036854848 #1+1486520211 #1^2-2004133 #1^3+#1^4&,4]^2)))/(\[Sqrt]((1000-(100 (12231648+1703130 Root[1345481280-8036854848 #1+

And so on, and so on...

How can I force it to evaluate these roots?

share|improve this question

closed as off-topic by Oleksandr R., Öskå, RunnyKine, Michael E2, m_goldberg Sep 28 at 22:02

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Oleksandr R., Öskå, RunnyKine, Michael E2, m_goldberg
If this question can be reworded to fit the rules in the help center, please edit the question.

2  
Do this A={{...},...}//N and then you can the numerical values. –  Junho Lee Sep 28 at 16:40

3 Answers 3

up vote 1 down vote accepted

Just do this.

A = {{1, 1, 1, 1}, {1, 2, 4, 8}, {1, 3, 9, 27}, {1, 4, 16, 64}, {1, 5,
      25, 125}, {1, 6, 36, 216}, {1, 7, 49, 343}, {1, 8, 64, 512}, {1,
      9, 81, 729}, {1, 10, 100, 1000}} // N;
{U, S, V} = SingularValueDecomposition[A];
U // MatrixForm
S // MatrixForm

You can confirm the results.

U.S.Conjugate[Transpose[V]] // Rationalize

{{1, 1, 1, 1}, {1, 2, 4, 8}, {1, 3, 9, 27}, {1, 4, 16, 64}, {1, 5, 25, 125}, {1, 6, 36, 216}, {1, 7, 49, 343}, {1, 8, 64, 512}, {1, 9, 81, 729}, {1, 10, 100, 1000}}

share|improve this answer
    
Yep! That was it. Thank you very much, Junho. I see that I just was forcing the numbers to be numeric at the wrong place. Or at least, that's how I interpret this. –  Frank Harris Sep 28 at 16:54
    
@FrankHarris: "I just was forcing the numbers to be numeric at the wrong place." Yup, you've got it right. If you give SingularValueDecomposition (or many other symbolic methods) integer input, it will give horrifyingly large exact symbolic expressions, which you can apply N to to get numeric results. But if numerical results are what you are after, then it is more efficient and safer to apply N to your initial matrix first, and then apply the SVD. –  DumpsterDoofus Sep 28 at 18:42

This is not a matter of "force". A Root object represents the exact root of a polynomial that cannot be represented exactly in closed form, or (in the case of cubics and quartics) cannot be represented succinctly. It is not "unsolved"; it is just a way of writing something that is hard or impossible to write down otherwise.

If you want to convert cubic or quartic Root objects to radicals, use ToRadicals:

Root[1345481280 - 8036854848 #1 + 1486520211 #1^2 - 2004133 #1^3 + #1^4 &,
  4
 ] // ToRadicals
(* -> 2004133/4 + 
 Sqrt[4012585027793/4 + 21832541169757571/(88409040345503470315691 + 
  (120*I)*Sqrt[176821665157935758420883814538881436163])^(1/3) + 
  11*(88409040345503470315691 +
  (120*I)*Sqrt[176821665157935758420883814538881436163])^(1/3)]/2 + 
 Sqrt[4012585027793/2 - 21832541169757571/(88409040345503470315691 + 
  (120*I)*Sqrt[176821665157935758420883814538881436163])^(1/3) - 
  11*(88409040345503470315691 +
  (120*I)*Sqrt[176821665157935758420883814538881436163])^(1/3) + 
 8037781888187331169/(4*
  Sqrt[4012585027793/4 + 21832541169757571/(88409040345503470315691 +
   (120*I)*Sqrt[176821665157935758420883814538881436163])^(1/3) + 
   11*(88409040345503470315691 +
   (120*I)*Sqrt[176821665157935758420883814538881436163])^(1/3)])]/2 *)

This is easily found in the documentation.

share|improve this answer

Let me reconstruct your Vandermonde matrix:

A = Outer[Power, Range[10], Range[0, 3]];
A // MatrixForm

enter image description here

Then there are two possibilities to compute SVD:

  1. Analytic expressions

  2. Numerical values

Your input is the integer array so Mathematica choose the first one and try to give your the answer in an analytic form. It returns the result as roots of the polynomials. The degree of the polynomials is 4 so you can force to give an explicit result

{U, S, V} = SingularValueDecomposition[A, Quartics -> True];
U

enter image description here

Unfortunately options Quartics -> True and Cubics -> True are not documented for SVD, but they work as in Eigenvalues. But formulas are very huge! I'm not sure that it is what you want.

To choose the numerical computations you should convert your array to the numerical array

{U, S, V} = SingularValueDecomposition[N[A]];
V // MatrixForm

enter image description here

share|improve this answer

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