I am trying to find the positive solution to this nonlinear ODE. Theoretically, it has been proven that this problem has a unique positive solution for lam large. But, Mathematica can detect only the zero solution (zero is a solution for all lam's). Any techniques to detect the positive solution?

lam = 30;
sol = NDSolve[{-D[f[x], x, x] == lam*f[x]*(1 - f[x]), 
(D[f[x], x] /. x -> 1) == -Sqrt[lam]*0.1*f[1], (*first boundary condition*) 
(D[f[x], x] /. x -> 0) == Sqrt[lam]*0.1*f[0]}, (*second boundary condition*) 
f, {x, 0, 1}];
Plot[f[x] /. sol, {x, 0, 1}, AxesLabel -> {x, f}, LabelStyle -> Directive[Black, Bold, 12]]

1 Answer 1


Let us try a shooting method. The following code produces the solution for a given value of f[0]:

lam = 30;

We want to understand for which f[0] the boundary condition at x==1 is satisfied. This condition is that the following must be zero:


Let us plot this:


enter image description here

I picked the plot domain after some playing around. We see four values of f[0] where the condition at x==1 is also satisfied. I think the one OP asks for is the one on the very right, so let us see where it is:

(* 0.905557 *)

Plot the corresponding solution:

With[{s=sol[f0x]}, Plot[s[x],{x,0,1},AxesLabel->{"x","f[x]"}]]

enter image description here

It is everywhere positive. It is also not difficult to guess that this solution is symmetric, $f(x) = f(1-x)$, and a numerical check confirms this. No error or warning message was produced, so I am assuming we can trust the numerical evaluation. But of course, one should check.

Note. The above is a manual implementation of the shooting method. Actually NDSolve has a shooting method built in. To see how this works, see this tutorial. Here:


Let us use this to plot the four solutions mentioned above:


enter image description here

Note 2. The quantity 1/2*f'[x]^2+lam*(1/2*f[x]^2-1/3*f[x]^3) is independent of x for every solution.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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