I solved this ode by hand and obtained the general solution. But not able to solve for the constants of the integrations given the initial conditions, as when I try, I get no solution.
Yet, Mathematica is able to do it, and would like to find how it did it. The problem is from text book
Mathematica gets the correct solution. This is what I did
ClearAll[y, x];
ode = y''[x] == -Exp[-2*y[x]]
(*just use one solution for now, but I tried both also*)
sol = y[x] /. First@DSolve[ode, y[x], x]
So now initial conditions
y[3] == 0
y'[3] == 1
Need to be applied to the above solution in order to solve for C[1],C[2]
and here is the problem. Setting up the two equations and asking Solve
to Solve for C[1],C[2]
eq1 = 0 == Limit[sol, x -> 3] // Simplify
eq2 = 1 == Limit[D[sol, x], x -> 3] // Simplify
Solve[{eq1, eq2}, {C[1], C[2]}]
{}
Tried Reduce, SolveAlways, FindInstance and nothing works. Unable to find solution.
But Mathematica gets the correct solution:
ClearAll[y, x];
ode = y''[x] == -Exp[-2*y[x]]
ic = {y[3] == 0, y'[3] == 1}
sol = DSolve[{ode, ic}, y[x], x]
How did Mathematica solve for the constants of integration? What method did it use?
Update
Figured how to solve it by hand. This looks like how DSolve
did it, from the Trace shown by Michael below.
The whole idea it to solve for one constant early one (from the $y'$ and only then solve for $y$. This is easier to do by hand than program it in).
\begin{align*} y^{\prime\prime} & =-e^{-2y}\\ y\left( 3\right) & =0\\ y^{\prime}\left( 3\right) & =1 \end{align*} Let $p=y^{\prime}$, then $y^{\prime\prime}=\frac{dp}{dx}=\frac{dp}{dy} \frac{dy}{dx}=\frac{dp}{dy}p$. The ode becomes $$ p\frac{dp}{dy}=-e^{-2y} $$ This is first order ode. The solution is \begin{equation} p=\pm\sqrt{e^{-2y}+2c_{1}}\tag{1} \end{equation} Taking one solution for now (same for the other), then $p=\sqrt{e^{-2y}+2c_{1}}$. But from initial conditions $p\left( 3\right) =1,y\left( 3\right) =0$. Hence \begin{align*} 1 & =\sqrt{e^{-2\left( 0\right) }+2c_{1}}\\ 1 & =\sqrt{1+2c_{1}}\\ c_{1} & =0 \end{align*} The solution (1) becomes \begin{align*} p & =\sqrt{e^{-2y}}\\ & =e^{-y} \end{align*} Or since $p=\frac{dy}{dx}$ $$ \frac{dy}{dx}=e^{-y} $$ This is first order ode whose solution is (taking one of them now) \begin{equation} y=\ln\left( x+c_{2}\right) \tag{2} \end{equation} But $y\left( 3\right) =0$, hence $$ 0=\ln\left( 3+c_{2}\right) $$ Hence $3+c_{2}=1$ or $c_{2}=-2$. Therefore the solution (2) becomes $$ y=\ln\left( x-2\right) $$
DSolve
is very good. Without doing this, and waiting for the end to solve both constants at same time (like I was doing), it would have got into trouble too. But it is much smarter than this.