Why is it returning those imaginary results?
The ode is
$$
y^{\prime\prime}(1+\left( y^{\prime}\right) ^{2})=0
$$
This gives 2 equations
\begin{align*}
y^{\prime\prime} & =0\\
(1+\left( y^{\prime}\right) ^{2}) & =0
\end{align*}
The first has the solution $y=c_{1}+c_{2}x$ and the second is $\left(
y^{\prime}\right) ^{2}=-1$ or $y^{\prime}=\pm i$. For $y^{\prime}=i$, by
integrating this the result is $y=i\int dx=ix+c_{1}$ and for $y^{\prime}=-i$,
by integrating this the result is $y=-i\int dx=-ix+c_{1}$
Hence the solutions are
\begin{align*}
y_{1}\left( x\right) & =c_{1}+c_{2}x\\
y_{2}\left( x\right) & =ix+c_{1}\\
y_{3}\left( x\right) & =-ix+c_{1}
\end{align*}
This is why Mathematica gave the complex solutions.
Answer comment
Why isn't the assumption that the results for DEQs are real?
First, there are no assumptions in the post.
Second, DSolve
returns solutions to ODE's. You could always filter out solutions you do not want afterwords. The solver does not know if $y(x)$ is real or not until it solves the ODE. It just finds solutions that satisfies the ODE. What do you want the solver to do when asked to solve $y'=i$?
DSolve[y'[x] == I, y[x], x, Assumptions -> Element[y[x], Reals]]
As mentioned in other places, DSolve seems to ignore such assumptions. Notice also that the constant of integration could be complex or not, depending on initial conditions. So DSolve
can't really be sure if solution is real or not with no initial conditions as well.
The bottom line, if you want real solutions, filter them out yourself afterwords using other Mathematica commands by post processing the DSolve
results.
Select[sol, FreeQ[#, Complex] &]
$\endgroup$