# Question about DSolve (nonlinear ODE)

I try to solve the following IVP (found in a textbook): $$\frac{d^2y}{dx^2}=\left(\frac{dy}{dx}\right)^2$$ with $$y(0)=1$$ and $$y'(0)=1$$. I use reduction of order. Say $$u=\frac{dy}{dx}$$. Thus $$\frac{du}{dx}=u^2$$. This is a separable equation $$\begin{gather*} \frac{du}{u^2}=dx\Rightarrow \int\frac{du}{u^2}=\int dx\Rightarrow -\frac{1}{u}=x+c\\ y'(0)=1\rightarrow u(0)=1\Rightarrow -\frac{1}{0+c}=1\Rightarrow c=-1 \end{gather*}$$ Therefore $$\begin{gather*} u=-\frac{1}{x-1}\Rightarrow \frac{dy}{dx}=-\frac{1}{x-1}\Rightarrow \int\frac{dy}{dx}=-\int\frac{1}{x-1}\Rightarrow y=-\ln|x-1|+c_2\\ y(0)=1\rightarrow 1=-\ln(1)+c_2\Rightarrow c_2=1 \end{gather*}$$ and the solution of the IVP is $$y=\ln|x-1|^{-1}+1$$. I tried to verify the obtained solution with Mathematica's DSolve. I got

DSolve[(y^′′)[x] == Derivative[1][y][x]^2 &&
y[0] == 1 && Derivative[1][y][0] == 1, y[x], {x, -∞, 1}]

During evaluation of Solve::incnst: Inconsistent or redundant transcendental equation. After reduction, the bad equation is 1+Subscript[\[ConstantC], 1] == 0.
(* {{y[x] -> 1 - Log[1 - x]}} *)

DSolve[(y^′′)[x] == Derivative[1][y][x]^2 &&
y[0] == 1 && Derivative[1][y][0] == 1, y[x], {x, 1, ∞}]

During evaluation of Solve::incnst: Inconsistent or redundant transcendental equation. After reduction, the bad equation is 1+Subscript[\[ConstantC], 1] == 0.
(* {{y[x] -> 1 + I π - Log[-1 + x]}} *)


How can one force Mathematica to provide the solution found by hand? Thanks in advance.

• The first result agrees with your by-hand solution. The abs. val. may be eliminated since we must have $x<1$. The solution for $1<x<\infty$ is not well-defined, since the IVP starts at $x=0$ and has a singularity at $x=1$. In other words, the last pair of integrals above should be $\int_0^x {dy \over dx} \,dx = \int_0^x {1 \over x-1}\; dx$. For $x>1$, the integral is improper. Mathematica is in effect integrating along a path in the complex plane that goes around the pole. I say "in effect" because it really is just using Log[z] with a particular branch chosen so that Log[-1] == I*Pi. Dec 4 '20 at 18:49

Clear["Global*"]

eqn = y''[x] == (y'[x])^2 && y[0] == 1 && y'[0] == 1;

sol = DSolve[eqn, y, {x, -∞, 1}][[1]]

(* Solve::incnst: Inconsistent or redundant transcendental equation. After reduction, the bad equation is 1+Subscript[\[ConstantC], 1] == 0.

{y -> Function[{x}, 1 - Log[1 - x]]} *)


Verifying Mathematica's solution,

eqn /. sol

(* True *)


Since  x < 1, this is equivalent to your hand-derived solution

sol2 = Log[Abs[x - 1]^-1] + 1;

(y[x] /. sol) == sol2 // Simplify[#, x < 1] &

(* True *)
`