Ellipse figure for eigenvalue introduction

Remove["Global`*"]

Pick some parameters for the ellipse based on finding a nice matrix

Eigensystem[{{a,c},{c,b}}]/.{a->6,b->3,c->2}

Formulate the ellipse

r=4;
A={{6,2},{2,3}};
lhs=Expand[{x,y}.A.{x,y}]

Draw the ellipse

lims=3.25;
Show[
ContourPlot[lhs==r^2,{x,-lims,lims},{y,-lims,lims},
ContourStyle->Black,
AspectRatio->1,
LabelStyle->15],
ListLinePlot[{{0,-lims},{0,lims}},PlotStyle->{Black,Dashed}],
ListLinePlot[{{-lims,0},{lims,0}},PlotStyle->{Black,Dashed}]
]

Find the eigenvalues and confirm them the old fashioned way

{eivals,eivecs}=Eigensystem[A]

Solve[Det[A-λ IdentityMatrix[2]]==0,λ]

Normalize the eigenvectors by hand. There are slicker ways to do this, but this is just a 2x2 so...

n1=Norm[eivecs[[1]]];
n2=Norm[eivecs[[2]]];
neivecs=eivecs/{n1,n2}

Define the rotation matrix. Remember that it has the eigenvectors as columns

R=Transpose[neivecs];
MatrixForm[R]

Check that the transformation properties are correct

RT=Transpose[R];
MatrixForm[RT.R]

MatrixForm[RT.A.R]

Use the eigenvectors to draw the axes of the ellipse. We’ll do this a klunky but transparent way. Use the rotation matrix to rotate the unit vectors in x and y, and use these rotated unit vectors to get the direction of the line. We are actually cheating a little because we know the eigenvectors are orthogonal, so use the “x” transformation to draw “y” and vice versa

y1=y/.Solve[R.{1,0}.{x,y}==0,y][[1]]
y2=y/.Solve[R.{0,1}.{x,y}==0,y][[1]]

Add the new axes to the plot

Show[
ContourPlot[lhs==r^2,{x,-lims,lims},{y,-lims,lims},
ContourStyle->Black,
AspectRatio->1,
LabelStyle->15],
ListLinePlot[{{0,-lims},{0,lims}},PlotStyle->{Black,Dashed}],
ListLinePlot[{{-lims,0},{lims,0}},PlotStyle->{Black,Dashed}],
Plot[{y1,y2},{x,-lims,lims},PlotStyle->{{Red,Dashed},{Red,Dashed}}]
]

Calculate the rotation angle

N[ArcCos[R[[1]][[1]]]]180/Pi