2.2.5.3 Example 3

\begin {align*} \frac {dy}{dx} & =\frac {2\left ( 2y-x\right ) }{x+y}\\ y\left ( 0\right ) & =2 \end {align*}

Let \(y=ux\) or \(u=\frac {y}{x}\), hence \(\frac {dy}{dx}=x\frac {du}{dx}+u\) and the above ode becomes\begin {align*} x\frac {du}{dx}+u & =\frac {2\left ( 2ux-x\right ) }{x+ux}\\ x\frac {du}{dx}+u & =\frac {2\left ( 2u-1\right ) }{1+u}\\ x\frac {du}{dx} & =\frac {2\left ( 2u-1\right ) }{1+u}-u\\ & =\frac {2\left ( 2u-1\right ) -u\left ( 1+u\right ) }{1+u}\\ & =\frac {-u^{2}+3u-2}{1+u} \end {align*}

This is separable

\[ \frac {1+u}{-u^{2}+3u-2}du=\frac {1}{x}dx\qquad \frac {-u^{2}+3u-2}{1+u}\neq 0 \] Integrating\begin {align*} \int \frac {1+u}{-u^{2}+3u-2}du & =\int \frac {1}{x}dx\\ -3\ln \left ( u-2\right ) +2\ln \left ( u-1\right ) & =\ln x+c \end {align*}

Replacing \(u=\frac {y}{x}\) gives\begin {align} -3\ln \left ( \frac {y}{x}-2\right ) +2\ln \left ( \frac {y}{x}-1\right ) & =\ln x+c\nonumber \\ -3\ln \left ( \frac {y-2x}{x}\right ) +2\ln \left ( \frac {y-x}{x}\right ) & =\ln x+c\nonumber \\ \ln \left ( \frac {x}{y-2x}\right ) ^{3}+\ln \left ( \frac {y-x}{x}\right ) ^{2} & =\ln x+c \tag {1} \end {align}

Singular solution is when \(\frac {-u^{2}+3u-2}{1+u}=0\) or \(u=1,u=2.\) This implies \(y=x,y=2x\). Hence the solutions are\begin {align*} \ln \left ( \frac {x}{y-2x}\right ) ^{3}+\ln \left ( \frac {y-x}{x}\right ) ^{2} & =\ln x+c\\ y & =x\\ y & =2x \end {align*}

Note on the power rule for log. \(n\ln \left ( m\right ) =\ln \left ( m^{n}\right ) \) is valid for \(m>0\) and in real domain. So in this above we implicitly assumed this is true in order to write \(-3\ln \left ( \frac {y-2x}{x}\right ) \) as \(\ln \left ( \frac {x}{y-2x}\right ) ^{3}\). Now, taking exponential of (1) gives\begin {align} \left ( \frac {x}{y-2x}\right ) ^{3}\left ( \frac {y-x}{x}\right ) ^{2} & =c_{1}x\nonumber \\ \frac {x^{3}}{\left ( y-2x\right ) ^{3}}\frac {\left ( y-x\right ) ^{2}}{x^{2}} & =c_{1}x\nonumber \\ \frac {x\left ( y-x\right ) ^{2}}{\left ( y-2x\right ) ^{3}} & =c_{1}x\nonumber \\ \frac {\left ( y-x\right ) ^{2}}{\left ( y-2x\right ) ^{3}} & =c_{1} \tag {2} \end {align}

At \(y\left ( 0\right ) =2\) then\begin {align*} \frac {\left ( 2\right ) ^{2}}{\left ( 2\right ) ^{3}} & =c_{1}\\ \frac {1}{2} & =c_{1} \end {align*}

Hence the solution from (2) becomes\[ \frac {\left ( y-x\right ) ^{2}}{\left ( y-2x\right ) ^{3}}=\frac {1}{2}\] It is important in these kind of problems where left side has \(\ln \) as function of \(y\left ( x\right ) \) is to take exponential. Lets see what happens of we do not. Starting again from (1) and let us try to solve for IC from (1) as is\[ \ln \left ( \frac {x}{y-2x}\right ) ^{3}+\ln \left ( \frac {y-x}{x}\right ) ^{2}=\ln x+c \] At \(y\left ( 0\right ) =2\) the above becomes\[ \ln \left ( 0\right ) ^{3}+\ln \left ( \frac {2}{0}\right ) ^{2}=\ln 0+c \] We see this will not work. These types of issues are easy to work around when solving by hand and looking at equations. But very hard to program since the code has to handle any form of expression.