Re: Round-off error?
- From: Dan Hensley <dan@xxxxxxxxxxxxx>
- Date: Mon, 15 May 2006 22:12:10 -0600
On Mon, 15 May 2006 23:27:02 -0400, Nivek wrote:
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?
This article may help:
http://docs.sun.com/source/806-3568/ncg_goldberg.html
In Matlab, one function that may be of help is 'eps'.
Dan
Thanks.
Roger Stafford wrote:
to
In article <ef34e7b.-1@xxxxxxxxxxxxxxxx>, Nivek
<cuforward@xxxxxxxxxxx> wrote:
I tried to compute the following in Matlabthis
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
1e-16 is a very small number and I can "fix" this problem byusing
roundn() but is there a better way?
There's got to be a better way than to use roundn() everywhere
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
.
- References:
- Round-off error?
- From: Nivek
- Re: Round-off error?
- From: Roger Stafford
- Re: Round-off error?
- From: Nivek
- Round-off error?
- Prev by Date: Plot a contour on the triangular mesh
- Next by Date: Speech encryption/ Audio Encryption
- Previous by thread: Re: Round-off error?
- Next by thread: Re: Round-off error?
- Index(es):
Relevant Pages
|
Loading