From: HengTong DING on 28 Oct 2009 15:13 I am new to Matlab and trying to do SVD with it. The precision of the SVD turns out to be very bad, maybe I did something naively wrong ... please help I have two small matrix W(31x31) and K(31x50). W is decomposed to Uw*sw*Vw' The conditioning number of W is 2.052816436458144e+13 and the difference of product Uw*sw*Vw' between W: norm(Uw*sw*Vw' - W) is quite large(1.087272583186032e+07)! For the matrix K the conditioning number is 7.342875993013515e+18 and the norm(Uk*sk*Vk' - K) is 2.579083335045855e-15 , which is sort of acceptable. During the calculation, I used "format long e" and my matlab version is 7.8.0(R2009a). I googled the topic related, it seems there exists a package called LAPACK in matlab which can provide higher precision. It has a routine called dgesvd. Does the routine SVD I used in matlab automatically call dgesvd from LAPACK ? I checked in my matlab installation there exists "libmwlapack.so" in /usr/local/matlab/R2009a/bin/glnxa64. But when I type dgesvd in the commandline, it complains "Undefined function or variable 'dgesvd' ". Any suggestions ? >> cond(W) ans = 2.052816436458144e+13 >> [Uw,sw,Vw]=svd(W) ; >> norm(Uw*sw*Vw' - W) ans = 1.087272583186032e+07 >> cond(K) ans = 7.342875993013515e+18 >> [Uk,sk,Vk]=svd(K) ; >> norm(Uk*sk*Vk' - K) ans = 2.579083335045855e-15
From: dpb on 28 Oct 2009 15:42 HengTong DING wrote: > I am new to Matlab and trying to do SVD with it. The precision of the > SVD turns out to be very bad, maybe I did something naively wrong ... > > I have two small matrix W(31x31) and K(31x50). W is decomposed to Uw*sw*Vw' > The conditioning number of W is 2.052816436458144e+13 and the > difference of product Uw*sw*Vw' between W: norm(Uw*sw*Vw' - W) is quite > large(1.087272583186032e+07)! > For the matrix K the conditioning number is 7.342875993013515e+18 > and the norm(Uk*sk*Vk' - K) is 2.579083335045855e-15 , which is sort of acceptable. > > During the calculation, I used "format long e" and my matlab version is 7.8.0(R2009a). > I googled the topic related, it seems there exists a package called > LAPACK in matlab which can provide higher precision. It has a routine > called dgesvd. Does the routine SVD I used in matlab automatically call > dgesvd from LAPACK ? ... The display format has nothing whatsoever to do with internal precision, only on the number of significant digits and format of the results in the command window. Matlab uses double precision by default for all computations and internal storage. This will provide roughly 15 decimal digits of precision. The condition number and resulting computations is dependent on the matrix itself; apparently the W mal-conditioning is more detrimental owing to its particular form than is that of the K matrix. --
From: Bruno Luong on 28 Oct 2009 16:07 "HengTong DING" <hengtong.ding(a)physik.uni-bielefeld.de> wrote in message <hca53u$k2c$1(a)fred.mathworks.com>... > > I have two small matrix W(31x31) and K(31x50). W is decomposed to Uw*sw*Vw' > The conditioning number of W is 2.052816436458144e+13 and the difference of product Uw*sw*Vw' between W: norm(Uw*sw*Vw' - W) is quite large(1.087272583186032e+07)! Why it's large? > For the matrix K the conditioning number is 7.342875993013515e+18 > and the norm(Uk*sk*Vk' - K) is 2.579083335045855e-15 , which is sort of acceptable. Why it's acceptable? You seem to mix everything. 1. Condition number has nothing to do with error in computing SVD. 2. Absolute error norms alone are meaningless. >> A=[1 2; 3 4]*1e100 A = 1.0e+100 * 1.0000 2.0000 3.0000 4.0000 >> cond(A) ans = 14.9330 >> [U S V]=svd(A); >> norm(A-U*S*V') ans = 9.2434e+084 >> A=[1 2; 1+eps 2]*1e-100 A = 1.0e-099 * 0.1000 0.2000 0.1000 0.2000 >> cond(A) ans = 1.3931e+016 >> [U S V]=svd(A); >> norm(A-U*S*V') ans = 8.0674e-116 I let you think about it. Bruno
From: HengTong DING on 28 Oct 2009 16:16 > The display format has nothing whatsoever to do with internal precision, > only on the number of significant digits and format of the results in > the command window. > > Matlab uses double precision by default for all computations and > internal storage. This will provide roughly 15 decimal digits of precision. > > The condition number and resulting computations is dependent on the > matrix itself; apparently the W mal-conditioning is more detrimental > owing to its particular form than is that of the K matrix. > Thanks for your correcting my misunderstanding of "format long e" in matlab. Both W and K's conditioning number are much larger than 1, and K is more ill-conditioned than W, but how come K is better decomposed ? Another thing about this symmetric matrix W is its entries are very big(order of 10^10) and >> det(W) ans = Inf I tried with matrix K'*W*K, which should be in principle symmetric(W is symmetric), e.g. >> size(W) ans = 31 31 >> norm(W - W') ans = 0 >> norm(K'*W*K - (K'*W*K)') ans = 1.828107974111172e+02 Any ideas ?
From: HengTong DING on 28 Oct 2009 16:29 "Bruno Luong" <b.luong(a)fogale.findmycountry> wrote in message <hca897$927$1(a)fred.mathworks.com>... Hi Bruno, > You seem to mix everything. Probably you are right! Thanks a lot for your message! > 1. Condition number has nothing to do with error in computing SVD. > 2. Absolute error norms alone are meaningless. > Your examples support your two remarks quit well. But I got more confused. It seems that the SVD depends a lot on the values of the matrix entries. So the good way to make more precision SVD is to somehow reduce the values of the matrix entries? But the question still exists: how could we test whether this SVD works well ?
|
Next
|
Last
Pages: 1 2 3 Prev: Regarding SPL Spectra using Matlab Next: MATLAB Out-of-core Solution |