I start out with 5x5 matrix gCorrMatrix[g]
depending on a parameter $g$ and an unknown $W_2$
gCorrMatrix[g_] := {{1, 0, Subscript[W, 2], 0, -((-1 + Subscript[W, 2])/g)},
{0, Subscript[W, 2], 0, -((-1 + Subscript[W, 2])/g), 0},
{Subscript[W, 2], 0, -((-1 + Subscript[W, 2])/g), 0,
-((1 - Subscript[W, 2] - 2*g*Subscript[W, 2])/g^2)},
{0, -((-1 + Subscript[W, 2])/g),
0, -((1 - Subscript[W, 2] - 2*g*Subscript[W, 2])/
g^2), 0}, {-((-1 + Subscript[W, 2])/g), 0,
-((1 - Subscript[W, 2] - 2*g*Subscript[W, 2])/g^2), 0,
-((-1 - 2*g + Subscript[W, 2] + 4*g*Subscript[W, 2] -
g^2*Subscript[W, 2]^2)/g^3)}}
I define a function of this matrix that returns an inequality
gRegion[g_] := Reduce[Eigenvalues[gCorrMatrix[g]] >= 0, Subscript[W, 2]]
that gives a range of values of $W_2$ for each $g$ where gCorrMatrix[g]
is positive-definite. Evaluating gives
In[157]:= Timing[gRegion[.3]]
During evaluation of In[157]:= Reduce::ratnz: Reduce was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result.
Out[157]= {0.083676, 0.703257 <= Subscript[W, 2] <= 0.714234}
Clearly this is computationally expensive to evaluate over and over again. Mathematica just hangs when I try to plot
RegionPlot[gRegion[g], {g, -1/8, .5}, {Subscript[W, 2], .5, 2}]
This surprised me because gRegion[g]
is very simple (just a line segment and independent of $g$). Is there a way I can tell RegionPlot
to just plot each line segment of $W_2$ sequentially? This really shouldn't take more than a few seconds. I thought I could change this with the Method
option but I can't see anything in the documentation aside from Method->"Automatic"
.