# Solve the differential equation y'=(y-x)^2?

Jun 21, 2018

$y = x + \frac{{a}^{2} + {x}^{2}}{{a}^{2} - {x}^{2}}$

where $a$ is a constant of integration.

#### Explanation:

Let us change variables to $u = y - x$.

Then ${u}^{'} = {y}^{'} - 1$ and so the differential equation becomes

${u}^{'} = {u}^{2} - 1 \implies$

$\frac{\mathrm{du}}{{u}^{2} - 1} = \mathrm{dx} \implies$
$\frac{1}{2} \log | \frac{u - 1}{u + 1} | = \log x - \log a$

where we have written the constant of integration as $- \log a$. Thus

$\frac{u - 1}{u + 1} = {x}^{2} / {a}^{2} \implies$
$u = \frac{{a}^{2} + {x}^{2}}{{a}^{2} - {x}^{2}} \implies$

$y = x + \frac{{a}^{2} + {x}^{2}}{{a}^{2} - {x}^{2}}$

Jun 21, 2018

$y = x + \frac{1 + A {e}^{2 x}}{1 - A {e}^{2 x}}$

#### Explanation:

We have:

$y ' = {\left(y - x\right)}^{2}$ ..... [A]

Perform the substitution:

$u = y - x$

Then differentiating wrt $x$, and applying the product rule:

$\frac{\mathrm{du}}{\mathrm{dx}} = \frac{\mathrm{dy}}{\mathrm{dx}} - 1 \implies \frac{\mathrm{dy}}{\mathrm{dx}} = 1 + \frac{\mathrm{du}}{\mathrm{dx}}$

Substituting into the DE:

$1 + \frac{\mathrm{du}}{\mathrm{dx}} = {u}^{2}$
$\therefore \frac{\mathrm{du}}{\mathrm{dx}} = {u}^{2} - 1$

Reducing the DE to a separable form:

$\frac{1}{{u}^{2} - 1} \setminus \frac{\mathrm{du}}{\mathrm{dx}} = 1$

So we can "separate the variables" to get:

$\int \setminus \frac{1}{{u}^{2} - 1} \setminus \mathrm{du} = \int \setminus \mathrm{dx}$

We can perform partial fraction decomposition of the LHS integrand:

 1/(u^2-1) -= 1/((u+1)(u-1)
$\setminus \setminus \setminus \setminus \setminus \setminus \setminus \setminus \setminus \setminus \setminus \setminus \equiv \frac{A}{u + 1} + \frac{B}{u - 1}$

And using the "cover up" methods we get:

$A = - \frac{1}{2} , B = \frac{1}{2}$

Allowing us to write the equation as:

$\frac{1}{2} \int \setminus \frac{1}{u - 1} - \frac{1}{u + 1} \setminus \mathrm{du} = \int \setminus \mathrm{dx}$

And integrating, we get:

$\frac{1}{2} \left\{\ln \left(u - 1\right) - \ln \left(u + 1\right)\right\} = x + C$

$\therefore \ln \left(\frac{u - 1}{u + 1}\right) = 2 x + 2 C$

$\therefore \frac{u - 1}{u + 1} = {e}^{2 x + 2 C}$

$\therefore u - 1 = \left(u + 1\right) A {e}^{2 x}$

$\therefore u - 1 = u A {e}^{2 x} + A {e}^{2 x}$

$\therefore u - u A {e}^{2 x} = 1 + A {e}^{2 x}$

$\therefore u \left(1 - A {e}^{2 x}\right) = 1 + A {e}^{2 x}$

$\therefore u = \frac{1 + A {e}^{2 x}}{1 - A {e}^{2 x}}$

And restoring the substitution:

$y - x = \frac{1 + A {e}^{2 x}}{1 - A {e}^{2 x}} \implies y = x + \frac{1 + A {e}^{2 x}}{1 - A {e}^{2 x}}$