Exact linear second order ode \(p\left ( x\right ) y^{\prime \prime }+q\left ( x\right ) y^{\prime }+r\left ( x\right ) y=0\)
Example 1
Example 2

ode internal name "exact_linear_second_order_ode"

Given the ode\begin {equation} p\left ( x\right ) y^{\prime \prime }+q\left ( x\right ) y^{\prime }+r\left ( x\right ) y=0 \tag {1} \end {equation} We want to first find the condition for exactness. This is the same as saying the above ode has a corresponding adjoint ode, which is \(\left ( py^{\prime }+B\left ( x\right ) y\right ) ^{\prime }=0\). i.e. if an ode \(p\left ( x\right ) y^{\prime \prime }+q\left ( x\right ) y^{\prime }+r\left ( x\right ) y=0\) can be written in the form \(\left ( py^{\prime }+B\left ( x\right ) y\right ) ^{\prime }=0\) for some \(B\left ( x\right ) \) then the ode \(\left ( py^{\prime }+By\right ) ^{\prime }=0\) is called the adjoint of \(py^{\prime \prime }+qy^{\prime }+ry=0\) which is the same thing as saying the ode \(p\left ( x\right ) y^{\prime \prime }+q\left ( x\right ) y^{\prime }+r\left ( x\right ) y=0\) is exact. i.e. it has complete differential.

The goal therefore is to determine if a linear second order ode has a corresponding adjoint ODE or not of the form \(\left ( py^{\prime }+B\left ( x\right ) y\right ) ^{\prime }=0\). If so, then it is exact and we can solve it by solving the adjoint ODE instead since it is much simpler to solve as it is a first order ODE. Lets see how to find the adjoint ODE.

Let \[ py^{\prime \prime }+q\left ( x\right ) y^{\prime }+r\left ( x\right ) y=\left ( py^{\prime }+By\right ) ^{\prime }\] Expanding gives\[ py^{\prime \prime }+qy^{\prime }+ry=p^{\prime }y^{\prime }+py^{\prime \prime }+B^{\prime }y+By^{\prime }\] Comparing coefficients\begin {align*} q & =p^{\prime }+B\\ r & =B^{\prime } \end {align*}

Differentiating the first ode gives \(q^{\prime }=p^{\prime \prime }+B^{\prime }\). Using the second ode gives \(q^{\prime }=p^{\prime \prime }+r\) or \begin {equation} p^{\prime \prime }-q^{\prime }+r=0 \tag {2} \end {equation} This is the condition for exactness. i.e. if the input ODE (1) satisfies (2) then the ODE is exact and has an adjoint ODE of the form \(\left ( py^{\prime }+By\right ) ^{\prime }=0\) which we now can be easily solve since it is complete differential.\begin {align} \left ( py^{\prime }+B\left ( x\right ) y\right ) ^{\prime } & =0\nonumber \\ \left ( py^{\prime }+\left ( q-p^{\prime }\right ) y\right ) ^{\prime } & =0 \tag {3} \end {align}

We see that solving (3) is much simpler than (1) since (3) is first order.  Integrating this once gives\[ py^{\prime }+\left ( q-p^{\prime }\right ) y=c \] This is first order ode. This is also called the first integral equation of (1). In summary, given an ode \(py^{\prime \prime }+qy^{\prime }+ry=0\) which is exact, then its first integral is \(py^{\prime }+\left ( q-p^{\prime }\right ) y=c\) and the solution to this is the solution to the original second order ode.