Linear second order not exact but solved by finding \(\mu \left ( x\right ) \) integrating factor.
Example 1
Example 2

ode internal name "linear_second_order_ode_solved_by_mu_integrating_factor"

(not implemented yet).

As mentioned above, an exact ode is one which has a corresponding adjoint ODE. In the case when the ode was exact, we did not use an integrating factor (this is the same as saying the integrating factor was \(1\)), i.e. \(\mu \left ( x\right ) =1\).

But if the ode is not exact, then we look for integrating factor \(\mu \left ( x\right ) \) that when multiplied by the ode makes it exact and hence will have an adjoint ODE. Given \begin {equation} py^{\prime \prime }+q\left ( x\right ) y^{\prime }+r\left ( x\right ) y=f\left ( x\right ) \tag {1} \end {equation} Which is assumed not to be exact. Multiplying both sides by \(\mu \left ( x\right ) \) gives \(\mu \left ( py^{\prime \prime }+q\left ( x\right ) y^{\prime }+r\left ( x\right ) y\right ) =\mu f\left ( x\right ) \). Let \begin {equation} \mu \left ( py^{\prime \prime }+q\left ( x\right ) y^{\prime }+r\left ( x\right ) y\right ) =\left ( \mu py^{\prime }+By\right ) ^{\prime } \tag {2} \end {equation} Expanding gives\begin {align*} \mu \left ( py^{\prime \prime }+q\left ( x\right ) y^{\prime }+r\left ( x\right ) y\right ) & =\mu ^{\prime }py^{\prime }+\mu p^{\prime }y^{\prime }+\mu py^{\prime \prime }+B^{\prime }y+By^{\prime }\\ \mu py^{\prime \prime }+\mu qy^{\prime }+\mu ry & =\mu py^{\prime \prime }+y^{\prime }\left ( \mu ^{\prime }p+\mu p^{\prime }+B\right ) +yB^{\prime } \end {align*}

Comparing coefficients gives the following 2 equations\begin {align} \mu q & =\mu ^{\prime }p+\mu p^{\prime }+B\tag {2A}\\ \mu r & =B^{\prime } \tag {2B} \end {align}

Taking derivative of (2A) gives\[ \mu ^{\prime }q+\mu q^{\prime }=\mu ^{\prime \prime }p+\mu ^{\prime }p^{\prime }+\mu ^{\prime }p^{\prime }+\mu p^{\prime \prime }+B^{\prime }\] Substituting for \(B^{\prime }\) from (2B) into the above gives\begin {equation} \mu ^{\prime }q+\mu q^{\prime }=\mu ^{\prime \prime }p+\mu ^{\prime }p^{\prime }+\mu ^{\prime }p^{\prime }+\mu p^{\prime \prime }+\mu r \tag {3} \end {equation} Arranging\begin {equation} \mu ^{\prime \prime }p+\mu ^{\prime }\left ( 2p^{\prime }-q\right ) +\mu \left ( p^{\prime \prime }-q^{\prime }+r\right ) =0 \tag {4} \end {equation} The integrating factor \(\mu \) is the solution to the above ODE (called the adjoint ode also). Note that in (4), the term \(p^{\prime \prime }-q^{\prime }+r\) will  not be zero, as this is the condition for exactness, and this ode is not exact (else we will not need an integrating factor to start with).

We can obtain (4) directly from \(py^{\prime \prime }+qy^{\prime }+ry=0\). Since the relation between an ode and its adjoint ode is the following: given \[ py^{\prime \prime }+qy^{\prime }+ry=0 \] Its adjoint ode is \begin {align*} \left ( \left ( p\mu \right ) ^{\prime }-q\mu \right ) ^{\prime }+r\mu & =0\\ \left ( p\mu \right ) ^{\prime \prime }-\left ( q\mu \right ) ^{\prime }+r\mu & =0\\ \left ( p^{\prime }\mu +p\mu ^{\prime }\right ) ^{\prime }-\left ( q^{\prime }\mu +q\mu ^{\prime }\right ) +r\mu & =0\\ p^{\prime \prime }\mu +p^{\prime }\mu ^{\prime }+p^{\prime }\mu ^{\prime }+p\mu ^{\prime \prime }-q^{\prime }\mu -q\mu ^{\prime }+r\mu & =0\\ p\mu ^{\prime \prime }+\mu ^{\prime }\left ( 2p^{\prime }-q\right ) +\mu \left ( p^{\prime \prime }-q^{\prime }+r\right ) & =0 \end {align*}

We see this is the same as (4). In summary, an ode  \(py^{\prime \prime }+qy^{\prime }+ry=0\) has adjoint ode \(\left ( p\mu \right ) ^{\prime \prime }-\left ( q\mu \right ) ^{\prime }+r\mu =0\) where the solution to the adjoint ode makes the first ode exact. Once the integrating factor \(\mu \) is found then the first integral is given by \[ py^{\prime \prime }+qy^{\prime }+ry=\left ( \mu py^{\prime }+By\right ) ^{\prime }\] Where \begin {align*} B & =\mu q-\mu ^{\prime }p-\mu p^{\prime }\\ & =\mu \left ( q-p^{\prime }\right ) -\mu ^{\prime }p \end {align*}

Hence\begin {equation} py^{\prime \prime }+qy^{\prime }+ry=\left ( \mu py^{\prime }+\left ( \mu \left ( q-p^{\prime }\right ) -\mu ^{\prime }p\right ) y\right ) ^{\prime } \tag {5} \end {equation} There is a known relation between an ode and its adjoint ode given by \[ \mu \left ( py^{\prime \prime }+qy^{\prime }+ry\right ) -y\overline {\left ( py^{\prime \prime }+qy^{\prime }+ry\right ) }=\frac {d}{dx}\left ( P\left ( y,u\right ) \right ) \] Where the bar above the ode means its complex conjugate. The function \(P\left ( y,u\right ) \) is called the bilinear concomitant (see Murphy book, page 93). And is given by\[ P\left ( y,u\right ) =p\left ( y^{\prime }\mu -y\mu ^{\prime }\right ) +\left ( q-p^{\prime }\right ) y\mu \] Unfortunately, all this does not help us in solving the adjoint ode (4) in order to find the integrating factor \(\mu \). Since it will also be a second order ode which can be as hard to solve as the original ode. So this method is not practical as far as I can see unless the adjoint ODE comes out very simple to solve, but in all the examples I looked at, this was not the case.