1

I could use some guidance in using Mathematica's NDSolve. I'm attempting to numerically uncover a cumulative distribution function (CDF), $F(p)$, with density $f(p)$ from a first order condition, which is defined as: $$ \int_{\underline{p}}^p g_1(y)f(y)dy+\int_p^{\overline{p}} g_2(y)f(y)dy+g_3(p)f(p)=0 $$ where $g_1(p)$, $g_2(p)$, and $g_3(p)$ are shown in the code I've tried below.

w = 1/8; z = 5/8;
upperp = (-1 + w^2 z^2 + Sqrt[-4 z (w + z - 2 w z) (1 + (-1 + w - w^2) z) + (-1 + 
  w^2 z^2)^2])/(2 z (-z + w (-1 + 2 z)));
lowerp = w;

g1[p_?NumericQ, y_?NumericQ] := (5 y (-8 + 5 y))/(8 - 5 p y)^2

g2[p_?NumericQ, y_?NumericQ] := (50 (-1 + p) (44 + 5 p (-4 + y) - 20 y) y)/((8 - 5 p)^2 (8 - 5 p y)^2)

g3[p_?NumericQ] := (15 (-1 + p) p)/((-8 + 5 p) (-8 + 5 p^2))

i1[p_?NumericQ] := i1[p] = NIntegrate[g1[p, y] f'[y], {y, lowerp, p}]

i2[p_?NumericQ] := i2[p] = NIntegrate[g2[p, y] f'[y], {y, p, upperp}]

i3[p_?NumericQ] := i3[p] = g3[p] f'[p]

NDSolve[{i1[p] + i2[p] + i3[p] == 0, f[w] == 0}, f, {p, lowerp, upperp}]

From this code I get the error:

NIntegrate::inumr: "The integrand ... has evaluated to non-numerical values for all sampling points in the region with boundaries..."

Any advice on Mathematica's ability to solve this problem would be greatly appreciated.

eyorble
  • 9,383
  • 1
  • 23
  • 37
J.R.
  • 11
  • 1
  • ?NumericQ is not a catholicon, using it blindly won't help. 2. Seems that the equation only has a trivial solution: i1[p] + i2[p] + i3[p] == 0 /. f' -> (0 &)
  • – xzczd Dec 31 '17 at 04:42
  • 1
    You try to solve an integral-equation, which exceeds in my opinion the ability of NDSolve. The error occurs, because MMA cannot handle f'[y] inside NIntegrate! (MMA version 11.0.1) – Ulrich Neumann Dec 31 '17 at 12:40
  • Thanks @xzczd for taking the time to read my post. Can you explain what you mean when you say using ?NumericQ blindly won't help? I'm new to using Mathematica this way and could use some helpful nudging. – J.R. Dec 31 '17 at 22:33
  • Thanks @UlrichNeumann for taking the time to read my post. Can you help me understand why NIntegrate doesn't handle f'[y] in my case? Is there a better way? I'm new to using Mathematica this way and could use some helpful nudging. – J.R. Dec 31 '17 at 22:34
  • ?NumericQ simply doesn't help in your case, to learn its usage, check this post. As pointed out by @UlrichNeumann , the main problem here is NDSolve can't handle this problem, so we need to code our own solver, here is an example. (The discussion is in Chinese, but you can at least read the code. ) Nevertheless, as mentioned in my last comment, your equation only has a trivial answer f'[p]==0. – xzczd Jan 01 '18 at 06:07
  • Thank you so much, @xzczd - really appreciate your help. – J.R. Jan 01 '18 at 22:44