# Visualizing 3x3 spectrahedra

I'm trying to visualize the SDP cone over 3x3 matrices by plotting random 3d sections of it. Since each region is a system of inequality constraints, I'm using RegionPlot, but I think the plots would look better if they only showed the surface...what is a good way to achieve this?

spectro2 := (
X = ( {
{x1, x2, x3},
{x2, x4, x5},
{x3, x5, x6}
} );
vars = Union@Flatten@X;
dvars = {x, y, z};
m = Length@vars;
n = Length@dvars;
makeMat := X /. (Thread[vars -> #]) &;
proj = makeMat /@ Orthogonalize@RandomReal[{-1, 1}, {n, m}];
mat2 =
Total@MapThread[Times, {proj, dvars}, 1] + IdentityMatrix@Length@X;
cons = And @@ (Thread[Eigenvalues[mat2] >= 0]);
RegionPlot3D[cons, {x, -3, 3}, {y, -3, 3}, {z, -3, 3}, Mesh -> 5,
PlotStyle -> Opacity[.7], PlotPoints -> 5]
);
Table[spectro2, {2}, {3}]


-
Hmm. What's an SDP? –  István Zachar Jan 26 '12 at 11:09
@IstvánZachar Probably 'semi-definite programming' –  Brett Champion Jan 26 '12 at 15:16
@IstvánZachar wikipedia has a somewhat scant definition of spectrahedron. But, it may be enough to go be. –  rcollyer Jan 26 '12 at 15:59
Yaroslav, I wanted to ask you: We were trying to get some questions migrated from Stack Overflow that are very mma specific and to close as dupes (some of them answered by you), and we faced some resistance from the mods there and one of the reasons that was mentioned was that the answerer might complain about loss of rep (in this case, one of the answers was your sin[x] answer). It's a valid point and so I just wanted to check with you — do you mind if your old questions/answers are migrated here? A list of questions currently being considered is here: meta.mathematica.stackexchange.com/q/744/5 –  rm -rf Oct 6 '12 at 1:30
I don't mind, as long as they are still easily findable –  Yaroslav Bulatov Oct 6 '12 at 2:26

If the desire is to not have a surface appear when the region hits the boundary of the plot range, you could use something like:

Show[RegionPlot3D[Evaluate[cons], {x, -3, 3}, {y, -3, 3}, {z, -3, 3},
PlotRangePadding -> None, Mesh -> 5, PlotStyle -> Opacity[.7],
PlotPoints -> 10], PlotRange -> 2.9]


to truncate the plot range to an area inside the boundary.

-
Ah, clipping the output range...yes, seems to do what I needed –  Yaroslav Bulatov Jan 26 '12 at 20:19
ContourPlot3D[x^3 + y^2 - z^2 == 0, {x, -2, 2}, {y, -2, 2}, {z, -2, 2}]