# How do I plot Numerical Range of two hermitian matrices

Let $A_1$ and $A_2$ be two $3\times 3$ hermitian matrices. Then their numerical range is defined as two-dimensional set

\begin{align} \mathbb{S}=\{\left[u^HA_1u,u^HA_2u\right]\in \mathbb{R}^2,u^Hu=1\} \end{align}

where $u$ is a unit-norm vector. Each of the $u^HA_iu,~i=1,2$ is a real number. Thus for a given $u$, I calculate the first co-ordinate as $u^HA_1u$ and second co-ordinate as $u^HA_2u$, then I have to vary $u$ through all possible unit-norm vectors. Thus $\mathbb{S}$ becomes a 2-D set.

EDIT If it is possible to find a solution for the real case, that is fine. But then the matrices $A_1$ and $A_2$ will be of size $6 \times 6$. The reason is you can convert the above set of equations in terms of real variables and real matrices in higher dimensions (twice the dimension to be exact).

-
What are the square brackets ? do you take u to be complex ? –  b.gatessucks Apr 30 at 9:38
@b.gatessucks Please see the edit. Yes I take $u$ as complex, but if you know solution for real, that is fine as well –  dineshdileep Apr 30 at 9:41

If you consider only real unit vectors then one can parametrize them in spherical coordinates u = {Sin[t] Cos[f], Sin[t] Sin[f], Cos[t]}; this way you can then use ParametricPlot.

Example :

SeedRandom[6]
a1 = With[{tmp = RandomReal[{-1, 1}, {3, 3}] + I RandomReal[{-1, 1}, {3, 3}]},
0.5 (tmp + ConjugateTranspose[tmp])];
a2 = With[{tmp = RandomReal[{-1, 1}, {3, 3}] + I RandomReal[{-1, 1}, {3, 3}]},
0.5 (tmp + ConjugateTranspose[tmp])];

range[t_, f_] = {Dot[{Sin[t] Cos[f], Sin[t] Sin[f], Cos[t]}, a1, {Sin[t]Cos[f], Sin[t] Sin[f], Cos[t]}],
Dot[{Sin[t] Cos[f], Sin[t] Sin[f], Cos[t]}, a2, {Sin[t] Cos[f], Sin[t] Sin[f], Cos[t]}]};

(* doubling the t-range to make the plot better *)
ParametricPlot[range[t, f], {t, 0, 2 Pi}, {f, 0, 2 Pi}, Mesh -> None]


-
+1, nice!!. The reason I said real is fine is because, if one can do it for complex, then one can do it for real as well. If your complex matrix is $N\times N$, then you can convert it into a equation in real variables, but then matrix will be of size $2N \times 2N$. Thus in my case, $A_1$ and $A_2$ will be $6\times 6$. Is there any way to extend this solution to real case? –  dineshdileep Apr 30 at 15:14
@dineshdileep In the complex case you'd have 5 independent variables and I don't know of any way of handling that continuosly. You could generate a big list of points and then use ListPlot but the result will not be as nice. –  b.gatessucks Apr 30 at 15:30
also, why is there some dark, more colored portion inside that shape. Is it because of complex part? –  dineshdileep Apr 30 at 16:53
I think it's just an artifact of the plotting routine; you can see a "skeleton" of the continuous plot with ParametricPlot[range[t, f], {t, 0, 2 Pi}, {f, 0, 2 Pi}, Mesh -> None]. However, hopefully some of the experts will have a better answer. –  b.gatessucks Apr 30 at 17:43
When I try $EigenValues[a1]$ after executing your code, I don't get real numbers, why is that so? –  dineshdileep May 1 at 2:38
show 1 more comment