Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
Eigenvalues and Matlab

Subject: Eigenvalues and Matlab

From: Mark Roman

Date: 19 Apr, 2010 23:40:23

Message: 1 of 5

Hey All

I've been assigned some work to do by hand and by matlab. I figure matlab is performing the calculations correctly, but I can't seem to produce the output I would expect. As a disclaimer, I typically only use matlab in coursework, so I'm not proficient.

I'm working with the matrix
A=[1i,1;1,-1i]

and I'm looking for the eigenvalues.

I would expect the only value to be 0.

Matlab produces...

lambda=eig(A)

lambda =

   1.0e-15 *

   0.0647 + 0.0079i
  -0.3174 - 0.1406i


It would be a great help if someone could explain why I'm reaching this result.

Thanks!

Mark

Subject: Eigenvalues and Matlab

From: Roger Stafford

Date: 20 Apr, 2010 00:08:03

Message: 2 of 5

"Mark Roman" <user@gmail.com> wrote in message <hqipl7$k82$1@fred.mathworks.com>...
> Hey All
>
> I've been assigned some work to do by hand and by matlab. I figure matlab is performing the calculations correctly, but I can't seem to produce the output I would expect. As a disclaimer, I typically only use matlab in coursework, so I'm not proficient.
>
> I'm working with the matrix
> A=[1i,1;1,-1i]
>
> and I'm looking for the eigenvalues.
>
> I would expect the only value to be 0.
>
> Matlab produces...
>
> lambda=eig(A)
>
> lambda =
>
> 1.0e-15 *
>
> 0.0647 + 0.0079i
> -0.3174 - 0.1406i
>
>
> It would be a great help if someone could explain why I'm reaching this result.
>
> Thanks!
>
> Mark

  There's nothing wrong with your work by hand. The precise values of those eigenvalues are both zero. However, you are witnessing the effects of round off error here with the output of 'eig'. Note the size of those eigenvalue results. They are down in the range of single bit errors in the least bit position of the original values in A. This is something you will have to become accustomed to in numerical computation by machines with only a finite number of bits of accuracy - in this case 53.

Roger Stafford

Subject: Eigenvalues and Matlab

From: Mark Shore

Date: 20 Apr, 2010 00:19:04

Message: 3 of 5

"Mark Roman" <user@gmail.com> wrote in message <hqipl7$k82$1@fred.mathworks.com>...
> Hey All
>
> I've been assigned some work to do by hand and by matlab. I figure matlab is performing the calculations correctly, but I can't seem to produce the output I would expect. As a disclaimer, I typically only use matlab in coursework, so I'm not proficient.
>
> I'm working with the matrix
> A=[1i,1;1,-1i]
>
> and I'm looking for the eigenvalues.
>
> I would expect the only value to be 0.
>
> Matlab produces...
>
> lambda=eig(A)
>
> lambda =
>
> 1.0e-15 *
>
> 0.0647 + 0.0079i
> -0.3174 - 0.1406i
>
>
> It would be a great help if someone could explain why I'm reaching this result.
>
> Thanks!
>
> Mark

Note the factor of 1.0e-15 (1.0 x 10^-15) preceding the pair of complex numbers. MATLAB has done the calculation in double precision floating point numbers and this is as close as it got to 0.

Enter >>help eps or >>doc eps from the command line for more detail.

Subject: Eigenvalues and Matlab

From: Mark Roman

Date: 20 Apr, 2010 00:22:05

Message: 4 of 5

"Roger Stafford" <ellieandrogerxyzzy@mindspring.com.invalid> wrote in message <hqir93$gru$1@fred.mathworks.com>...
> "Mark Roman" <user@gmail.com> wrote in message <hqipl7$k82$1@fred.mathworks.com>...
> > Hey All
> >
> > I've been assigned some work to do by hand and by matlab. I figure matlab is performing the calculations correctly, but I can't seem to produce the output I would expect. As a disclaimer, I typically only use matlab in coursework, so I'm not proficient.
> >
> > I'm working with the matrix
> > A=[1i,1;1,-1i]
> >
> > and I'm looking for the eigenvalues.
> >
> > I would expect the only value to be 0.
> >
> > Matlab produces...
> >
> > lambda=eig(A)
> >
> > lambda =
> >
> > 1.0e-15 *
> >
> > 0.0647 + 0.0079i
> > -0.3174 - 0.1406i
> >
> >
> > It would be a great help if someone could explain why I'm reaching this result.
> >
> > Thanks!
> >
> > Mark
>
> There's nothing wrong with your work by hand. The precise values of those eigenvalues are both zero. However, you are witnessing the effects of round off error here with the output of 'eig'. Note the size of those eigenvalue results. They are down in the range of single bit errors in the least bit position of the original values in A. This is something you will have to become accustomed to in numerical computation by machines with only a finite number of bits of accuracy - in this case 53.
>
> Roger Stafford

Roger -

Thanks for your clarification. It is greatly appreciated!

Subject: Eigenvalues and Matlab

From: Roger Stafford

Date: 20 Apr, 2010 00:46:04

Message: 5 of 5

"Mark Roman" <user@gmail.com> wrote in message <hqis3d$d4$1@fred.mathworks.com>...
> Thanks for your clarification. It is greatly appreciated!

  Just for your further edification try the following on your machine. On mine they all come out with a small difference from zero, even though mathematically perfect answers would all be zero.

 (2^(1/2))^2-2
 sin(pi)
 43*(7/43)-7
 exp(log(5))-5
 (3/14+(3/14+15/14)) - ((3/14+3/14)+15/14)

This last one even has the audacity to violate the associative law of addition but of course only by a very tiny amount in relation to the size of the values involved.

Roger Stafford

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us