-1

I have the following code:

    a = 200*10^-6;
    Subscript[n, s] = 1.456;
    k = (2*Pi)/\[Lambda];
    l = Round[2*Pi*a/(685*10^-9)];
    \[Beta] = Sqrt[l*(l + 1)]/a;
    \[Alpha] = Sqrt[\[Beta]^2 - k^2];
    F = (\[Alpha] + l/a)*SphericalBesselJ[l, k*Subscript[n, s]*a];
    G = k*Subscript[n, s]*SphericalBesselJ[l + 1, k*Subscript[n, s]*a];
    Plot[F - G, {\[Lambda], 680*10^-9, 690*10^-9}]

It yields an oscillating for a given parameter "a". I want to find all instances in which F=G within the interval in the plot and save the results in a list. I've tried all main root finder functions but none seem to work. How can I do that?

J. M.'s missing motivation
  • 124,525
  • 11
  • 401
  • 574
Rodrigo
  • 1,482
  • 9
  • 13

1 Answers1

0

As @Michael E2 pointed out in the comments, you can use NSolve.

MapThread[Set, {{a, ns, l, \[Beta]}, {200*10^-6, 1.456, Round[2*Pi*a/(685*10^-9)], Sqrt[l*(l + 1)]/a}}]
k[\[Lambda]_] := (2*Pi)/\[Lambda]
\[Alpha][\[Lambda]_] := Sqrt[\[Beta]^2 - k[\[Lambda]]^2]
F[\[Lambda]_] := (\[Alpha][\[Lambda]] + l/a)*SphericalBesselJ[l, k[\[Lambda]]*ns*a]
G[\[Lambda]_] := k[\[Lambda]]*ns*SphericalBesselJ[l + 1, k[\[Lambda]]*ns*a]
pts = {\[Lambda], 0} /. NSolve[F[\[Lambda]] == G[\[Lambda]] && 680*10^-9 < \[Lambda] < 690*10^-9, \[Lambda]]
Plot[
 F[\[Lambda]] - G[\[Lambda]],
 {\[Lambda], 680*10^-9, 690*10^-9}, 
 Epilog -> {PointSize[.03], Red, Point@pts}
]

{1/5000, 1.456, 1835, 30000 Sqrt[93585]}

{{6.85326*10^-7, 0}, {6.8643*10^-7, 0}, {6.87541*10^-7, 0}, {6.8866*10^-7, 0}, {6.89784*10^-7, 0}}

enter image description here

where the root solutions are

rootsolutions = pts[[;;,1]]
NonDairyNeutrino
  • 7,810
  • 1
  • 14
  • 29