# Numerically Approximating Solutions to Differential Equation

I'm trying to numerically approximate solutions to a messy differential equation, given below $$(1-\alpha \frac{1}{\pi^{'}(s_2)})(s_2-\pi(s_2)+\frac{\beta}{2}\pi(s_2)-\frac{\alpha\beta}{2}s_2)+(p-\alpha s_2)(-1+\frac{\beta}{2}-\frac{\alpha\beta}{2\pi^{'}(s_2)})=0$$ and. I want to understand how the solution $$\pi(s_2)$$ changes as we change $$\alpha$$ and $$\beta$$ and what forms such solutions will take. The initial condition is given by $$\pi(1)=1$$, however I am open to investigating other boundary conditions that aren't $$\pi(0)=0$$. However Mathematica does not give any output and I'm not sure why. My code is given below.

DSolve[{-(p[s2]-a s2)+(s2-p[s2])(1-a/(p'[s2]))+b(p[s2]-a s2)(1-a/(p'[s2]))==0,p[1]==1},p[s2],s2] Manipulate[NSolve[-FractionBox[RowBox[{RowBox[{RowBox[{"(", RowBox[{RowBox[{"-", "1"}], "+", "a"}], ")"}], " ", RowBox[{"Log", "[", RowBox[{RowBox[{"-", "a"}], "+", FractionBox[RowBox[{"p", "[", "s2", "]"}], "s2"]}], "]"}]}], "+", RowBox[{"a", " ", RowBox[{"Log", "[", RowBox[{"1", "-", RowBox[{"a", " ", "b"}], "+", FractionBox[RowBox[{RowBox[{"(", RowBox[{RowBox[{"-", "2"}], "+", "b"}], ")"}], " ", RowBox[{"p", "[", "s2", "]"}]}], "s2"]}], "]"}]}]}], RowBox[{RowBox[{"-", "1"}], "+", RowBox[{"2", " ", "a"}]}]]\[Equal]FractionBox[RowBox[{RowBox[{"Log", "[", RowBox[{"1", "-", "a"}], "]"}], "-", RowBox[{"a", " ", RowBox[{"Log", "[", RowBox[{"1", "-", "a"}], "]"}]}], "-", RowBox[{"a", " ", RowBox[{"Log", "[", RowBox[{RowBox[{"-", "1"}], "+", "b", "-", RowBox[{"a", " ", "b"}]}], "]"}]}]}], RowBox[{RowBox[{"-", "1"}], "+", RowBox[{"2", " ", "a"}]}]]+Log[s2],p[s2]],{a,-1,1,.1},{s2,0,1,.1},{b,-1,1,0.1}]

• You can format inline code and code blocks by selecting the code and clicking the {} button above the edit window. The edit window help button ? is useful for learning how to format your questions and answers. You may also find the meta Q&A, How to copy code from Mathematica so it looks good on this site, helpful Mar 11 at 20:40
• Your code has serious problems - what is this  doing in there? Apr 10 at 20:05
• You want to solve a differential equation numerically...so have you tried NDSolve? Apr 10 at 23:35

## 1 Answer

There are still parameter values where no solution is found, but at least we get some results, although it can take some time.:

First s2==0 and a==1 are not allowed and we can simplify by multiplying by (2a-1). Then we replace the variable p[s2] by p. Finally we use FindInstance instead NSolve :

Manipulate[
FindInstance[-(-1 + a) Log[-a + p/s2] +
a Log[1 - a b + ((-2 + b) p)/s2] ==
Log[1 - a] - a Log[1 - a] - a Log[-1 + b - a b] +
Log[s2] (-1 + 2 a), p], {a, -1, 1, .1}, {s2, 0.001,
0.999, .1}, {b, -1, 1, 0.1}]