7
$\begingroup$

The following is a spectrahedron region plot using 3 eigenvalues for mesh functions. It takes 22 seconds and mesh line quality is quite poor, any tips on making it nicer?

Already using PlotPoints->50, so is there another setting for controlling number of evaluation points for mesh lines?

roots = Eigenvalues[{{1, p1, p2}, {p1, 1, p3}, {p2, p3, 1}}];
eig1 = Function[{p1, p2, p3}, Evaluate@roots[[1]]];
eig2 = Function[{p1, p2, p3}, Evaluate@roots[[2]]];
eig3 = Function[{p1, p2, p3}, Evaluate@roots[[3]]];
RegionPlot3D[
 Max@Eigenvalues@{{1, p1, p2}, {p1, 1, p3}, {p2, p3, 1}} < 2, {p1, -1,
   1}, {p2, -1, 1}, {p3, -1, 1}, PlotPoints -> 50, 
 MeshFunctions -> {eig1, eig2, eig3}]

enter image description here

PS, doing region plots for the three eigenvalues is informative, but doesn't seem to translate well into Mesh lines

ContourPlot3D[eig1[p1, p2, p3], {p1, -1, 1}, {p2, -1, 1}, {p3, -1, 1}, RegionFunction -> Function[{x, y, z}, x < 0 || y > 0]]
ContourPlot3D[eig2[p1, p2, p3], {p1, -1, 1}, {p2, -1, 1}, {p3, -1, 1}, RegionFunction -> Function[{x, y, z}, x < 0 || y > 0]]
ContourPlot3D[eig3[p1, p2, p3], {p1, -1, 1}, {p2, -1, 1}, {p3, -1, 1}, RegionFunction -> Function[{x, y, z}, x < 0 || y > 0]]

enter image description here

$\endgroup$
0

2 Answers 2

10
$\begingroup$

Since the numeric roots/eigenvalues are real, they come in increasing order. Maybe this, then?:

Quiet[
 RegionPlot3D[
  eig3[p1, p2, p3] < 2, {p1, -1, 1}, {p2, -1, 1}, {p3, -1, 1}, 
  PlotPoints -> 35, MeshFunctions -> {eig1, eig2}],
 Less::nord]

enter image description here

$\endgroup$
3
  • 1
    $\begingroup$ The problem with eig3 as a mesh function is that the surface coincides with a level set, up to a certain error. So the total range of eig3 over the OP's surface, which should be {2} is in fact {1.9991, 2.00002}, and the surface approximation error is determining the mesh lines. ("The surface approximation error" comes from truncating the refinement of the polygonal mesh approximating the boundary eig3[p1, p2, p3] == 2.) $\endgroup$
    – Michael E2
    Sep 29, 2021 at 3:41
  • $\begingroup$ thanks, makes sense! Interesting that eig1 and eig2 mesh lines look identical even though region plots for those two functions look quite different $\endgroup$ Sep 29, 2021 at 4:40
  • 1
    $\begingroup$ @YaroslavBulatov Yes, I noticed that, but it wasn't immediately obvious why last night. However, from the characteristic polynomial, one has $e_1+e_2+e_3 = 3=$ trace of the matrix. So if two of the eigenvalues are constant along a trajectory, so is the third. You can save some time just specifying, say, eig2 as a mesh function. $\endgroup$
    – Michael E2
    Sep 29, 2021 at 12:55
3
$\begingroup$

Higher quality requires higher values for PlotPoints and MaxRecursion, and specifying a WorkingPrecision. These will all increase the timing.

Clear["Global`*"]

$Version

(* "12.3.1 for Mac OS X x86 (64-bit) (June 19, 2021)" *)

roots = Eigenvalues[{{1, p1, p2}, {p1, 1, p3}, {p2, p3, 1}}];

{eig1, eig2, eig3} = Function[{p1, p2, p3}, Evaluate@#] & /@ roots;

Column[
 AbsoluteTiming[
  RegionPlot3D[
   Max@Eigenvalues@
      {{1, p1, p2}, {p1, 1, p3}, {p2, p3, 1}} < 2,
   {p1, -1, 1}, {p2, -1, 1}, {p3, -1, 1},
   PlotPoints -> 135,
   MaxRecursion -> 5,
   MeshFunctions -> {eig1, eig2, eig3},
   WorkingPrecision -> 30,
   ImageSize -> 400,
   PerformanceGoal -> "Quality"]]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.