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!
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}]
Comments
Post a Comment