2.1.2.2 Solved using first_order_ode_exact
Entering first order ode exact solver
\[\begin {aligned} y^{\prime }+c y&=a \end {aligned}\]
A differential equation of of the form
\begin{align*} M\left ( x,y\right ) +N\left ( x,y\right ) \frac {dy}{dx}&=0\tag {A} \end{align*}
is solved by assuming there exists a function \(\phi \left ( x,y\right ) =c\) where \(c\) is constant that satisfies the ode. Taking
derivative of \(\phi \) w.r.t. \(x\) gives
\begin{align*} \frac {d}{dx}\phi \left ( x,y\right ) &=0 \end{align*}
Therefore
\begin{equation} \frac {\partial \phi }{\partial x}+\frac {\partial \phi }{\partial y}\frac {dy}{dx}=0\tag {B}\end{equation}
Comparing (A,B) shows that
\begin{align*} \frac {\partial \phi }{\partial x} & =M\\ \frac {\partial \phi }{\partial y} & =N \end{align*}
Since \(\frac {\partial ^{2}\phi }{\partial x\partial y}=\frac {\partial ^{2}\phi }{\partial y\partial x}\) then for the above to be valid the following condition is required
\[ \frac {\partial M}{\partial y}=\frac {\partial N}{\partial x}\]
if the above condition is satisfied, the original ode is called exact.
The function \(\phi \left ( x,y\right ) \) needs to be determined. If this condition is not satisfied this method will
not work. In this case an integrating factor might exist to force this condition to be
satisfied.
The first step is to write the ODE in following standard form and then check for exactness.
\[ M(x,y) \mathop {\mathrm {d}x}+ N(x,y) \mathop {\mathrm {d}y}=0 \tag {1A} \]
The given ODE becomes
\begin{align*} \mathop {\mathrm {d}y} &= \left (-c y +a\right )\mathop {\mathrm {d}x}\\ \left (c y -a\right ) \mathop {\mathrm {d}x} + \mathop {\mathrm {d}y} &= 0 \tag {2A} \end{align*}
Comparing (1A) and (2A) shows that
\begin{align*} M(x,y) &= c y -a\\ N(x,y) &= 1 \end{align*}
The ODE is now checked if it is exact or not. An ODE is exact if the following condition is
satisfied
\[ \frac {\partial M}{\partial y} = \frac {\partial N}{\partial x} \]
Therefore
\begin{align*} \frac {\partial M}{\partial y} &= \frac {\partial }{\partial y} \left (c y -a\right )\\ &= c \end{align*}
and
\begin{align*} \frac {\partial N}{\partial x} &= \frac {\partial }{\partial x} \left (1\right )\\ &= 0 \end{align*}
Since \(\frac {\partial M}{\partial y} \neq \frac {\partial N}{\partial x}\), the ODE is not exact.
Because the ODE is not exact, need to find an integrating factor to make it exact. Let
\begin{align*} A &= \frac {1}{N} \left (\frac {\partial M}{\partial y} - \frac {\partial N}{\partial x} \right ) \\ &=1\left ( \left ( c\right ) - \left (0 \right ) \right ) \\ &=c \end{align*}
Since \(A\) does not depend on \(y\), then it can be used to find an integrating factor. The integrating
factor \(\mu \) is
\begin{align*} \mu &= e^{ \int A \mathop {\mathrm {d}x} } \\ &= e^{\int c\mathop {\mathrm {d}x} } \end{align*}
The result of integrating gives
\begin{align*} \mu &= e^{x c } \\ &= {\mathrm e}^{x c} \end{align*}
\(M\) and \(N\) are multiplied by this integrating factor, giving new \(M\) and new \(N\) which are called \(\overline {M}\) and \(\overline {N}\) for
now so not to confuse them with the original \(M\) and \(N\).
\begin{align*} \overline {M} &=\mu M \\ &= {\mathrm e}^{x c}\left (c y -a\right ) \\ &= \left (c y -a \right ) {\mathrm e}^{x c} \end{align*}
and
\begin{align*} \overline {N} &=\mu N \\ &= {\mathrm e}^{x c}\left (1\right ) \\ &= {\mathrm e}^{x c} \end{align*}
The new ODE is now exact and can be solved. The new ODE is
\begin{align*} \overline {M} + \overline {N} \frac { \mathop {\mathrm {d}y}}{\mathop {\mathrm {d}x}} &= 0 \\ \left (\left (c y -a \right ) {\mathrm e}^{x c}\right ) + \left ({\mathrm e}^{x c}\right ) \frac { \mathop {\mathrm {d}y}}{\mathop {\mathrm {d}x}} &= 0 \end{align*}
The following equations are set up to find the function \(\phi \left (x,y\right )\)
\begin{align*} \frac {\partial \phi }{\partial x } &= \overline {M}\tag {1} \\ \frac {\partial \phi }{\partial y } &= \overline {N}\tag {2} \end{align*}
Integrating (2) w.r.t. \(y\) gives
\begin{align*} \int \frac {\partial \phi }{\partial y} \mathop {\mathrm {d}y} &= \int \overline {N}\mathop {\mathrm {d}y} \\ \int \frac {\partial \phi }{\partial y} \mathop {\mathrm {d}y} &= \int {\mathrm e}^{x c}\mathop {\mathrm {d}y}\\ \phi &= {\mathrm e}^{x c} y+ f(x)\tag {3} \end{align*}
Where \(f(x)\) is used for the constant of integration since \(\phi \) is a function of both \(x\) and \(y\). Taking derivative
of equation (3) w.r.t \(x\) gives
\begin{align*} \frac {\partial \phi }{\partial x} &= c \,{\mathrm e}^{x c} y+f'(x)\tag {4} \end{align*}
But equation (1) says that \(\frac {\partial \phi }{\partial x} = \left (c y -a \right ) {\mathrm e}^{x c}\). Therefore equation (4) becomes
\begin{align*} \left (c y -a \right ) {\mathrm e}^{x c} &= c \,{\mathrm e}^{x c} y+f'(x)\tag {5} \end{align*}
Solving equation (5) for \( f'(x)\) gives
\begin{align*} f'(x) &= -{\mathrm e}^{x c} a \end{align*}
Integrating the above w.r.t \(x\) gives
\begin{gather*} \begin {aligned} \int f'(x) \mathop {\mathrm {d}x} &= \int \left ( -{\mathrm e}^{x c} a\right ) \mathop {\mathrm {d}x}\\ f(x) &= -\frac {{\mathrm e}^{x c} a}{c}+ c_1 \end {aligned} \end{gather*}
Where \(c_1\) is constant of integration. Substituting result found above for \(f(x)\) into equation (3) gives \(\phi \)
\begin{align*} \phi &= {\mathrm e}^{x c} y -\frac {{\mathrm e}^{x c} a}{c}+ c_1 \end{align*}
Since \(\phi \) is a constant function, then by combining constants the above simplifies to
\begin{align*} c_1 &= {\mathrm e}^{x c} y -\frac {{\mathrm e}^{x c} a}{c} \end{align*}
Solving for \(y\) from \({\mathrm e}^{x c} \left (y-\frac {a}{c}\right ) = c_1\) gives
\begin{align*}
y &= \frac {\left ({\mathrm e}^{x c} a +c_1 c \right ) {\mathrm e}^{-x c}}{c} \\
\end{align*}
Simplifying the above gives
\[
y = \frac {{\mathrm e}^{-x c} c_1 c +a}{c}
\]
Summary of solutions found
\[
y = \frac {{\mathrm e}^{-x c} c_1 c +a}{c}
\]