(*Review of Linear algebra: symmetric matrices are orthogonally diagonalizable*)
A={{5,1},{1,7}};
Eigensystem[A]

(*Renormalizing eigenvectors to be unit lenght; they are already orthogonal - why?*)
{v1,v2}={{-1+(Sqrt[2]),1},{-1-(Sqrt[2]),1}};u1=Simplify[v1/Sqrt[v1.v1]]
u2=Simplify[v2/Sqrt[v2.v2]]

diag=DiagonalMatrix[{6+(Sqrt[2]),6-(Sqrt[2])}];
P=Transpose[{u1,u2}];
diag//MatrixForm
P//MatrixForm

(*Checking*)
A==Simplify[P.diag.Inverse[P]]
Inverse[P]==Transpose[P]

(*Switching coordinate systems x=Py to eliminate mixed terms in quadratic form*)
{y1,y2}=Transpose[P].{x1,x2}

Simplify[(6+(Sqrt[2]))(y1)^2+(6-(Sqrt[2]))(y2)^2]

Show[RegionPlot[5 (x1^2)+2 x1 x2+7 (x2^2)≤10,{x1,-3,3},{x2,-3,3},PlotStyle->{Opacity[.2],Gray},BoundaryStyle->{Thick, Gray}],
RegionPlot[(6+(Sqrt[2]))(y1)^2+(6-(Sqrt[2]))(y2)^2≤10,{y1,-3,3},{y2,-3,3},PlotStyle->{Opacity[.2],Red},BoundaryStyle->{Thick, Red}]]

(*Excercise 1*)
X={{1+x1,x2},{x2,1-x1}};
X//MatrixForm

(*Computes all principal minors*)
princminors[X_]:=(
minors={};
For[k=1,k<=Length[X],k++,
ktuples=Subsets[Range[Length[X]],{k}];
For[i=1,i<=Length[ktuples],i++,
minors=AppendTo[minors,Det[X[[ktuples[[i]],ktuples[[i]]]]]];
];
];
Return[minors];
);
(*Applies Sylvester's criterion for positive-semidefiniteness*)
region=Simplify[And@@Thread[princminors[X]>=0]]
RegionPlot[region,{x1,-2,2},{x2,-2,2}]

X=DiagonalMatrix[{1+x1,1-x1,1+x2,1-x2}];
X//MatrixForm

region=Simplify[And@@Thread[princminors[X]>=0]]
RegionPlot[region,{x1,-2,2},{x2,-2,2}]

X={{1,x1,x2},{x1,1,x1},{x2,x1,1}};
X//MatrixForm

region=Simplify[And@@Thread[princminors[X]>=0]]
RegionPlot[region,{x1,-2,2},{x2,-2,2}]

CylindricalDecomposition[region,{x1,x2}]

RegionPlot[-1+2 (x1^2)≤x2≤1,{x1,-2,2},{x2,-2,2}]