# Multiple Roots of Spheroidal Function

I am trying to compute multiple roots of a spheroidal Function (SpheroidalS1). At first, I define function RootsInRange which evaluates roots within a given interval and then try to find SpheroidalS1's roots using RootsInRange. Finally, I use those roots to define another variable AnalyticalFrequencies. Here's my code:

RootsInRange[δ_, {λ_, λmin_, λmax_}, opts___] :=
Module[{p, pts, x, f = Function[λ, Evaluate[δ]]},
p = Plot[f[λ], {λ, λmin, λmax}];
pts = Cases[First[p], Line[{x__}] -> x, Infinity];
pts = Map[First,
Select[Split[pts, Sign[Last[#2]] == -Sign[Last[#1]] &],
Length[#1] == 2 &], {2}]; (FindRoot[
f[λ] == 0, {λ, ##1}] &) /@ pts]

(*Define ellipsoid and then compute its spheroidal function's roots*)
t = 1.25; d = t^(-1/3) Sqrt[t^2 - 1]; ξ0 = t/Sqrt[t^2 - 1];
KD = Table[{N[
kd /. RootsInRange[
Re[SpheroidalS1[1, n, kd, ξ0]], {kd, 0, 60},
WorkingPrecision -> 5], 60]}, {n, 1, 10}];

(*Analytical Frequencies*)
AnalyticalFrequencies = 3*(10^8)*KD/(2*Pi*d) // N  // MatrixForm


However, while this is a working code, it tends to be very slow. How can we make root finding faster? Is there any other algorithm? Something else that we can do?

• Missing a semicolon in the middle of the third line from the bottom? – John Doty Nov 1 '16 at 20:13
• You are right but that doesn't seem to solve my problem yet – George Giannoulis Nov 1 '16 at 20:16
• You haven't defined FilterOptions – Feyre Nov 1 '16 at 20:17
• I 'am sorry but I didn't understand what you mean. Could you be more specidfic please? – George Giannoulis Nov 1 '16 at 20:20
• What is FilterOptions supposed to be? As far as I can see it's not a built in function. – Feyre Nov 1 '16 at 20:22