# Plot FindRoot for non-trivial function

I would like to plot the results of FindRoot over certain range of inputs. I tried to do this with the code:

Plot[Evaluate[FindRoot[f[m, b], {m, 1}][[1, 2]]], {b, 0,2}]


where I want to plot the roots of f[m,b] vs. b ranging over [0,2]. I'm not sure this code is working, because although I do get a plot, I also get this error:

FindRoot::nlnum: "The function value {1.[VeryThinSpace]-(2.\Gamma[2.,0.,(1.[VeryThinSpace]+1. b)/Sqrt[b]])/(1.[VeryThinSpace]+1.\b)}\n is not a list of numbers with dimensions {1} at {m} = {1.}."

Note the function I'm trying to find the roots for is:

f[M_, b_] := 1 - (2 M Gamma[2, 0, (1/M + b M)/Sqrt[b]])/(1/M + b M)


Thanks!

• You can also remove Evaluate. The FindRoot won't be evaluated until a number for b is plugged in. May 27, 2013 at 14:38

## 1 Answer

Define in addition the function

g[b_?NumericQ] := FindRoot[f[m, b], {m, 1}][[1, 2]]


and then make the Plot for this one:

Plot[g[b], {b, 0, 2}]
`

• Thanks, I had come up with a way of doing it using Do and ListPlot but this is much nicer.
– misi
Apr 18, 2013 at 23:18