23 Note on using when to raise ln to exp solving an ode
Sometimes in the middle of solving an ode, we get \(\ln \) on both sides. We can raise both sides to \(\exp \) as soon as these show up, or wait until the end, after solving the constant of integration to do that. This shows we get same result in both cases.
23.1 Example 1
\begin{equation} y^{\prime }=2\frac {2yx-x}{x+y} \tag {1}\end{equation}
With initial conditions \(y\left ( 0\right ) =2\). This is homogenous type ode. It solved by substitution \(u=\frac {y}{x}\) which results in the new ode in \(u\) given by
\[ u^{\prime }=\frac {1}{x}\left ( \frac {-u^{2}+3u-2}{1+u}\right ) \]
This is now separable
\begin{align*} \frac {du}{dx} & =\frac {1}{x}\left ( \frac {-u^{2}+3u-2}{1+u}\right ) \\ \int \frac {1+u}{-u^{2}+3u-2}du & =\frac {1}{x}dx \end{align*}
Integrating gives
\begin{equation} 2\ln \left ( 1-u\right ) -3\ln \left ( 2-u\right ) =\ln x+c \tag {1A}\end{equation}
Replacing \(u\) by \(\frac {y}{x}\) which gives
\begin{align} 2\ln \left ( 1-\frac {y}{x}\right ) -3\ln \left ( 2-\frac {y}{x}\right ) & =\ln x+c\nonumber \\ \ln \left ( \frac {\left ( 1-\frac {y}{x}\right ) ^{2}}{\left ( 2-\frac {y}{x}\right ) ^{3}}\right ) & =\ln x+c\nonumber \\ \ln \left ( \frac {\frac {1}{x^{2}}\left ( x-y\right ) ^{2}}{\frac {1}{x^{3}}\left ( 2x-y\right ) ^{3}}\right ) & =\ln x+c\nonumber \\ \ln \left ( x\frac {\left ( x-y\right ) ^{2}}{\left ( 2x-y\right ) ^{3}}\right ) & =\ln x+c\nonumber \\ \ln x+\ln \frac {\left ( x-y\right ) ^{2}}{\left ( 2x-y\right ) ^{3}} & =\ln x+c \tag {1B}\end{align}
\(\ln x\) cancels out giving
\begin{equation} \ln \frac {\left ( x-y\right ) ^{2}}{\left ( 2x-y\right ) ^{3}}=c \tag {2}\end{equation}
Now lets try to solve for \(c\) from IC \(y\left ( 0\right ) =2\). The above becomes
\begin{align*} \ln \left ( \frac {\left ( -2\right ) ^{2}}{\left ( -2\right ) ^{3}}\right ) & =c\\ c & =\ln \left ( \frac {4}{-8}\right ) \\ & =\ln \left ( -\frac {1}{2}\right ) \end{align*}
So the solution (2) is
\[ \ln \frac {\left ( x-y\right ) ^{2}}{\left ( 2x-y\right ) ^{3}}=\ln \left ( -\frac {1}{2}\right ) \]
And only now after \(c\) is found, we raise both sides to \(\exp \) (to simplify it) which gives the solution as
\[ \frac {\left ( x-y\right ) ^{2}}{\left ( 2x-y\right ) ^{3}}=\frac {-1}{2}\]
Or
\begin{equation} \frac {\left ( x-y\right ) ^{2}}{\left ( y-2x\right ) ^{3}}=\frac {1}{2} \tag {3}\end{equation}
Lets see what happens if we had raised both sides to \(\exp \) earlier on, instead of waiting until after solving for the constant of integration. i.e. from step (1A) above
\begin{align*} 2\ln \left ( 1-u\right ) -3\ln \left ( 2-u\right ) & =\ln x+c\\ \ln \frac {\left ( 1-u\right ) ^{2}}{\left ( 2-u\right ) ^{3}} & =\ln x+c\\ \frac {\left ( 1-u\right ) ^{2}}{\left ( 2-u\right ) ^{3}} & =e^{\ln x+c}\\ \frac {\left ( 1-u\right ) ^{2}}{\left ( 2-u\right ) ^{3}} & =Ax \end{align*}
Where \(A\) is new constant. And only now we replace \(u\) by \(\frac {y}{x}\) which gives
\begin{align} \frac {\left ( 1-\frac {y}{x}\right ) ^{2}}{\left ( 2-\frac {y}{x}\right ) ^{3}} & =Ax\nonumber \\ x\frac {\left ( x-y\right ) ^{2}}{\left ( 2x-y\right ) ^{3}} & =Ax\nonumber \\ \frac {\left ( x-y\right ) ^{2}}{\left ( 2x-y\right ) ^{3}} & =A \tag {4}\end{align}
Using IC \(y\left ( 0\right ) =2\). The above becomes
\begin{align*} \frac {\left ( -2\right ) ^{2}}{\left ( -2\right ) ^{3}} & =A\\ A & =-\frac {1}{2}\end{align*}
Hence (4) becomes
\begin{align*} \frac {\left ( x-y\right ) ^{2}}{\left ( 2x-y\right ) ^{3}} & =-\frac {1}{2}\\ \frac {\left ( x-y\right ) ^{2}}{\left ( y-2x\right ) ^{3}} & =\frac {1}{2}\end{align*}
Which is the same answer obtained earlier in (3). This shows both methods work. It might be better to delay the raising to exponential to the very end so it is all done in one place.
23.2 Example 2
\begin{align} y^{\prime } & =\frac {y^{2}-2xy-x^{2}}{y^{2}+2xy-x^{2}}\tag {1}\\ y\left ( 1\right ) & =-1\nonumber \end{align}
This is a homogenous ode, solved by the substitution \(u=\frac {y}{x}\) which results in new ode in \(u\) given by
\[ u^{\prime }=\frac {1}{x}\frac {-u^{3}-u^{2}-u-1}{u^{2}+2u-1}\]
This is separable
\[ \frac {u^{2}+2u-1}{-u^{3}-u^{2}-u-1}du=\frac {1}{x}dx \]
Integrating gives
\begin{equation} \ln \left ( u+1\right ) -\ln \left ( u^{2}+1\right ) =\ln \left ( x\right ) +c_{1} \tag {1}\end{equation}
There are two choices now. Raise both sides to \(\exp \) to simplify the \(u\) solution or wait until the end. Option 1:
Replacing \(u\) by \(\frac {y}{x}\) in (1) gives
\begin{align} \ln \left ( \frac {y}{x}+1\right ) -\ln \left ( \left ( \frac {y}{x}\right ) ^{2}+1\right ) & =\ln \left ( x\right ) +c_{1}\nonumber \\ \ln \left ( \frac {\frac {y}{x}+1}{\left ( \frac {y}{x}\right ) ^{2}+1}\right ) & =\ln \left ( x\right ) +c_{1}\nonumber \\ \ln \left ( \frac {\frac {1}{x}\left ( y+x\right ) }{\frac {1}{x^{2}}\left ( y^{2}+x^{2}\right ) }\right ) & =\ln \left ( x\right ) +c_{1}\nonumber \\ \ln \left ( x\frac {\left ( y+x\right ) }{\left ( y^{2}+x^{2}\right ) }\right ) & =\ln \left ( x\right ) +c_{1}\nonumber \\ \ln x+\ln \left ( \frac {y+x}{y^{2}+x^{2}}\right ) & =\ln \left ( x\right ) +c_{1}\nonumber \\ \ln \left ( \frac {y+x}{y^{2}+x^{2}}\right ) & =c_{1} \tag {2}\end{align}
Now lets try to solve for \(c_{1}\) from IC \(y\left ( 1\right ) =-1\). The above becomes
\begin{align*} \ln \left ( \frac {0}{2}\right ) & =c_{1}\\ c & =-\infty \end{align*}
Hence (2) becomes
\[ \ln \left ( \frac {y+x}{y^{2}+x^{2}}\right ) =-\infty \]
Now raising both sides to \(\exp \) gives
\begin{align*} \frac {y+x}{y^{2}+x^{2}} & =e^{-\infty }\\ \frac {y+x}{y^{2}+x^{2}} & =0\\ y+x & =0\\ y & =-x \end{align*}
Lets try to see what happens if we raise to \(\exp \) after solving for \(u\) immeadilty which is the second option. From (1)
\[ \ln \left ( \frac {u+1}{u^{2}+1}\right ) =\ln \left ( x\right ) +c_{1}\]
Raising both to \(\exp \) gives
\[ \frac {u+1}{u^{2}+1}=Ax \]
Where \(A\) new constant. Now we replace \(u\) by \(\frac {y}{x}\)
\begin{align} \frac {\frac {y}{x}+1}{\left ( \frac {y}{x}\right ) ^{2}+1} & =Ax\tag {2}\\ x\frac {y+x}{y^{2}+x^{2}} & =Ax\nonumber \\ \frac {y+x}{y^{2}+x^{2}} & =A\nonumber \end{align}
Solving for \(A\) from IC \(y\left ( 1\right ) =-1\) from the above gives
\begin{align*} \frac {0}{2} & =A\\ A & =0 \end{align*}
Hence the solution (2) becomes
\[ \frac {\frac {y}{x}+1}{\left ( \frac {y}{x}\right ) ^{2}+1}=0 \]
or
\begin{align*} \frac {y}{x}+1 & =0\\ y & =-x \end{align*}
So both method worked. The early one and the later on one. Both give same result.
23.3 Example 3
\begin{align} \left ( x+2y\right ) y^{\prime } & =1\tag {1}\\ y\left ( 0\right ) & =-1\nonumber \end{align}
This is tricky as how it is solved needs special handling of the initial conditions. Let us solve by subtituting \(z=x+2y\). Then \(z^{\prime }=1+2y^{\prime }\). The ode now becomes
\begin{align*} z\frac {\left ( z^{\prime }-1\right ) }{2} & =1\\ z^{\prime }-1 & =\frac {2}{z}\\ z^{\prime } & =\frac {2}{z}+1 \end{align*}
This is separable
\[ \frac {dz}{1+\frac {2}{z}}=dx \]
Integrating
\begin{align} \int \frac {dz}{1+\frac {2}{z}} & =\int dx\nonumber \\ z-2\ln \left ( 2+z\right ) & =x+c \tag {1}\end{align}
We could raise both sides to \(\exp \) now or wait until after converting back to \(y\). Lets look what happens in both cases. Raising to \(\exp \) now gives
\begin{align*} e^{z-2\ln \left ( 2+z\right ) } & =Ae^{x}\\ \frac {e^{z}}{\left ( 2+z\right ) ^{2}} & =Ae^{x}\end{align*}
But \(z=x+2y\) and the above becomes
\begin{align} \frac {e^{x+2y}}{\left ( 2+x+2y\right ) ^{2}} & =Ae^{x}\nonumber \\ \frac {e^{2y}}{\left ( 2+x+2y\right ) ^{2}} & =A \tag {2}\end{align}
Which is the correct solution. Now IC is used to find \(A\). Using \(y\left ( 0\right ) =-1\) the above becomes
\[ \frac {e^{-2}}{0}=A \]
So \(A=\infty \). Hence the solution (2) is
\[ \frac {e^{2y}}{\left ( 2+x+2y\right ) ^{2}}=\infty \]
When this happens, to simplify the above we say that \(\left ( 2+x+2y\right ) ^{2}=0\) or \(2+x+2y=0\). This gives \(2y=-2-x\). Hence
\[ y=-1-x \]