Yesterday in class, inspired by Problem 3 on Assignment 1, I decided to try a more general problem: Five points in the plane determine a conic section uniquely. How to illustrate this fact in Mathematica? I asked ChatGPT to solve this for us. However ChatGPT's code did not work. I studied the ChatGPT's code and start seeing a solution there. Below is a "bare bones" code for this problem
Manipulate[
Module[{mat, conic},
mat = Prepend[{#[[1]]^2, #[[1]] #[[2]], #[[2]]^2, #[[1]], #[[2]],
1} & /@ {pA, pB, pC, pD, pE}, {x^2, x y, y^2, x, y, 1}];
conic = Det[mat];
ContourPlot[conic == 0, {x, -5, 5}, {y, -5, 5},
PlotPoints -> {100, 100},
ContourStyle -> {Thickness[0.006], RGBColor[0, 0, 0.5]},
PlotRange -> {{-5, 5}, {-5, 5}}, AspectRatio -> Automatic,
ImageSize -> 500]],
{{pA, {0, -3}}, {-5, -5}, {5, 5},
Locator}, {{pB, {1, -2}}, {-5, -5}, {5, 5},
Locator}, {{pC, {-1, -2}}, {-5, -5}, {5, 5},
Locator}, {{pD, {-2, 1}}, {-5, -5}, {5, 5},
Locator}, {{pE, {2, 1}}, {-5, -5}, {5, 5}, Locator}]
Below is an extended code that shows more information about the conic that is being created:
Manipulate[
Module[{mat, conic, mins},
mat = Prepend[{#[[1]]^2, #[[1]] #[[2]], #[[2]]^2, #[[1]], #[[2]],
1} & /@ {pA, pB, pC, pD, pE}, {x^2, x y, y^2, x, y, 1}];
conic = Det[mat]; mins = Map[Reverse, Minors[mat], {0, 1}][[1]];
If[And[Abs[mins[[1]]] < 0.01, Abs[mins[[2]]] < 0.01,
Abs[mins[[3]]] < 0.01, Abs[mins[[4]]] < 0.01,
Abs[mins[[5]]] < 0.01],
ContourPlot[None, {x, -5, 5}, {y, -5, 5},
Epilog -> {Text["No conic!", {0, 4}]},
PlotRange -> {{-5, 5}, {-5, 5}}, AspectRatio -> Automatic,
ImageSize -> 500],
ContourPlot[conic == 0, {x, -5, 5}, {y, -5, 5},
PlotPoints -> {100, 100},
ContourStyle -> {Thickness[0.01], RGBColor[0, 0, 0.5]},
Epilog -> {If[
Abs[Det[{{mins[[1]], mins[[2]]/2}, {mins[[2]]/2,
mins[[3]]}}]] < 0.01, Text["Parabola", {0, 4}],
If[Det[{{mins[[1]], mins[[2]]/2}, {mins[[2]]/2, mins[[3]]}}] >
0.01, Text["Ellipse", {0, 4}], Text["Hyperbola", {0, 4}]]],
Text[N[Eigenvalues[{{mins[[1]], mins[[2]]/2}, {mins[[2]]/2,
mins[[3]]}}]], {0, 4.5}]}, PlotRange -> {{-5, 5}, {-5, 5}},
AspectRatio -> Automatic, ImageSize -> 500]]
],
{{pA, {0, -3}}, {-5, -5}, {5, 5},
Locator}, {{pB, {1, -2}}, {-5, -5}, {5, 5},
Locator}, {{pC, {-1, -2}}, {-5, -5}, {5, 5},
Locator}, {{pD, {-2, 1}}, {-5, -5}, {5, 5},
Locator}, {{pE, {2, 1}}, {-5, -5}, {5, 5}, Locator}]