# Solution to $y'=y^2-4$

I recognize this as a separable differential equation and receive the expression:

$\frac{dy}{y^2-4}=dx$

The issue comes about when evaluating the left hand side integral:

$\frac{dy}{y^2-4}$

I attempt to do this integral through partial fraction decomposition using the following logic:

$\frac{1}{(y+2)(y-2)} = \frac{A}{y+2}+\frac{B}{y-2}$

Therefore, $1=Ay-2A+By+2B$.

Since the coefficients must be the same on both sides of the equation it follows that:

$0=A+B$ and $1=-2A+2B$. Hence, $A=-B$, $B=\frac14$, $A=-\frac14$.

Thus the differential equation should be transformed into:

$-\frac{1}{4} \frac{dy}{y+2} + \frac14 \frac{dy}{y-2} = x+C$

Solving this should yield:

$-\frac14 \ln|y+2| + \frac14 \ln|y-2| = x+C$

which simplifies as:

$\ln(y-2)-\ln(y+2)=4(x+c)$

$\ln[(y-2)/(y+2)]=4(x+c)$

$(y-2)/(y+2)=\exp(4(x+c))$

$y-2=y*\exp(4(x+c)+2\exp(4(x+c))$

$y-y\exp(4(x+c))=2+2\exp(4(x+c))$

$y(1-\exp(4(x+c)))=2(1+\exp(4(x+c)))$

$y= 2(1+\exp(4(x+c)))/(1-\exp(4(x+c)))$

However, when done in Mathematica/Wolfram Alpha the result is given as (proof in the attached image)

$\frac14 \ln(2-y) -\frac14 \ln(2+y) = x + C$

and returns an answer of:

$y= 2(1-\exp(4(x+c)))/(1+\exp(4(x+c)))$.

Can anyone figure out where I have made an error? The only thing I can think of is something with evaluating the absolute values of the natural logarithms.

• two constant solutions, $y=2$ and $y=-2.$ The other solutions split into three types, $y < -2,$ very similar $y > 2,$ rather different $-2 < y < 2$ – Will Jagy May 29 '15 at 22:03
• Ok but how does this help me in understanding why my answer is wrong? – Filip May 29 '15 at 22:09
• That is up to you. – Will Jagy May 29 '15 at 22:16
• If I am not mistaken, $y' = y^2 - 4$ is a Ricatti equation; you might check the wiki page on such; I have found it quite useful. As far as Wolfram Alpha goes, I have often found its solutions to be quite different than mine; I usually like mine better; at least I know where mine came from! – Robert Lewis May 29 '15 at 22:25
• I'm not sure you're answer is wrong. Did you try checking it the old-fashioned way, by hand? – Robert Lewis May 29 '15 at 22:26

## 2 Answers

Saturday morning: I do like robjohn's point about $\log |x|$ giving the student some incorrect expectations. What I wrote here is correct and careful, but the same conclusions come from dropping the absolute value signs and doing the calculations three times, $y < -2,$ $-2 < y < 2,$ $y > 2.$ At some point the vertical asymptotes will be revealed, how solutions with $y > 2$ reach a vertical asymptote and then jump below to $y < -2.$ That is how I usually do things, split into cases early.

Lost my train of thought. However, if I want $\int \frac{1}{x} dx,$ without absolute values, the answer would be $\log x$ for $x > 0,$ but $\log (-x)$ for $x < 0.$

$-\frac14 \log|y+2| + \frac14 \log|y-2| = x+C$

which simplifies as:

$\log|y-2|-\log|y+2|=4(x+c),$ or

$$\left| \frac{y-2}{y+2} \right| = k e^{4x}$$ with $k > 0$ for the nonconstant solutions. The item inside absolute value signs is a linear fractional or Mobius transformation, once we decide about the $\pm$ signs the inverse is given by the matrix $$\left( \begin{array}{rr} 2 & 2 \\ -1 & 1 \end{array} \right)$$ If $y > 2$ or $y < -2,$ those inequalities hold true forever, we have $$\frac{y-2}{y+2} = k e^{4x}$$ and we get robjohn's $$y = \frac{2k e^{4x} + 2}{-k e^{4x} + 1}.$$ There is a jump discontinuity: for some value of $x,$ we find that $-k e^{4x} + 1= 0,$ indeed $e^{4x} = 1/k,$ $4x = - \log k,$ x = $-(1/4) \log k.$ For $x < -(1/4) \log k,$ we have $y > 2.$ There is a vertical asymptote, then for $x > -(1/4) \log k,$ we have $y < -2.$

In all cases, the curves are asymptotic to the lines $y=2$ and $y=-2.$ Also, note that the ODE is autonomous. Given one of the solutions described, we get another solution by shifting $x$ by any constant we like. If preferred, we can drop the multiplier $k$ by emphasizing the horizontal shifts.

If, however, we begin with $-2 < y < 2,$ then those inequalites hold forever, we have $$\frac{y-2}{y+2} = - k e^{4x}$$ and we get the continuous $$y = \frac{-2k e^{4x} + 2}{k e^{4x} + 1}.$$

In the picture below, I took $k=1.$ To find all other solutions, replace $x$ by some $x - x_0.$ Put another way, we can take $e^{-4 x_0}= k;$ thus, we can account for all solutions either by varying $k,$ or by deleting $k$ and adjusting $x_0.$ Note also that the part with $y>2$ and the part with $y < -2$ are tied together, the same vertical asymptote. \begin{align} x &=\int\frac{\,\mathrm{d}y}{y^2-4}\\ &=\frac14\int\left(\frac1{y-2}-\frac1{y+2}\right)\,\mathrm{d}y\\ &=\frac14\log\left(\frac{y-2}{y+2}\right)+C \end{align} Therefore, $$\frac{y-2}{y+2}=ke^{4x}$$ or, solving for $y$, $$y=2\,\frac{1+ke^{4x}}{1-ke^{4x}}$$ We get your form of the answer by letting $k\lt0$. It is hard to see this since you need to use a complex $c$ to get the equivalent answer. Check your answer in the original equation. You'll see that it works.

• but isn't your k guaranteed to be a positive value since it is e^C and e^x>0? – Filip May 29 '15 at 22:45
• @WillJagy: I dislike using $\log|y|$ as the antiderivative of $\frac1y$ since it suggests that $\int_{-1}^1\frac{\mathrm{d}y}y=0$, when, in fact, the integral diverges. Taking the Cauchy Principal Value of the integral does give $0$, but I prefer to use either an complex constant of integration for the case when $y\lt0$, or use $\log(y)+C$ and $\log(-y)+C$ depending on the domain, emphasizing that the domains should not be mixed. – robjohn May 29 '15 at 23:02
• @Filip: As I mentioned in my answer, if $C$ is complex, we can have $e^C\lt0$. – robjohn May 29 '15 at 23:05