cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Symbolic and numeric bugs on one page

ifomenko
15-Moonstone

Symbolic and numeric bugs on one page

I've met something very strange....


ScreenShort.PNG

MC15 file is attached

1 ACCEPTED SOLUTION

Accepted Solutions

Just a suggestion to avoid the confusion - overlay the function "eigenvec" by a userdefined function:

B.png

View solution in original post

7 REPLIES 7

Your problem is probably related to the fact that the symbolic eigenvalues are listed in reverse order to those of the numeric eigenvalues.

 

eigenvals.PNG

Alan

 

 

To put it short - the problem is the different results you get when you evaluate R either symbolically or numerically:

B3.png

The problem is a different handling of eigenvec in numerics and symbolics. As you possibly know the eigenvector for a given eigenvalue is not unique and numerics and symbolics chose different vectors for this. The numerics will always chose a unitvector but the symbolics doesn't.

So you get the correct result if you stay completely within symbolics

B.png

 

or if you stay completely within numerics:

B2.png

ifomenko
15-Moonstone
(To:Werner_E)

Thank you all,

I know all these specific things about the differences between symbolic and numeric calculations.

Werner, you wrote, "The numerics will always chose a unitvector but the symbolics doesn't."

For this reason, I always use eigenvec(R, lambda) function instead of simple eigenvecs(R), the first one works well and returns unit vector.

But anyway, why two last numeric calculations gave a different results?


I always use eigenvec(R, lambda) function instead of simple eigenvecs(R), the first one works well and returns unit vector.

No!! Using eigenvec instead of eigenvecs gives you control about the order of the vectors (which is also differently in numerics and symbolics as Alan had pointed out), but eigenvec WILL NOT evaluate to a unitvector symbolically:

B.png

And thats the reason for all the confusion.

You define matrix R using the function eigenval(C,lambda). Now it depends upon if you evaluate R numerically or symbolically if you get the matrix you expect, the one where the columns are unit vectors.

If you evaluate R*C.l*R^T symbolically, R gets the wrong values and you get a wrong result.

Before the last numeric evaluation you assigned R the symbolic result and so consequently the numeric R*C.l*R^T is wrong, too.

 

Just a suggestion to avoid the confusion - overlay the function "eigenvec" by a userdefined function:

B.png

ifomenko
15-Moonstone
(To:Werner_E)

Thank you very much, Werner!!!

I finally understood the problem: I always checked the norm of eigenvector numerically and got a unit. But it is not unit in symbolic case.

 

-MFra-
21-Topaz II
(To:ifomenko)

Hi,

It should be noted that the procedure is valid only for symmetric matrices.

Top Tags