[Math] How to solve a Second order and Second Degree Differential Equation

numerical methodsordinary differential equations

I have came across a second order as well as second degree differential equation in study of cosmic inflation. The full equations is quite messy so let me give a prototype:
$$A(x) y''(x)^2 + B(x) y(x) + C(x) = 0 $$ $$y'(0) = a$$ $$y(0) = b$$
What I usually do in this type of cases is to ask Mathematica to solve it. And she usually solve it. But, sometimes mathematica show some error, for instance "singularity or stiffness at x=d". Now, I am trying to solve them numerically in some basic language ( read python ). But, the way we solve 2nd order differential equation is not applicable here, i.e., writing it as two first order differential equations.

Can any one provide me with an algorithm for solving the problem numerically and/or direct me to the literature where I can learn more about the methods.

Thanks in advance.

N.B. I have asked this question in stackoverflow, now asking here as suggested in a helpful comment.

Best Answer

But, the way we solve 2nd order differential equation is not applicable here, i.e., writing it as two first order differential equations.

Why not? Let $z = y'$; then we have $$ y'(x) = z(x) \\ z'(x) = \pm \sqrt{- \frac{B(x) y(x) + C(x)}{A(x)}} \\ z(0) = a \\ y(0) = b $$ This will provide you with a local solution for $y(x)$ so long as $y''(x)$ does not cross zero (i.e., $z'(x)$ never switches sign.) In fact, the solution in a neighborhood of 0 will not be unique (if it exists—the quantity under the square root could be negative); there will be two solutions, one with $z'(0) > 0$ and one with $z'(0) < 0$.