I'm trying to make my matrix diagonal. this is my matrix (for matlab and octave)

ab = [2305.90543896547,-1.84172677109018E-11,0,7.27595761418343E-12,-3458.85815844816,1503.85397120216;-3.2287061912939E-11,2305.90543896546,0,3458.85815844817,-3.18323145620525E-12,-1503.85397120214;-1152.8022645461,-1152.8022645461,1189103.95844129,-1845.58277496696,1845.58277496509,4.54747350886464E-13;1.57556722431824E-13,384.267421515366,-7.03336746482597E-11,1189719.15269961,-2.76805747637657E-10,1152.8022645461;-384.267421515366,5.25189074772746E-14,2.3283064365387E-10,6.98491930961609E-10,1189719.15269961,1152.8022645461;1.13118403533008E-11,-7.61701812734827E-12,0,2.27373675443232E-13,3.41060513164848E-13,2807.19009603281;]

but the problem is when i pre multiply it by transpose of eigenvectors and postmultyply it by its eigenvectors, result is not a diagonal matrix! this is the whole code you can put in matlab or octave online

dab = transpose(eigvector)*ab*eigvector;

in above code the dab matrix should be diagonal, but it is not!

enter image description here

and these are eigenvalues: 1.1897e+06, 2.8072e+03, 2.3048e+03, 2.3048e+03, 1.1897e+06, 1.1891e+06

I'm thinking problem is with digital calculations in computer, because some eigenvalues are close or equal to each other and others are far more or less...

  • $\begingroup$ Check that the matrix of eigenvectors $V$ is orthonormal, in the above case Octave gives $\| V^T V -I \| > 1.56$. $\endgroup$ – copper.hat Jun 19 '15 at 18:54

The matrix $ab$ you are carrying out an eigendecomposition on is not symmetric, so the only way you will recover the diagonal matrix is if you did the following

  dab = inv(eigvector)*ab*eigvector; 

so long as the matrix is diagonalisable, provided all its eigenvalues are distinct.

For the matrix ($ab$) in question, the number of distinct eigenvalues is $5$, with there being two repeated eigenvalues (highlighted in red below):- $$ 1189720.27,2807.19,\color{red}{2304.79,2304.79},1189720.27,1189103.96$$ so it may or may not be possible to diagonalise $ab$ - this is quite an involved process, and looking here could help.

Note: If $ab$ was symmetric, then its eigenvectors would be orthogonal so your original operation would have resulted in a diagonal matrix (the off-diagonal terms would be non-zero, but orders of magnitude smaller than the diagonal elements)

  • $\begingroup$ I'm using octave online, all off diagonal elements are almost zero except one which is -9.5253e+02 $\endgroup$ – epsi1on Jun 20 '15 at 10:53
  • $\begingroup$ i use your code (inv(eigvector)*ab*eigvector) but still get one off diagonal large non zero value $\endgroup$ – epsi1on Jun 21 '15 at 11:37
  • $\begingroup$ @epsi1on Yes, indeed this is the case. Please see the edits to my answer. $\endgroup$ – Alijah Ahmed Jun 21 '15 at 16:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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