On matlab I want to solve numerically and plot this ode on $x\in [0,1]$ $$ g''(x)h(x)+g(x)(1-g(x)) = 0 $$ With (assume the 2 conditions) $a,b\in \mathbb R,\ g(0.5)=a$ and $g'(0.5)=b$ and where $h$ is given by $$ h(x) = \frac{1}{2\pi}e^{{-(\phi^{-1}(x)})^2} $$ and $\phi^{-1}$ is the inverse gaussian cumulative distribution.
On matlab it exists the function norminv for $\phi^{-1}$ (doc).
So I have to solve backwardly and forwardly the ODE (with an euler method for instance).
So as a beginner I have mainly 2 problems :
- I do not know how to use norminv (which is not a symbolic function) inside odevectorfield and ode45 etc
- How to tell to matlab to solve the ode backwardly (from $x=0.5$ to $x=0$) and forwardly (from $x=0.5$ to $x=1$)? and plot the final curve ?
- does my below code is a good way to solve numerically and plot this ODE ? or do I have to use other packages ? dsolve for instance ? If someone has a solution or a code or a closed example of what I want ?
my code (is just the idea of the algorithm) that does not work at all is :
syms x,h(x),y(x)
h(x) := 1./(2.*pi)*exp(-norminv(x)^2)%problem is norminv is not symbolic function
[V] = odeToVectorField(diff(y(x), 2) == y(x)*(y(x)-1.)./h(x))
M = matlabFunction(V,'vars', {'x','Y'})
sol = ode45(M,[0 1],[0.5 b]); %on x in[0, 1] and condition is g'(0.5)=b but problem is backwardly and forwardly is not specified to matlab.
plot(sol); %wrong since I have not specified on [0, 1]
But it does not work at all.
Extra informations :
For $\epsilon>0$ small, I have backwardly on from $0.5$ to $0$: $$ g(x-\epsilon) = g(x) - \epsilon g'(x)\\ g'(x-\epsilon) = g'(x) - \epsilon h^{-1}(x)g(x)(g(x)-1)\\ $$ And forwardly, for $\delta>0$ small from $0.5$ to $1$, $$ g(x+\delta) = g(x) + \delta g'(x)\\ g'(x+\delta) = g'(x) + \delta h^{-1}(x)g(x)(g(x)-1)\\ $$
Something along these lines, as @Ian suggested?