# Finding the roots of an equation and plotting them

ψn[n_, x_] := x SphericalBesselJ[n, x]
dψn[n_, x_] := ψn[n - 1, x] - n ψn[n, x]/x
Nn[n_, x_] := x SphericalBesselY[n, x]
dNn[n_, x_] := Nn[n - 1, x] - n Nn[n, x]/x
f[m_, n_, x_] := m ψn[n, m x] dNn[n, x] - Nn[n, x] dψn[n, m x] There is a root of f[Sqrt[9.8], 24, x] between 9.61677463456185765 and 9.61677463456185768. The Plot function can't give the right picture with a correct x region. What's the problem? How can I find it and how to Plot f in this interval?

• Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2) Read the faq! 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. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! – user9660 Mar 19 '15 at 7:25
• I think the tag 'findroot' should be removed since the question is solely about plotting. – Taiki Mar 19 '15 at 10:53

You would probably need to ask Mathematica to treat your numbers as arbitrary-precision numbers by tagging the number of digits you'd like Mathematica to keep track of at the end of your numbers like this:

9.6167746345618576520


This produces a plot:

Plot[
f[Sqrt[9.8], 24, x] 10^8,
{x, 9.6167746345618576520, 9.6167746345618576820}
]


In drawing the figure, the two endpoints of the $x$-axis will be treated as the same number if your \$MachinePrecision is not enough. (This is probably because Mathematica uses machine-precision numbers for the plot range.)

You may want to try ListPlot instead:

ListPlot[
Table[
f[Sqrt[9.8], 24, x] 10^8,
{x, 9.6167746345618576520, 9.6167746345618576820, 0.00000000000000000120}
],
Joined -> True,
PlotRange -> All
]


and modify the tick numbers with the option Ticks as appropriate (if DataRange doesn't work).

Note that 9.8 is a machine-precision number. You may want to think about whether that's what you want. Your f gives a different result when the number is inputted as 98/10—an exact number (i.e. Precision[98/10] is Infinity).