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.
?NumericQis 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 &)?NumericQsimply doesn't help in your case, to learn its usage, check this post. As pointed out by @UlrichNeumann , the main problem here isNDSolvecan'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 answerf'[p]==0. – xzczd Jan 01 '18 at 06:07