2
$\begingroup$

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

enter image description here

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

enter image description here

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

enter image description here

$\endgroup$
  • $\begingroup$ 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 $\endgroup$ – bukwyrm May 17 '18 at 7:49
  • $\begingroup$ @Bill I've updated my question. Intermediate variables have not changed anything. $\endgroup$ – Ark-kun May 17 '18 at 8:11
  • $\begingroup$ @bukwyrm I've updated and clarified my question. $\endgroup$ – Ark-kun May 17 '18 at 8:15
  • $\begingroup$ 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. $\endgroup$ – Henrik Schumacher May 17 '18 at 8:17
1
$\begingroup$

Try

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

enter image description here

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

enter image description here

the smooth plot ends at n~170

$\endgroup$
  • $\begingroup$ Ulrich, the discontinuities only appear in the range $n \in [80,200]$ or so. So, they cannot appear in your plot. $\endgroup$ – Henrik Schumacher May 17 '18 at 9:56
  • $\begingroup$ 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 $\endgroup$ – Ulrich Neumann May 17 '18 at 10:20
1
$\begingroup$

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]

enter image description here

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

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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