Solve Matlab Eigenvectors Homework

Click For Summary
SUMMARY

The discussion focuses on solving a MATLAB homework problem involving eigenvectors and eigenvalues using the function [V,D]=eig(A). The user initially attempted to use elementwise multiplication (.*) instead of matrix multiplication (*) when reconstructing the original matrix A from the eigenvectors and eigenvalues. The correct approach, using matrix multiplication, yielded a result that closely approximated the original matrix A, despite minor errors due to the condition number of V.

PREREQUISITES
  • Understanding of eigenvectors and eigenvalues in linear algebra
  • Familiarity with MATLAB syntax and functions
  • Knowledge of matrix multiplication versus elementwise multiplication
  • Basic concepts of matrix inversion
NEXT STEPS
  • Learn MATLAB matrix operations, focusing on multiplication and inversion
  • Study linear algebra concepts related to eigenvalues and eigenvectors
  • Explore MATLAB's condition number function to understand numerical stability
  • Practice solving similar MATLAB problems involving matrix decompositions
USEFUL FOR

Students and professionals in mathematics, engineering, or computer science who are working with MATLAB for linear algebra applications, particularly those needing to compute and verify eigenvalues and eigenvectors.

jdawg
Messages
366
Reaction score
2

Homework Statement


I think this problem is supposed to be pretty simple, but I have almost no knowledge of how to use matlab. I was told to use this function: [V,D]=eig(A) to give me the eigenvectors (columns of matrix V) and the diagonal matrix with eigenvales in the diagonal ( matrix D). I also need to check the matrix with A=VDV-1.

Homework Equations

The Attempt at a Solution


I don't feel like this is right, but this is what I tried:
Here is what I typed in the script:

%1
A=[1 -3 3 3; -1 4 -3 -3; -2 0 1 1; 1 0 0 0]
[V,D]=eig(A)
V.*D.*inv(V)

And here is what came out:

A =

1 -3 3 3
-1 4 -3 -3
-2 0 1 1
1 0 0 0V =

-0.0000 0.0000 0.0000 0.5607
-0.0000 -0.7071 0.7071 -0.7476
0.7071 -0.7071 0.7071 -0.3271
-0.7071 0.0000 0.0000 0.1402D =

0.0000 0 0 0
0 1.0000 0 0
0 0 1.0000 0
0 0 0 4.0000ans =

1.0e+07 *

-0.0000 0 0 0
0 -1.0712 0 0
0 0 -1.0712 0
0 0 0 0.0000
[/B]
 
Last edited:
Physics news on Phys.org
jdawg said:
%1
A=[1 -3 3 3; -1 4 -3 -3; -2 0 1 1; 1 0 0 0]
[V,D]=eig(A)
V.*D.*inv(V)

You're close. The key here is that .* does elementwise multiplication (corresponding elements are multiplied, the result is the same size as the inputs), whereas * does matrix multiplication (you know, where an NxM matrix multiplied by an MxP matrix results in an NxP matrix).

You want to use * instead of .*, and when you do that you'll get a much better answer for the check:

Code:
V*D*inv(V)

ans =

    1.0000   -3.0000    3.0000    3.0000
   -1.0000    4.0000   -3.0000   -3.0000
   -2.0000   -0.0000    1.0000    1.0000
    1.0000    0.0000   -0.0000   -0.0000

Since the condition number of V is rather large, calculating the inverse introduces some error, so the above matrix isn't exactly equal to A, but it's close.

Code:
A - V*D*inv(V)

ans =

   1.0e-07 *

   -0.1285   -0.1285    0.1285    0.1285
    0.1286    0.1656   -0.1386   -0.1551
   -0.0052    0.0250    0.0221    0.0056
   -0.0072   -0.0072    0.0072    0.0072
 
Perfect! Thanks so much!
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
Replies
2
Views
2K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 18 ·
Replies
18
Views
4K
  • · Replies 18 ·
Replies
18
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 10 ·
Replies
10
Views
2K
  • · Replies 11 ·
Replies
11
Views
3K