# RegionPlot shading the wrong region

f[k_, α_, N_] := Sum[Sin[k*m/2]^2/m^(1 + α), {m, 1, N}]

ContourPlot[(f[k, 1, 1000] - 2 A^2) == 0, {k, -π, π}, {A, 0,
2}, FrameLabel -> {"k", "A"}, PlotLegends -> Automatic]


I want to shade the region above each of the two curves shown below using RegionPlot. To do this, I tried:

RegionPlot[(f[k, 1, 1000] - 2 A^2) < 0 , {k, -π, π}, {A, 0,
2}, FrameLabel -> {"k", "A"}, PlotLegends -> Automatic]


but this yields a region being shaded but does not have the "kink" part. Why?

• PlotPoints -> 80, MaxRecursion -> 4 can improve the plot. Commented Aug 26, 2023 at 1:27

We can use ContourPlot to do this.

ContourPlot[(f[k, 1, 1000] - 2 A^2), {k, -π, π}, {A, 0, 2},
FrameLabel -> {"k", "A"}, PlotLegends -> Automatic, Contours -> {0},


• Could you please explain how it works? e.g, what does "Contours ->{0}" do? Commented Aug 26, 2023 at 3:37
• @KZ-Spectra We can read the Contours in Mathematica documents. reference.wolfram.com/language/ref/Contours.html Contous can set the level sets and ContourShading can shading the level sets. Commented Aug 26, 2023 at 3:43

Using ListContourPlot:

expr = f[k, 1, 1000] - 2 A^2;
sty = {Style["k", Black, 14], Style["A", Black, 14]};

ListContourPlot[Transpose@Table[expr, {k, -π, π, π/10}, {A, 0, 2, 0.05}],
Contours -> {0}, FrameLabel -> sty, LabelStyle -> Directive[Black, Medium],
ColorFunction -> (If[# < 0, Darker[Blue, Abs[#]], Lighter[Cyan, #]] &),
ContourStyle -> Directive[Darker[Blue], Thickness[0.0025]]]