# Finding roots of a function that includes Bessel functions [duplicate]

I'm fairly new to Mathematica so forgive any stupid mistakes. Here's my function:

x = 3;
f[b_] := BesselY[1, b] BesselJ[1, b x] - BesselJ[1, b] BesselY[1, b x] == 0


Not too ugly. I'm trying to use the findAllRoots function created by the user Jens seen here: Find all roots of an interpolating function (solution to a differential equation)

With this as my input:

findAllRoots[f[b], {b, 0, 10}, "ShowPlot" -> True]


I get the correct graph but then a mess of error messages and an unfinished output:

FindRoot::nlnum: The function value {False} is not a list of numbers with dimensions {1} at {x$1716} = {1.63463}. >> FindRoot::nlnum: The function value {False} is not a list of numbers with dimensions {1} at {x$1716} = {3.16008}. >>
FindRoot::nlnum: The function value {False} is not a list of numbers with dimensions {1} at {x$1716} = {4.72677}. >> General::stop: Further output of FindRoot::nlnum will be suppressed during this calculation. >> ReplaceAll::reps: {FindRoot[localFunction$1716==0,{x$1716,1.63463,1.63769}],FindRoot[localFunction$1716==0,{x$1716,3.16008,3.26471}],FindRoot[localFunction$1716==0,{x$1716,4.72677,4.75158}],FindRoot[localFunction$1716==0,{x$1716,6.1217,6.33371}],FindRoot[localFunction$1716==0,{x$1716,7.73927,7.95071}],FindRoot[localFunction$1716==0,{x$1716,9.3727,9.58357}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >> FindRoot::fdssnv: Search specification {} without variables should be a list with 1 to 4 elements. >> FindRoot::fdssnv: Search specification {} without variables should be a list with 1 to 4 elements. >> FindRoot::fdssnv: Search specification {} without variables should be a list with 1 to 4 elements. >> General::stop: Further output of FindRoot::fdssnv will be suppressed during this calculation. >> ReplaceAll::reps: {FindRoot[localFunction$1716==0,{{},1.63463,1.63769}],FindRoot[localFunction$1716==0,{{},3.16008,3.26471}],FindRoot[localFunction$1716==0,{{},4.72677,4.75158}],FindRoot[localFunction$1716==0,{{},6.1217,6.33371}],FindRoot[localFunction$1716==0,{{},7.73927,7.95071}],FindRoot[localFunction$1716==0,{{},9.3727,9.58357}]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing. >>  Output: {} /. {FindRoot[localFunction$1716 == 0, {{}, 1.63463, 1.63769}],
FindRoot[localFunction$1716 == 0, {{}, 3.16008, 3.26471}], FindRoot[localFunction$1716 == 0, {{}, 4.72677, 4.75158}],
FindRoot[localFunction$1716 == 0, {{}, 6.1217, 6.33371}], FindRoot[localFunction$1716 == 0, {{}, 7.73927, 7.95071}],
FindRoot[localFunction\$1716 == 0, {{}, 9.3727, 9.58357}]}

• Have you tried any of the solutions here? – J. M.'s ennui Apr 9 '16 at 9:08

x = 3;
f[b_] = BesselY[1, b] BesselJ[1, b x] - BesselJ[1, b] BesselY[1, b x] ;
FindInstance[{f[b]==0, 0 <= b <= 10}, b, Reals, 7] sol = b /. % // N
(* {1.63562, 3.17884, 4.73809, 6.30272, 7.86971, 9.43793} *)


There are only 6 real roots. You also can do it with Solve or Reduce:

Solve[{f[b]==0, 0 <= b <= 10}, b, Reals]

Plot[f[b], {b, 0, 10},
Epilog -> {Red, PointSize[Large], Point[{#, f[#]} & /@ sol]}, PlotRange -> All] • Neither Solve nor FindInstance worked: "The methods available to FindInstance are insufficient to find the requested instances or prove they do not exist." "This system cannot be solved with the methods available to Solve." – Sean Kelso Apr 16 '16 at 6:22
• @ Sean Kelso All works fine with Mathematica 10.4 on Windows 10 (64 bit). – user36273 Apr 16 '16 at 8:21

You're not going to be able to find all the roots, because there are an infinite number of them. But you can use FindRoot directly to find any subset within a range.

x = 3;
eqn = BesselY[1, b] BesselJ[1, b x] - BesselJ[1, b] BesselY[1, b x] == 0;
sol = FindRoot[eqn, {b, #}] & /@ Range


Here are the first few:

Sort[DeleteDuplicates[sol[[All, 1, 2]], Abs[#1 - #2] < 0.01 &]]

{1.63562, 3.17884, 4.73809, 6.30272, 7.86971, 9.43793, 11.0069, 12.5763,
14.146, 15.7159, 17.286, 18.8562, 20.4265}