# Solve second order non linear differential equation

4 views (last 30 days)
AJ on 9 Nov 2021
Commented: AJ on 10 Nov 2021
I need to solve F'' + F^2 -1/2pi = 0
Boundary conditons
F(0) = 0;
F(inf) = 1
I am new to using the ode solver in matlab and am not sure how to make it solve a non-linear SECOND order equation. Any suggestion would be appreciated.

Sulaymon Eshkabilov on 9 Nov 2021
You can try a builtin fcn: bvp4c(). Here is a nice documentation on bvp4c() with examples: https://www.mathworks.com/help/matlab/ref/bvp4c.html
John D'Errico on 9 Nov 2021
I don't think the bvpsolver can handle an infinite domain, since it uses collocation.

### More Answers (1)

John D'Errico on 9 Nov 2021
You will not be able to use bvp4c directly, since it will use collocation. That will fail on an infinite domain.
One option might be to use a finite domain, but one that is relatively large. So [0,Xmax] where Xmax is sufficiently far out that the solve has a chance to finish in a reasonable time, yet not that far out that numerical problems exist.
I did try dsolve, and it fails to find a solution, but that is not unexpected. My next suggestion is to use a transformation of the domain into a bounded domain. For example, you might try a transformation like
y = atan(x)
This maps the domain [0,inf] into [0,pi/2], which may be surprisingly a good idea, considering the equation at hand. You can see some ideas here on a similar problem:
But certainly other links exist where people explain how to transform such a problem into a finite domain.
AJ on 10 Nov 2021
Thank you!John! Your efforts are appreciated