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:
eig not producing the right answer??

Subject: eig not producing the right answer??

From: Pinpress

Date: 19 Jan, 2011 20:08:04

Message: 1 of 6

Hi,

I am using eig to generate principal strains and principal directions from a strain tensor, but found sometimes it fails to produce the right answer. I have found out that the eig function seems to be very sensitive to non-zero entries when the tensor is symmetric (within numerical tolerance).

A simple example:

ee = [0.1 0; 0 0.1];
[V,D] = eig(ee)
V =
     1 0
     0 1
D =
    0.1000 0
         0 0.1000

This is OK. However, adding eps to the input completely changes the eigon direction:
[V,D] = eig(ee+eps)
V =
   -0.7071 0.7071
    0.7071 0.7071
D =
    0.1000 0
         0 0.1000

 [V,D] = eig(ee-eps)
V =
   -0.7071 -0.7071
   -0.7071 0.7071
D =
    0.1000 0
         0 0.1000

Can anyone tell me what is going on? How can I avoid this behavior in practice, when the tensor almost always will have some noise in the numbers. Thanks!!

Subject: eig not producing the right answer??

From: Steven_Lord

Date: 19 Jan, 2011 20:28:35

Message: 2 of 6



"Pinpress" <nospam__@yahoo.com> wrote in message
news:ih7gb4$lg8$1@fred.mathworks.com...
> Hi,
>
> I am using eig to generate principal strains and principal directions from
> a strain tensor, but found sometimes it fails to produce the right answer.
> I have found out that the eig function seems to be very sensitive to
> non-zero entries when the tensor is symmetric (within numerical
> tolerance).
>
> A simple example:
>
> ee = [0.1 0; 0 0.1];
> [V,D] = eig(ee)
> V =
> 1 0
> 0 1
> D =
> 0.1000 0
> 0 0.1000

That's correct; your ee is 0.1*eye(2) and so you can tell the eigenvalues
and eigenvectors by inspection.

> This is OK. However, adding eps to the input completely changes the eigon
> direction:
> [V,D] = eig(ee+eps)
> V =
> -0.7071 0.7071
> 0.7071 0.7071
> D =
> 0.1000 0
> 0 0.1000

This too is correct. Your ee+eps is:

[0.1+eps, eps; eps, 0.1+eps]

not, as I suspect you may be thinking:

[0.1+eps, 0; 0, 0.1+eps]

If you want the latter answer, add eps*eye(2) to ee.

You can check the answers EIG gives easily enough:

ee2 = ee+eps;
[V, D] = eig(ee2);
difference = (ee2*V-V*D)

All the elements of difference should be (and are, when I computed it) very
small.

--
Steve Lord
slord@mathworks.com
comp.soft-sys.matlab (CSSM) user-generated FAQ:
http://matlab.wikia.com/wiki/FAQ
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

Subject: eig not producing the right answer??

From: Matt J

Date: 19 Jan, 2011 20:29:04

Message: 3 of 6

"Pinpress" wrote in message <ih7gb4$lg8$1@fred.mathworks.com>...
>
> Can anyone tell me what is going on? How can I avoid this behavior in practice, when the tensor almost always will have some noise in the numbers. Thanks!!
================

In practice, will you have repeated eigevalues, like in this example? The discontinuous behavior shouldn't occur for distinct eigenvalues, except up to a trivial sign change. For example,

>> ee = [0.1 0; 0 0.3];
>> [V,D] = eig(ee+eps)

V =

   -1.0000 0.0000
    0.0000 1.0000


D =

    0.1000 0
         0 0.3000

Subject: eig not producing the right answer??

From: Pinpress

Date: 19 Jan, 2011 20:46:06

Message: 4 of 6

Thanks both Steve and Matt.

To Steve:

either eig(ee+eps), or eig(ee + [0 eps; eps 0]) would produce the same effect. My point was to demonstrate what I observed.

To Matt:

I have also noticed that if the eig values do not repeat, then I am fine. However in practice, I could have repeated eigen values, for example, a bilateral stretching in X and Y directions of the same amount (this is exactly what my previous example was trying to do).

Any more thoughts??


"Matt J" wrote in message <ih7hig$cbu$1@fred.mathworks.com>...
>
> In practice, will you have repeated eigevalues, like in this example? The discontinuous behavior shouldn't occur for distinct eigenvalues, except up to a trivial sign change. For example,
>
> >> ee = [0.1 0; 0 0.3];
> >> [V,D] = eig(ee+eps)
>
> V =
>
> -1.0000 0.0000
> 0.0000 1.0000
>
>
> D =
>
> 0.1000 0
> 0 0.3000

Subject: eig not producing the right answer??

From: Pinpress

Date: 19 Jan, 2011 20:49:05

Message: 5 of 6

Thanks Steven.

Yes, the "difference" was indeed small. However, the difference in V is huge, totally different, and I am more interested in computing V more reliably.

Thanks!

"Steven_Lord" <slord@mathworks.com> wrote in message
>
> You can check the answers EIG gives easily enough:
>
> ee2 = ee+eps;
> [V, D] = eig(ee2);
> difference = (ee2*V-V*D)
>
> All the elements of difference should be (and are, when I computed it) very
> small.
>

Subject: eig not producing the right answer??

From: Matt J

Date: 19 Jan, 2011 21:03:05

Message: 6 of 6

"Pinpress" wrote in message <ih7io0$t84$1@fred.mathworks.com>...
> Thanks Steven.
>
> Yes, the "difference" was indeed small. However, the difference in V is huge, totally different, and I am more interested in computing V more reliably.
=======

There is nothing unreliable about the result. Your principal directions are ill-defined in the case when the tensor has repeated eigenvalues. The columns

V=
  -0.7071 0.7071
    0.7071 0.7071

is just as valid for a set of principal directions as V=eye(2)

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