# Density plot through a single-lined double loop

I have a function f that is dependent on three parameters ω, κ2 and x:

f[ω_, κ2_,
x_] := (384000. x κ2 Sqrt[κ2^2])/(1600000000 x^2 \
κ2^2 (1/100000000 + 4 ω^2) + (κ2^2 +
4 ω^2) (16 +
8 (1/10000 - 4 ω^2) + (1/100000000 +
4 ω^2) (1 + 4 ω^2)) +
80000 x κ2 ((κ2 - 4 ω^2) (1/100000000 +
4 ω^2) +
4 (κ2/10000 + 4 ω^2))) + (9.6 (κ2^2 +
4 ω^2))/(1600000000 x^2 κ2^2 (1/100000000 +
4 ω^2) + (κ2^2 + 4 ω^2) (16 +
8 (1/10000 - 4 ω^2) + (1/100000000 +
4 ω^2) (1 + 4 ω^2)) +
80000 x κ2 ((κ2 - 4 ω^2) (1/100000000 +
4 ω^2) +
4 (κ2/10000 +
4 ω^2))) + (0.0122 (1600000000 x^2 κ2^2 +
80000 x κ2 (κ2 - 4 ω^2) + (1 +
4 ω^2) (κ2^2 +
4 ω^2)))/(1600000000 x^2 κ2^2 (1/100000000 +
4 ω^2) + (κ2^2 + 4 ω^2) (16 +
8 (1/10000 - 4 ω^2) + (1/100000000 +
4 ω^2) (1 + 4 ω^2)) +
80000 x κ2 ((κ2 - 4 ω^2) (1/100000000 +
4 ω^2) + 4 (κ2/10000 + 4 ω^2)))


As you can see, the function is long but nonetheless dependent on those three paramters (I apologize if the symbols are hard to see, I copied and replaced the raw symbols with unicode glyphs from the add-on).

Now I intend to plot a density plot with the x-axis as κ2, y-axis as x, and the z-axis as the Difference in the maxima of the function at each κ2 and x value as a function of ω. I tried really hard to do all of this in one line through a double loop (because my computer has a hard time allocating memory). My attempt is of the following:

ωarr =
Table[{i, j,
Max[ω /.
NSolve[(D[f[ω, i, j], ω]) == 0 &&
D[f[ω, i, j], {ω, 2}] < 0, Reals]] -
Min[ω /.
NSolve[(D[f[ω, i, j], ω]) == 0 &&
D[f[ω, i, j], {ω, 2}] < 0, Reals]]}, {i, 0,
100, 1}, {j, 0, 10^-3, 10^-4}];


From what I can tell, the code works and it spits out a really long nested list, each containing three elements: {i, j, maxima difference} - That's my x, y and z coordinate right there. I proceed to plot a density plot like so:

ListDensityPlot[ωarr]


But nothing comes out on the plot. I feel like I'm missing out on something trivial (I apologize since I'm a new user). I could really use any help that I can get.

The dimensions of ωarr are wrong. You perhaps want to Flatten[ωarr,1].
ωarr // Dimensions

gives {101,11,3} while ListDensityPlot expects {1111,3}.
• Length of i and j do not need to be the same, but the dataset has to have 2 dimensions instead of 3. About the whitespace you should ask a new question after you have checked for existing answers in other topics. – Johu Mar 2 '18 at 9:31
• I think the whitespaces are there due to your definition of f and not due to plotting. – Johu Mar 2 '18 at 9:32
• I meant f actually gives you 0 for many values. – Johu Mar 2 '18 at 9:40
• you must Flatten[ warr , 1]` The one here is important so that you just flatten by one list level. – george2079 Mar 2 '18 at 14:36