# NSolve missing solutions

I'm having trouble solving the transcendental equation. For some values ​​of bi, NSolve obtains 6 roots, however when changing the value, it obtains 5. Graphing the function clearly shows that the root that is missing exists and is in the interval between 10 and 11.

This is the code running all the roots correctly

bi=0.515625;
g[β_]:=(β*BesselJ[1, β])-(bi*BesselJ[0,β]);
roots=(β/.NSolve[{g[β]==0,0<=β<=18},β])
Plot[g[β], {β, 0, 18}, PlotRange -> {-5, 5},
Epilog -> {Red, AbsolutePointSize[6], Point[{#, 0} & /@ roots]}]


And this is the same code with another bi value

bi=1.27188;
g[β_]:=(β*BesselJ[1, β])-(bi*BesselJ[0,β]);
roots=(β/.NSolve[{g[β]==0,0<=β<=18},β])
Plot[g[β], {β, 0, 18}, PlotRange -> {-5, 5},
Epilog -> {Red, AbsolutePointSize[6], Point[{#, 0} & /@ roots]}]

• I think you should report this as a bug to support. As a workaround, you could use Solve[...] //N instead. Apr 8, 2021 at 18:42
• Solve shows the same bug! Apr 8, 2021 at 18:44

## 1 Answer

Clear["Global*"]


Functions should use explicit arguments for all variables.

g[bi_, β_] := (β*BesselJ[1, β]) - (bi*BesselJ[0, β]);


A function that uses a numeric technique (e.g., NSolve) should use SetDelayed rather than Set and have its arguments restricted to numeric values.

EDIT: Used Rationalize on argument and used Solve rather than NSolve

roots[bi_?NumericQ] := Module[{bir = Rationalize[bi, 0]},
β /. Solve[{g[bir, β] == 0, 0 <= β <= 18}, β] //
Quiet]

roots[0.515625] // N

(* {0.953584, 3.96325, 7.08857, 10.224, 13.3623, 16.5019} *)

Plot[g[#, β], {β, 0, 18},
PlotRange -> {-5, 5},
PlotLabel -> StringForm["bi = ", #],
Epilog -> {Red, AbsolutePointSize[6],
Point[{#, 0} & /@ roots[#]]},
ImageSize -> 300] & /@
{0.515625, 1.27188} // Column


• Do I miss something? This simply shows the bug again. And it does not only happen with the numeric NDSolve but also with Solve`. Apr 8, 2021 at 18:44
• @DanielHuber - I wasn't paying attention. Corrected error. Apr 8, 2021 at 19:31