I am trying to plot $J_m(\chi_{mn} r) \cos(m\phi),$ where $J_m(\chi_{mn}) =0,$ as a DensityPlot
in polar coordinates (solution to 2D wave equation in polar coordinates). First, some definitions
besselzero = N@Table[BesselJZero[l, n], {l, 0, 25}, {n, 1, 25}];
bzeros[l_, n_] := besselzero[[l + 1, n]];
for speed purposes.
For the purposes of this question consider $m=3$ (but there's essentially the same problem for any $m$):
DensityPlot[
Cos[3 ArcTan[y/x] ] BesselJ[3, bzeros[3,1]Sqrt[x^2+y^2]],{x,-1,1},{y,-1,1},
Epilog->{Thick,Circle[]},PlotRange->{-1,1},
RegionFunction->Function[{x,y,z},Norm[{x,y}]<1.]]
This is nearly right, except that the sign on the left-hand side ($y<0$) of the plot is wrong (it should not be mirror symmetric around $y=0$, rather continue alternating positive and negative after each $\Delta\phi=\pi/3$).
Looking at the Plot3D
of ArcTan[y/x]
I realized the cause of the problem was because of how ArcTan
is defined, so I tried a workaround:
DensityPlot[
Cos[3 Piecewise[{{0, x > 0 && y == 0}, {π/2,
x == 0 && y > 0}, {(3 π)/2, x == 0 && y < 0}, {(2 π)/2,
x < 0 && y == 0}, {ArcTan[y/x],
x > 0 && y > 0}, {ArcTan[y/x] + π,
x < 0 && y > 0}, {ArcTan[y/x] + π,
x < 0 && y < 0}, {ArcTan[y/x] + 2 π,
x > 0 && y < 0}}] ] BesselJ[3,
bzeros[3, 1] Sqrt[x^2 + y^2]], {x, -1, 1}, {y, -1, 1},
Epilog -> {Thick, Circle[]}, PlotRange -> {-1, 1},
RegionFunction -> Function[{x, y, z}, Norm[{x, y}] < 1.]]
This is nearly right, except for those white regions. Is there a better way to plot functions of this sort?