Question regarding usage of absolute value within natural log in solution of differential equation

The problem from the book.

$\dfrac{\mathrm{d}y}{\mathrm{d}x} = 6 -y$

I understand the solution till this part.

$\ln \vert 6 - y \vert = x + C$

The solution in the book is $6 - Ce^{-x}$

My issue this that this solution, from the book, doesn't seem to resolve the issue of the abs value of $\vert 6 - y\vert$


You should have, as your general solution, $$ -\ln|6-y|=x+C\ \quad\iff\quad |6-y|=e^C e^{-x} . $$

If $y-6>0$, you have the solution $$y-6= e^Ce^{-x}\ \quad\iff\quad y=6+ e^Ce^{-x} . $$

If $y-6<0$, you have the solution $$6-y= e^Ce^{-x}\ \quad\iff\quad y=6- e^Ce^{-x} . $$

In either case, the solution can be written as $y=6- Ce^{-x} $, for some constant $C$ (different from the $C$ above).


  1. Here's a rigorous solution: $$\begin{align} &\dfrac{\mathrm{d}y}{\mathrm{d}x} = 6 -y \\ \frac1{6-y}\dfrac{\mathrm{d}y}{\mathrm{d}x} &= 1 \ \ \ \ \ \ \ \ \text{or}\ \ \ \ \ \ \ \ y=\bbox[pink]{6} \\ \int\frac{\mathrm{d}y}{6-y} &= \int1{\mathrm{d}x} \\ -\ln \lvert 6-y\rvert &= x +C' \\ \lvert 6-y\rvert &= e^{-x-C'} \\ 6-y= e^{-x-C'}\ \ \ &\text{or}\ \ \ y-6= e^{-x-C'}\\ y&=\bbox[pink]{6\pm e^{-C'}e^{-x}}. \end{align}$$ Observe that $\pm e^{-C'}$ is a nonzero arbitrary constant.
    Combining the two sub-answers (in pink) gives the general solution $\bbox[yellow]{y=6+Ce^{-x}}$.


2. Alternatively, this solution avoids dealing with the modulus function, and is more compact to boot: $$\begin{align} \dfrac{\mathrm{d}y}{\mathrm{d}x} &= 6 -y\\ \dfrac{\mathrm{d}y}{\mathrm{d}x} +y &= 6\\ \dfrac{\mathrm{d}y}{\mathrm{d}x}e^x +ye^x &= 6e^x \\ \dfrac{\mathrm{d}}{\mathrm{d}x} (ye^x) &= 6e^x\\ ye^x &= \int6e^x{\mathrm{d}x}\\ &=6e^x+C\\ \bbox[yellow]{y}&\bbox[yellow]{=6+Ce^{-x}}. \end{align}$$