# Want a DiscretePlot of an NSolve that uses a parameter n

Let's say I want to solve f[n,R]==0 with respect to R for n=1,2,3,... (up to some upper bound) and put this in a DiscretePlot or something equivalent. Reading this question, I decided to try

DiscretePlot[R /. NSolve[R*(R + 2)/(1 + R) == n && R > 0, R], {n, 1, 20}]

as an experiment, which worked with no errors. But then when I try my example,

DiscretePlot[R /. NSolve[Gamma[n/2, R^2] == 0.5 Gamma[n/2] && R > 0, R], {n, 1, 20}]

a ton of errors are thrown in between some time elapses, then an empty graph appears. For comparison, NSolve[Gamma[20/2, R^2] == Gamma[20/2] && R > 0, R] throws up a single error yet outputs {{R -> 3.10946}} in a fraction of a second.

How come the inputs for my situation aren't working even though the inputs for the other example are, and how do I fix it?

• What version are you using? DiscretePlot[R /. NSolve[Gamma[n/2, R^2] == 0.5 Gamma[n/2] && R > 0, R], {n, 1, 20}] executes successfully with v12.1.1, 12.2, 12.3, and 12.3.1; I experienced problems with v12.0 Nov 10 '21 at 3:12
• Well that sucks. I'm using v12.0.0 Nov 10 '21 at 3:14

With v12.0 use FindRoot rather than NSolve

Clear["Global*"]

\$Version

(* "12.0.0 for Mac OS X x86 (64-bit) (April 7, 2019)" *)

DiscretePlot[
R /. FindRoot[Gamma[n/2, R^2] == 1/2 Gamma[n/2], {R, (n + 9)/10}],
{n, 1, 20}]


• Thanks this works. Nov 10 '21 at 3:36
• An alternativ workaround for v12.0 is sol[n_?NumericQ] := R /. NSolve[Gamma[n/2, R^2] == 0.5 Gamma[n/2] && R > 0, R][[1, 1]]; DiscretePlot[sol[n ], {n, 1, 20}]` Nov 10 '21 at 10:08