# Plot of partial derivative looks wrong and does not match the surface plot of the function

I have a function and I'm using Wolfram Cloud to analyze it.

F[p_, n_] := InverseBetaRegularized[0.1, p*n + 1, (1 - p)*n + 1]


When I plot the function, it looks very similar to F[p_, n_] := p for large values of n.

Plot3D[F[p, n], {p, 0, 1}, {n, 1, 1000}]


Now I try to find partial derivative at p=0:

dFdp[p_, n_] := D[F[p, n], p]

dFdpAtP0[n_] := ReplaceAll[dFdp[p, n], {p -> 0}]


From the 3D plot, these derivatives should be very close to 1.

Yet, I get very different plot:

Plot[dFdpAtP0[n], {n, 1, 1000}]


There are several problems with this plot: It's not continuous, not monotonic and not close to 1.

I'm not very experienced with Wolfram or Mathematica. What's the problem with the derivative plot?

P.S.

dFdpAtP0[n] =


• Can you plot myF in the same section? You have the derivative of myF at p=0 for n from one to 1000, which would be a cut in your 3D plot running from the left frontal corner to the left backwards corner - i'd expect the derivative to be 0 tbh. "along the p-axis" i would expect to mean n=0 (or some other constant up to 1000) and p=0 to 1 May 17, 2018 at 7:49
• @Bill I've updated my question. Intermediate variables have not changed anything. May 17, 2018 at 8:11
• @bukwyrm I've updated and clarified my question. May 17, 2018 at 8:15
• Maybe there is some jumping between branches of the logarithm or of any of the special functions is involved... Might be an indication for a bug. May 17, 2018 at 8:17

Try

Plot3D[Derivative[1, 0][F][p, n], {p, 0, 1}, {n, 1, 10}]


Thereby I redused the range of n because the evaluation time...

For p=0

Plot[Derivative[1, 0][F][.0, n],  {n, 1, 1000}, PlotRange -> {0, 1}]


the smooth plot ends at n~170

• Ulrich, the discontinuities only appear in the range $n \in [80,200]$ or so. So, they cannot appear in your plot. May 17, 2018 at 9:56
• Henrik, thank you for your hint. I edited my answer, the derivative for p=0 looks smooth in the range 1<n<170. Outside the derivative seems to be undefined May 17, 2018 at 10:20

This is mainly a problem of precision.

Allow as much extra precision as possible \$MaxExtraPrecision = Infinity and use 1/10 instead of 0.1 in function definition.

Even then Plot can't do the job up to n==1000; do it with Table .

But I noticed, even Table suceeds only in reasonalble time, when n are even numbers. Don't know why.

tab = Table[{p, n, Derivative[1, 0][F][p, n]}, {p, 0, 1, 1/20}, {n, 0,
1000, 40}] // N[#, 8] &

tab2 = Table[{p, n, Derivative[1, 0][F][p, n]}, {p, 0, 1, 1/20}, {n,
0, 20, 4}] // N[#, 8] &


I splitted it up to get better resolution at low n. // N[#, 8] & forces exact evaluation, simply //N won't do it.

ListPlot3D[Flatten[Join[tab, tab2], 1], PlotRange -> All]


Plot[Derivative[1, 0][F][0, n], {n, 1, 1000}, PlotRange -> {0, .4}]