This question already has an answer here:

I have an equation and I want to solve it with FindRoot but is there any way to give a range to FindRoot instead of giving a point? this is my MMA code:

uvariable3 = 
u /. FindRoot[(1/(1/u^2 + 1/(v^2 - u^2)))*((
    BesselJ[m - 1, u] - BesselJ[m + 1, u])/(
      u]) + (BesselK[m - 1, Sqrt[v^2 - u^2]] + 
       BesselK[m + 1, Sqrt[v^2 - u^2]])/(-2*Sqrt[v^2 - u^2]*
       BesselK[m, u]))*((BesselJ[m - 1, u] - BesselJ[m + 1, u])/(
      u]) + ((n2/
       n1)^2*((BesselK[m - 1, Sqrt[v^2 - u^2]] + 
          BesselK[m + 1, Sqrt[v^2 - u^2]])/(-2*Sqrt[v^2 - u^2]*
          BesselK[m, u])))) - m^2/u^2 == 
   m^2*((n2/n1)^2*1/(v^2 - u^2)), {u, 1.5}]

and u is the only variable. I have the value for other variables.


marked as duplicate by Szabolcs, Henrik Schumacher, m_goldberg, mikado, Bob Hanlon Sep 11 '18 at 5:29

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.

  • $\begingroup$ Try NSolve: NSolve[{f[x] == g[x], xmin <= x <= xmax}, x]. If appropriate, you can also restrict the domain. $\endgroup$ – Bob Hanlon Sep 10 '18 at 12:57
  • $\begingroup$ Actually, NSolve does not give me any root. so I plotted the rhs and lhs and then by using this plot I give a point too FindRoot to find the root but I have more than one root and so I have to change the starting point to find all the roots $\endgroup$ – sara Sep 10 '18 at 13:23
  • 1
    $\begingroup$ Map FindRoot onto a list of starting points taken from the Plot: FindRoot[f[x] == g[x], {x, #}] & /@ pts $\endgroup$ – Bob Hanlon Sep 10 '18 at 13:28
  • 2
    $\begingroup$ Why didn't you publish your equation as MMA code? $\endgroup$ – Ulrich Neumann Sep 10 '18 at 13:33
  • $\begingroup$ Do you already know how FindRoot works (Newton's method) and why it gives you a single root only? $\endgroup$ – Szabolcs Sep 10 '18 at 13:58

From the documentation

FindRoot[lhs==rhs,{x, x_start,  x_min, x_max}] 

searches for a solution, stopping the search if x ever gets outside the range [x_min,x_max]

Have you tried this?

  • $\begingroup$ I tried it but it gave me exactly the x_start as the root of my equation $\endgroup$ – sara Sep 10 '18 at 13:25
  • $\begingroup$ Are you sure your function has a root in the range provided? If not, you can try and implement a method to extend the range until a root is found or try a different algorithm. $\endgroup$ – OldTomMorris Sep 11 '18 at 9:28
  • $\begingroup$ yes I'm sure because I made the plot of f==g and there are some intersections $\endgroup$ – sara Sep 17 '18 at 7:39

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