I encountered the following ODE in order to find a solution for Einstein equation $$y''+f(x)y=g(x)y^3.$$ It seems to me that it is not among the solvable nonlinear second order differential equations. Is there any known method to solve that? Any help will be appreciated.

$\begingroup$ It is difficult to say something if you do not say anything on the structure of coefficients $f(x)$ and $g(x)$: could you say more on them? $\endgroup$ – Daniele Tampieri Jul 24 '19 at 6:03

5$\begingroup$ With $f$ and $g$ constant, this equation has exact solutions in terms of Jacobi elliptic functions. $\endgroup$ – Jon Jul 24 '19 at 6:14

$\begingroup$ The functions $f$ and $g$ are sufficiently smooth and not constant. $\endgroup$ – Masoud Jul 24 '19 at 6:31

4$\begingroup$ You can take $f,g\in\mathbb{R}$, excluding the trivial case $f=g=0$, and your solution, when $g\ne 0$ is expressed using the Jacobi function ${\rm sn}(x,k)$. Indeed, this equation is a definition of that function by itself. When $f$ and $g$ are not constant, you are in trouble to get a closed form solution unless for special cases or numerically. Already the linear case with $g(x)=0$ can be generally hard. Finally, a perturbative WKB approach could be helpful. $\endgroup$ – Jon Jul 24 '19 at 8:04
When $g(x) = 2$ (which can be achieved by a transformation in $x$) and $f(x)$ is linear in $x$, then this equation is a special case of the second Painlevé equation, which also appears in other areas of mathematical physics. It is known to be integrable by the isomonodromy method via its Lax representation and it has many other interesting properties.
While closedform solutions will be very rare, you can get series solutions. For example, the solution with $y(0)=0,\; y'(0)=v$ has Maclaurin series
$$ y = v x  \frac{f(0)}{6} v x^3  \frac{f'(0)}{12} v x^4 + \left(\frac{f(0)^2  3 f''(0)}{120} v + \frac{g(0)}{20} v^3 \right) x^5 + \ldots $$

1$\begingroup$ This is produced by the command of Maple dsolve({diff(y(x), x, x) + f(x)*y(x) = g(x)*y(x)^3, y(0) = 0, D(y)(0) = v}, y(x), series). $\endgroup$ – user64494 Jul 24 '19 at 13:11

The paper by Norbert Euler (1997) ``Transformation Properties of $\ddot{x}+f_1(t)\dot{x} + f_2(t)x + f_3(t) x^n = 0$" Journal of Nonlinear Mathematical Physics, 4:34, 310337
describes in detail the "the most general conditions on the functions $f_1$, $f_2$ and $f_3$, by which the equation may be integrable, as well as conditions for the existence of Lie point symmetries."