Re: Round-off error?



Thank you Roger for your reply. I'm trying to use Matlab to solve
for the eigenvectors corresponding to the 0 eigenvalue of a matrix.
That is, I'm trying to see what the null space looks like.

The matrix entries are computed by hand and they are exact. So I
enter the matrix by hand and then use the "eig" function to get the
eigenvalues and the eigenvectors.

Sometimes the matrix functions (e.g. det, eig...) return "wrong"
values. For example, I can compute a small 2x2 example by hand to
see that the matrix is singular, but Matlab tells me the det() is
non-zero. I have to deal with large square matrices (n>5) so
computing everything by hand is not something I want to do. The best
thing I can think of is to do a roundn() after the 10-th decimal
place.

How does one make these types of matrix operations robust?

Thanks.

Roger Stafford wrote:


In article <ef34e7b.-1@xxxxxxxxxxxxxxxx>, Nivek
<cuforward@xxxxxxxxxxx> wrote:

I tried to compute the following in Matlab

1+1+0.55+0.55-3.1

and I got that the answer is -4.4409e-016. Now if I compute

0.55+0.55+1+1-3.1

then the answer is 0. Is this problem due to round-off? I know
this
1e-16 is a very small number and I can "fix" this problem by
using
roundn() but is there a better way?

There's got to be a better way than to use roundn() everywhere
to
prevent numerical problems.

Any help is greatly appreciated.

thanks.
--------------------------
Yes, that is roundoff error. Such errors are inevitable in any
numerical procedure capable of using only a finite number of
digits. You
wouldn't expect your decimal calculator to get the exact answer to
1/3.
Similarly, matlab, using binary floating point numbers, cannot
express
either 0.55 or 3.1 exactly, and it should be expected that after a
series
of necessarily rounded intermediate values, your final answer is
also not
exact.

Doctoring up intermediate values with some kind of rounding is
ordinarily not a good practice. Your computations should be of
such a
nature as to tolerate a certain amount of roundoff error.

(Remove "xyzzy" and ".invalid" to send me email.)
Roger Stafford

.



Relevant Pages

  • Re: Round-off error?
    ... for the eigenvectors corresponding to the 0 eigenvalue of a matrix. ... The matrix entries are computed by hand and they are exact. ... In Matlab, one function that may be of help is 'eps'. ... nature as to tolerate a certain amount of roundoff error. ...
    (comp.soft-sys.matlab)
  • Re: normalised mode shapes
    ... I don't know about the syntax in Matlab, but you won't get the eigenvalues by dividing K by M, this operation is only defined for scalars.... ... The eigenvectors you can,,normalize" to some quantity, these eigenvectors represent our mode shapes. ...
    (sci.engr.analysis)
  • Re: Feature Extraction for EMG data using PCA
    ... Matlab without any extra toolboxes. ... Keep the minimum number of eigenvectors that will ... what should i use for training theneuralnetwork (projected data or principal components) ?? ... % Then use EIGS to caclculate exactly r ...
    (comp.soft-sys.matlab)
  • Re: svd in two ways not equal..
    ... On May 25, 5:16 pm, "Roger Stafford" ... in two ways in matlab but I am not getting the same result. ... definition S is the matrix that is made up of eigenvectors of A * A', ... I think the problem stems from the fact that svd of a matrix is ...
    (comp.soft-sys.matlab)
  • Re: Left eigen vectors
    ... > for my problem,Can i got left eigen vector from that without solving ... Hello Amandeep, ... the columns of V are right eigenvectors of A and the diagonal D has the ... Roger Stafford ...
    (comp.soft-sys.matlab)

Loading