Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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)


share|improve this question
You can also remove Evaluate. The FindRoot won't be evaluated until a number for b is plugged in. – Michael E2 May 27 '13 at 14:38
up vote 4 down vote accepted

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}]

enter image description here

share|improve this answer
Thanks, I had come up with a way of doing it using Do and ListPlot but this is much nicer. – misi Apr 18 '13 at 23:18

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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