Exact differential equations

5.3. Exact differential equations#

Remember that a function \(f(x,y)\) has the total differential

(5.28)#\[\begin{equation} \d{f}= \td{}{f}{x}{y} \d{x} + \td{}{f}{y}{x} \d{y} \end{equation}\]

Also note that if \(f = c\) (a constant), then \(\d{f} = 0\). How does this apply to ODEs?

Suppose we can rewrite our ODE as

(5.29)#\[P(x,y) \d{x} + Q(x,y) \d{y} = 0\]

If we can show that

(5.30)#\[\begin{equation} P = \td{}{f}{x}{y} \qquad Q = \td{}{f}{y}{x} \end{equation}\]

for some \(f\), then we know that \(f(x,y) = c\) is an implicit solution of the ODE! We call ODEs with this property exact. But, how do we know if such a function exists and what it is?

Example: Test for exactness

Is the following differential equation exact?

(5.32)#\[\begin{equation} \cos(x+y) \d{x} + \left[3y^2 + 2y + \cos(x+y) \right]\d{y} = 0 \end{equation}\]

For the given ODE,

(5.33)#\[\begin{align} P &= \cos(x+y) \\ \td{}{P}{y}{x} &= -\sin(x+y) \end{align}\]

and

(5.34)#\[\begin{align} Q &= 3y^2 + 2y + \cos(x+y) \\ \td{}{Q}{x}{y} &= -\sin(x+y) \end{align}\]

Since these partial derivatives match, the ODE is exact.

If an ODE is exact, we can integrate P or Q to get f, then solve for the integration constant with Q or P. For the ODE given by Eq. (5.32), first integrate P with respect to x:

(5.35)#\[\begin{align} f &= \int P \d{x} \\ &= \int \cos(x+y) \d{x} \\ &= \sin(x+y) + k(y) \end{align}\]

Note that this integration adds an unknown function k of the variable that was held constant (in this case, y). To determine this function, differentiate and equate with Q:

(5.36)#\[\begin{align} \td{}{f}{y}{x} &= Q \\ \cos(x+y) + k' &= 3y^2+2y+\cos(x+y) \\ k' &= 3y^2+2y \end{align}\]

This is a first-order ODE for k that can be solved using separation of variables:

(5.37)#\[\begin{align} \int \d{k} &= \int (3y^2+2y) \d{y} \\ k &= y^3 + y^2 + k_0 \end{align}\]

where \(k_0\) is another unknown integration constant. Since we know that the ODE was exact, the solution f must be equal to a constant c:

(5.38)#\[\begin{align} f = \sin(x+y) + y^3 +y^2 + k_0 = c \end{align}\]

Note that the coefficient \(k_0\) can be absorbed into c. This will be a common pattern for these problems, so moving forward, we will neglect writing the integration constant for k. The general, implicit solution to the ODE is:

(5.39)#\[\begin{equation} \sin(x+y) + y^3 + y^2 = c \end{equation}\]

Note that order of integration does not matter. We could also have integrated with respect to y first

(5.40)#\[\begin{align} f &=\int Q \d{y} \\ &= \int \left[3y^2+2y+\cos(x+y) \right] \d{y} \\ &=y^3+y^2+\sin(x+y)+k(x) \end{align}\]

Then differentiated with respect to x and equated with P:

(5.41)#\[\begin{align} \td{}{f}{x}{y} &= P \\ \cos(x+y) + k' &= \cos(x+y) \\ k'&=0 \end{align}\]

giving \(k = k_0\). Substituting, we arrive at the same answer!

5.3.1. Skill builder problems#

Obtain general solutions to:

  1. \(-2xy \sin( x^2) \d{x} + \cos(x^2) \d{y} = 0\)

    Solution

    The ODE is already in the standard form so

    (5.42)#\[\begin{align} P &= -2xy \sin(x^2) \\ Q &= \cos(x^2) \\ \end{align}\]

    Check to see if the ODE is exact:

    (5.43)#\[\begin{align} \td{}{P}{y}{x} &= -2x \sin(x^2) \\ \td{}{Q}{x}{y} &= -2x \sin(x^2) \end{align}\]

    The two partial derivatives are equal, so the ODE is exact. You can proceed directly to integration. First, integrate Q with respect y

    (5.44)#\[\begin{equation} f(x,y) = \int \cos(x^2) \d{y} = y \cos(x^2) + k(x) \end{equation}\]

    where k is an unknown function of x. Then, differentiate f with respect to x and compare to P:

    (5.45)#\[\begin{align} \td{}{f}{x}{y} = -2xy \sin(x^2) + k'(x) &= P = -2xy \sin(x^2) \\ k'(x) &= 0 \end{align}\]

    This simple ODE has \(k = 0\) as a solution (neglecting the integration constant). Putting it all together,

    (5.46)#\[\begin{equation} f = y \cos(x^2) = c \end{equation}\]

    is an implicit solution of the ODE, which we can manipulate to an explicit solution:

    (5.47)#\[\begin{equation} y = \frac{c}{\cos(x^2)} \end{equation}\]
  2. \(y' = \dfrac{x^4 + y^2}{xy}\)

    Solution

    This ODE is not in the standard form, so we need to first rearrange:

    (5.48)#\[\begin{align} xy \d{y} = (x^4+y^2) \d{x} \\ (x^4 + y^2) \d{x} - xy \d{y} = 0 \end{align}\]

    so:

    (5.49)#\[\begin{align} P &= x^4 + y^2 \\ Q &= -xy \end{align}\]

    Check to see if the ODE is exact:

    (5.50)#\[\begin{align} \td{}{P}{y}{x} &= 2y \\ \td{}{Q}{x}{y} &= -y \end{align}\]

    The two partial derivatives are not equal, so the ODE is not exact. In order to make it exact, we need to find an integrating factor F. First, compute:

    (5.51)#\[\begin{align} R &= \frac{1}{Q}\left[\td{}{P}{y}{x} - \td{}{Q}{x}{y} \right] \\ &=\frac{1}{-xy}(2y-(-y)) \\ &= -\frac{3}{x} \end{align}\]

    R is a function of only x, so use it to compute F

    (5.52)#\[\begin{equation} F = \exp\left(\int \frac{-3}{x} \d{x}\right) = e^{-3\ln(x)} = x^{-3} \end{equation}\]

    Apply the integrating factor to the original ODE:

    (5.53)#\[\begin{align} x^{-3}(x^4+y^2) \d{x} - x^{-3}(xy) \d{y} &= 0 \\ \left(x+\frac{y^2}{x^{-3}}\right) \d{x} - \frac{y}{x^2} \d{y} &= 0 \end{align}\]

    Integrate the Q of our exact ODE with respect to y:

    (5.54)#\[\begin{equation} f(x,y) = \int -\frac{y}{x^2} \d{y} = \frac{-y^2}{2x^2}+k(x) \end{equation}\]

    where k is an unknown function of x. Then, differentiate f with respect to x and compare to P of the exact ODE:

    (5.55)#\[\begin{align} \td{}{f}{x}{y} = \frac{y^2}{x^3} + k'(x) &= P = x + \frac{y^2}{x^3} \\ k'(x) &= x \\ \end{align}\]

    This ODE for k can be integrated directly (neglecting the integration constant)

    (5.56)#\[\begin{equation} k = \int x \d{x} = \frac{x^2}{2} \end{equation}\]

    Putting it all together,

    (5.57)#\[\begin{align} f = \frac{-y^2}{2x^2} + \frac{x^2}{2} = c \end{align}\]

    is an implicit solution of the ODE.