Consider a function
F[a_, b_, uaa_, ubb_, uab_, na_, nb_] :=
a/na*Log[a] + b/nb*Log[b] + (1 - a - b)*Log[1 - a - b] -
1/2*uaa*a^2 - 1/2*ubb*b^2 - uab*b*a
and its Hessian matrix
Hess[a_, b_, uaa_, ubb_, uab_, na_, nb_] :=
D[F[a, b, uaa, ubb, uab, na, nb], {{a, b}, 2}] // Evaluate
and the corresponding determinant
det[a_, b_, uaa_, ubb_, uab_, na_, nb_] :=
Det[D[F[a, b, uaa, ubb, uab, na, nb], {{a, b}, 2}]] // Evaluate
One can visualize the contours of the determinant,
Manipulate[ContourPlot[{det[a, b, uaa, ubb, uab, 10, 8] == 0},
{a, 0, 1}, {b, 0, 1},
RegionFunction -> Function[{a, b}, 0 <= a + b <= 1]],
{uaa, 0, 10}, {uab, 0, 10, 1}, {ubb, 0, 10}]
Alongside these, at a few random (or maybe equally spaced points) on the contour, I would like to visualise the eigenvector corresponding the the minimum eigenvalue.
Manipulate[
Module[{plot, contourData, sampledPoints},
plot = ContourPlot[
det[a, b, uaa, ubb, uab, 10, 8] == 0, {a, 0, 1}, {b, 0, 1}];
contourData = Cases[Normal[plot], Line[pts_] :> pts, Infinity];
sampledPoints = RandomSample[Flatten[contourData, 1], 10];
Show[plot,
Graphics[{Table[
With[{vec =
Eigensystem[Hess[a, b, uaa, ubb, uab, 10, 8]][[2,
2]]}, {Arrowheads[0.02],
Arrow[{pt, pt + 0.1 Normalize[vec]}]}], {pt,
sampledPoints}]}]]], {uaa, 0, 10}, {uab, 0, 10, 1}, {ubb, 0,
10}]
The above doesn't work as intended. It gives the error,
RandomSample::smplen: RandomSample cannot generate a sample of length 10, which is greater than the length of the sample set {}. If you want a choice of possibly repeated elements from the set, use RandomChoice.
Even when the contour data is not empty/should not be empty. Also I am not sure of how to select equally spaced points at all (not super crucial, but a personal preference for visualisation purposes).
Here's a random illustration of what I am going for made in powerpoint (not mathematically correct).