Quit[];

(* AUTOVALORI ED AUTOVETTORI *)

(* Esempio 1. *)

a={{1,2,-1},{4,1,-1},{2,0,1}};
n=Length[a]
id=IdentityMatrix[n];
MatrixForm[a]
Eigenvalues[a]
Eigenvectors[a]

a1=a-λ*id;
MatrixForm[a1]
eq=Det[a1]==0
eval=Solve[eq,λ]

eval[[1]]
eval[[2]]
eval[[3]]

x={x1,x2,x3};
sys1=Thread[Dot[(a1/.eval[[1]]),x]==0]
sol1=Solve[sys1,x][[1]]
sol1/.x3->2

sys2=Dot[(a1/.eval[[2]]),x]==0;
sol2=Solve[sys2,x][[1]]
sol2/.x3->1

sys3=Dot[(a1/.eval[[3]]),x]==0;
sol3=Solve[sys3,x][[1]]
sol3/.x3->1

(* Secondo esempio *)

Clear[a];
a={{0,1},{-1,0}};
n=Length[a]
id=IdentityMatrix[n];
MatrixForm[a]
Eigenvalues[a]

(* Terzo esempio *)

Clear[a];
a={{1,1},{-1,2}};
n=Length[a]
id=IdentityMatrix[n];
MatrixForm[a]
Eigenvalues[a]

(* Quarto esempio *)

Clear[a];
a={{1,1,0},{-1,2,0},{0,0,3}};
n=Length[a]
id=IdentityMatrix[n];
MatrixForm[a]
Eigenvalues[a]

(* Quinto esempio *)

Clear[a];
a={{1,2,3},{-1,-2,-3},{4,5,1}};
n=Length[a]
id=IdentityMatrix[n];
MatrixForm[a]
Eigenvalues[a]