First off, I am new to using Mathematica. What I am trying to do is the following:
- I have a matrix that is a function of two variables. I want to plot the region in the space of these 2 variables where the matrix is positive definite.
- How I would do this in any other programming language is checking for positive definiteness of the matrix while iterating over the 2 variables in a nested loop and then try to plot the regions where the condition comes out to be true.
- I am not sure how I would go about doing this in Mathematica. I am able to write a similar code as to what I described above using Do and I get an output. But I am not able to figure out how to plot that data.
Also, is there a better way to do it in Mathematica than the method I described above?
This is the code I have so far.
K = 7;
Array[x, 2 K + 1, 0];
x[0] = 1;
x[1] = 0;
Do[
x[2] = xa;
x[n] = 0;
x[n + 3] = (n/(n + 2)) (Ener) x[
n - 1] + (n (n - 1) (n - 2)/(4 n + 8)) x[
n - 3] - ((n + 1)/(n + 2)) x[n + 1];
(M = Table[x[i + j - 2], {i, K + 1}, {j, K + 1}]) // MatrixForm;
pred = PositiveSemidefiniteMatrixQ[M];
Print[pred, xa, Ener], {xa, 0.295, 0.310, 0.001}, {Ener, 1.34, 1.44,
0.01}, {n, 1, 2 K - 2, 2}
]
Any help is highly appreciated. Thanks!
pred
was positive semidefinite when running your code. $\endgroup$HankelMatrix[]
to construct yourM
? $\endgroup$