2
$\begingroup$

This question already has an answer here:

I'm pretty new at using Mathematica, so I sometimes find errors in stuff so simple I can't seem to find where the error is.

I've been trying to solve a trascendental equation that involves a number of Bessel's functions, and I can't seem to find why it doesn't work.

Here it goes.

a = 0.889;
b = 2.946;
Er = 2.2;

f[x_, n_] := BesselJ[n, a*x] BesselY[n, b*x] - BesselJ[n, b*x] BesselY[n, a*x];
NSolve[f[x, 0] == 0, x];

Has it something to do with it being an infinite number of solutions, or something like that?

Thanks in advance.

PD : I tried giving it an interval as march suggested, but I got an error I don't understand. What does it mean?

Solve::ratnz: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result. >>

$\endgroup$

marked as duplicate by march, MarcoB, happy fish, Yves Klett, Feyre Oct 19 '16 at 12:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    $\begingroup$ Yes. You could also use FindRoot, but if you specify an interval: NSolve[f[x, 0] == 0 && x \[Element] Interval[{0, 5}], x] gives you three solutions. $\endgroup$ – march Oct 18 '16 at 18:14
  • $\begingroup$ Thanks! Tried that and got the three solutions that you said, but it gives me also an error I don't fully understand. I'll edit the question to add that. $\endgroup$ – The Cloak Oct 18 '16 at 18:27
  • $\begingroup$ Welcome! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Take the tour and check the faqs! 3) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! $\endgroup$ – user9660 Oct 18 '16 at 18:36
  • $\begingroup$ Oh, thanks! I didn't know that. I'll do that! $\endgroup$ – The Cloak Oct 18 '16 at 18:39
  • 4
    $\begingroup$ @corey979. Hmmm. NSolve gave me three solutions in the interval. Really, I don't think NSolve is the right thing to use here anyway, for exactly these kinds of difficulties. By the way, TheCloak, the error it's spitting out is due to the fact that you have a transcendental equation, and NSolve is not in general designed to solve those. I suggest looking at this Q&A, which I think I will propose as a duplicate. $\endgroup$ – march Oct 18 '16 at 19:00
2
$\begingroup$
a = 0.889 // Rationalize;
b = 2.946 // Rationalize;
Er = 2.2 // Rationalize;

f[x_, n_] := 
  BesselJ[n, a*x] BesselY[n, b*x] - BesselJ[n, b*x] BesselY[n, a*x];

roots = (x /. Solve[{f[x, 0] == 0, 0 <= x <= 5}, x])[[All, 1, -1]]

enter image description here

(*  {1.50177384329388181009156654340, 
     3.04000268689460168628592657359,
     4.57176009090372974335375245063}  *)

Plotting f[x,0] shows that there are only three roots in the interval so the warning is not important.

Plot[f[x, 0], {x, 0, 5},
 Epilog -> {Red, AbsolutePointSize[6],
   Point[{#, 0} & /@ roots]}]

enter image description here

$\endgroup$
2
$\begingroup$
a = 0.889;
b = 2.946;
Er = 2.2;

f[x_, n_] := 
  BesselJ[n, a*x] BesselY[n, b*x] - BesselJ[n, b*x] BesselY[n, a*x];

With

$Version

"10.4.1 for Linux x86 (64-bit) (April 11, 2016)"

I obtain only two solutions in the interval $(0,5)$ using NSolve - I'm missing the 3.04 solution.

On the other hand, this works well:

FindInstance[f[x, 0] == 0 && x \[Element] Interval[{0, 5}], x, 3]

{{x -> {1.50177}}, {x -> {3.04}}, {x -> {4.57176}}}

When I try to find more instances than there are solutions in the interval, I find just the three and receive a warning:

FindInstance::incs: Warning: FindInstance was unable to prove that the solution set found is complete.

Hence, as a crude way of finding the solutions, one can either keep changing the number of instances to be found until the warning occurs, or just give a number high enough to exceed the number of solutions. E.g., this

FindInstance[f[x, 0] == 0 && x \[Element] Interval[{0, 15}], x, 15]

finds nine solutions:

{{x -> {1.50177}}, {x -> {3.04}}, {x -> {4.57176}}, {x -> {6.10143}}, {x -> {7.63018}}, {x -> {9.15846}}, {x -> {10.6865}}, {x -> {12.2143}}, {x -> {13.742}}}

enter image description here

while NSolve only 5.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.