# Plotting roots of a non polynomial function

I'd like to plot the solutions of a function f(y)=k, when f(y) is non polynomial. This is the Mathematica script I have produced so far:

P = 1; a = 1;
f[y_] = ArcCos[P*Sin[Sqrt[y]*a]/(Sqrt[y]*a) + Cos[Sqrt[y]*a]]/a ;

roots[k_?NumericQ] := FindRoot[f[y] == k, {y, 0.1, 0.5}];

dataRoots = {roots[#], #} & /@ Range[0.01, \[Pi]/a, 0.01];

Show[ListPlot[dataRoots, PlotStyle -> {Red, PointSize[0.02]}]]


Where I have provided two starting (trial) values for y, 0.1 and 0.5. The problem is that the resulting plot is empty. Is there any smarter way to easily find and plot the roots?

• Your function has complex values in that interval. – b.gates.you.know.what Jun 5 at 12:45

Try ContourPlot
ContourPlot[k == f[y], {y, 0, 4}, {k, -1, 1}, FrameLabel -> {y,k}] • @ cipper: Because f[y]>0 there exists no negative solution k! – Ulrich Neumann Jun 5 at 13:56
• you are right (duh!), I must put f[y] == Abs[k] to show the full plot. Thank you again. – cipper Jun 5 at 14:00