0

I'm looking for solutions of the equation $1/\omega + \tan(k/\omega)=0$, and for some reason ContourPlot is missing a bunch of roots.

ContourPlot[1/ω + Tan[k/ω] == 0, {k, 0, 10}, {ω, 0, 1},
 PlotPoints -> 10, FrameLabel -> {"k", "ω"}]

ContourPlot with abrupt line ends

Each of the branches should continue down towards $\omega=0$. Increasing PlotPoints makes no difference.

NSolve works fine at a set value of $\omega$:

k /. NSolve[{(1/ω + Tan[k/ω]) /. ω -> 0.2, 0 <= k <= 10}, k]
(* {0.353638, 0.981957, 1.61028, 2.23859, 2.86691, 3.49523, 4.12355, 4.75187, 5.38019, 
   6.00851, 6.63682, 7.26514, 7.89346, 8.52178, 9.1501, 9.77842} *)

Putting these points on you can see that there are roots missing:

enter image description here

I'm able to manually make a table and build the plot myself, but just want to know why ContourPlot fails so badly here.

SPPearce
  • 5,653
  • 2
  • 18
  • 40

1 Answers1

2

You could use NDSolveValue instead to find solutions to your equation. For example:

eqn[k_] = 1/ω[k]+Tan[k/ω[k]] == 0;
ω1 = ω[1] /. NSolve[eqn[1] && 0<ω[1]<1, ω[1]]

{0.00363778, 0.00416084, 0.00464676, 0.00534959, 0.00544103, 0.00606282, \ 0.00618054, 0.00670096, 0.00699548, 0.00766967, 0.00785902, 0.00805795, \ 0.00826722, 0.00848765, 0.00872016, 0.00896575, 0.00922559, 0.00950093, \ 0.00979321, 0.010104, 0.0104353, 0.0107889, 0.0111674, 0.0115734, 0.01201, \ 0.0124808, 0.01299, 0.0135426, 0.0141443, 0.0148019, 0.0155236, 0.0163192, \ 0.0172008, 0.0181831, 0.0192843, 0.0205275, 0.0219418, 0.0235654, 0.0254483, \ 0.027658, 0.0302874, 0.0334688, 0.0373959, 0.0423652, 0.048854, 0.0576822, \ 0.0703857, 0.0902076, 0.125334, 0.203534, 0.492912}

With an equation and initial values, we can use NDSolveValue:

sol = NDSolveValue[{eqn'[k], ω[1]==ω1}, ω, {k,0,10}];

Visualization:

Plot[sol[k], {k,0,10}]

enter image description here

Carl Woll
  • 130,679
  • 6
  • 243
  • 355