1
$\begingroup$

I'm facing the following problem and would very much like you help. Thanks is advance!

I have defined the following 4x4 matrix: \begin{equation} S=\left( \begin{array}{cccc} \frac{1}{r^2} & 1 & 1 & t\sqrt{x}\\ 1 & \frac{1}{t^2} & 1 & \frac{\sqrt{x}}{t}\\ 1 & 1 & 1 & \sqrt{q} \\ t\sqrt{x} & \frac{\sqrt{x}}{t} & \sqrt{q} & 1 \end{array} \right). \end{equation} where $(t,r)$ are two parameters (which I can choose arbitrarily to be any value in the segment $(0,1]$) and $(x,q)$ are the variables (each over the domain $[0,1]$).

Now, for a fixed pair of $(r,t)$ I want to plot a region of $(x,q)$ over which the matrix $S$ is positive semi-definite (I want it to be a valid covariance matrix). The thing is that when I try to use the Manipulate function (manipulation on $(r,t)\in(0,1]^2$), and plotting the region of $(x,t)$, nothing shows. Namely, Iv'e written the following:

S={{1/r^2, 1, 1, t Sqrt[x]}, {1, 1/t^2, 1, Sqrt[x]/t}, 
   {1, 1, 1, Sqrt[q]}, {t Sqrt[x], Sqrt[x]/t, Sqrt[q], 1}};

Manipulate[
  RegionPlot[PositiveDefiniteMatrixQ[S], 
             {x, 0, 1}, {q, 0, 1}], {r, 0, 1}, {t, 0, 1}]

and I get an empty graph no matter what values I set for $(r,t)$. You might say that maybe this matrix is never positive semi-definite, but the strange this is that if I manually input numerical values to $(r,t)$ and plot the region, everything works fine.

I really need to manipulate over all possible parameter value of $(r,t)$. What is wrong here and how can I fix it?

Moreover, is it possible for Mathematica to parametrically find a local minima of a certain function (of the variable $q$ where $(r,t,x)$ serve as parameters) subject to the constraint that the above matrix must be positive semi-definite? If so, it would very much help me to know how to formalize such a command.

$\endgroup$
6
$\begingroup$

Try to define your matrix as a function of $(x,q,r,t)$ variables

S[x_, q_, r_, t_] := {{1/r^2, 1, 1, t Sqrt[x]}, {1, 1/t^2, 1, Sqrt[x]/t}, {1, 1, 1, Sqrt[q]}, {t Sqrt[x], Sqrt[x]/t, Sqrt[q], 1}};

Then Manipulate does what you want

Manipulate[
 RegionPlot[
  PositiveDefiniteMatrixQ@S[x, q, r, t], {x, 0, 1}, {q, 0, 1}],
   {{r, 1/2}, 0, 1}, {{t, 1/2}, 0, 1}]

enter image description here

$\endgroup$
  • $\begingroup$ Great! thank you very much. How about the minimization problem? Is it possible to do what I want? $\endgroup$ – Adam Dinstein Jul 16 '13 at 9:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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