Calculus &
Linear Algebra II

Chapter 3

3 Exact first order ODEs

By the end of this section, you should be able to answer the following questions about first order ODEs:

  • How do you identify an exact ODE?
  • How do you solve an exact ODE?






3.1 Definition

First recall that if $z = f(x, y)$ is a differentiable function of $x$ and $y$, where $x = g(t)$ and $y = h(t)$ are both differentiable functions of $t$, then $z$ is a differentiable function of $t$ whose derivative is given by the chain rule:

$\ds \frac{dz}{dt} = \frac{\partial f}{dx}\frac{dx}{dt} + \frac{\partial f}{\partial y}\frac{dy}{dt} $

Now suppose the equation \[ f(x,y)= C \] defines $y$ implicitly as a function of $x$ (here $C$ is a constant). Then $y = y(x)$ can be shown to satisfy a first order ODE obtained by using the chain rule above.


3.1 Definition

$\ds \frac{dz}{dt} = \frac{\partial f}{dx}\frac{dx}{dt} + \frac{\partial f}{\partial y}\frac{dy}{dt} $

Now suppose the equation \[ f(x,y)= C \] defines $y$ implicitly as a function of $x$ (here $C$ is a constant). Then $y = y(x)$ can be shown to satisfy a first order ODE obtained by using the chain rule above. In this case, $z = f(x, y(x)) = C,$ so

$\ds \frac{dz}{dx} = \frac{\partial f}{dx}\frac{dx}{dx} + \frac{\partial f}{\partial y}\frac{dy}{dx}$

$f_x + f_y y' =0.$         $(7)$



3.1 Definition

$f_x + f_y y' =0.$         $(7)$

A first order ODE of the form \[ P\left(x,y\right)+ Q\left(x,y\right) \frac{dy}{dx}=0 \qquad (8) \] is called exact, if there is a function $\,f(x, y)$ (compare $(8)$ with $(7)$ above) such that \[ f_x\left(x,y\right) = P\left(x,y\right) \quad \text{and}\quad f_y\left(x,y\right) = Q\left(x,y\right). \]

The solution is then given implicitly by the equation $\,f\left(x,y\right)=C.$ The constant $C$ can usually be determined by some kind of "initial condition".


3.1 Definition

$f_x + f_y y' =0.$         $(7)$

A first order ODE of the form \[ P\left(x,y\right)+ Q\left(x,y\right)\frac{dy}{dx}=0 \qquad (8) \] is called exact, if there is a function $\,f(x, y)$ (compare $(8)$ with $(7)$ above) such that \[ f_x\left(x,y\right) = P\left(x,y\right) \quad \text{and}\quad f_y\left(x,y\right) = Q\left(x,y\right). \]

The solution is then given implicitly by the equation $\,f\left(x,y\right)=C.$ The constant $C$ can usually be determined by some kind of “initial condition”.

🤔 Given an equation of the form $(8)$, how do we determine whether or not it is exact? There is a simple test.




3.2 Test for exactness

Let $P$, $Q$, and $\ds \frac{\partial Q}{\partial x}$ be continuous over some region of interest. Then \[ P\left( x, y\right)+ Q\left( x, y\right)\frac{dy}{dx}=0 \] is an exact ODE if and only if (iff) \[ \frac{\partial P}{\partial y} =\frac{\partial Q}{\partial x} \] everywhere in the region.


3.2 Test for exactness

Proof: $\nec$ Recall that $\ds \frac{\partial^2 f}{\partial x\partial y}=\frac{\partial^2 f}{\partial y\partial x}$ for a smooth function $\,f$. So if the ODE is exact, then there exists $\,f$ such that \[ f_x = \frac{\partial f}{\partial x} = P\left(x,y\right)\quad \text{and}\quad f_y = \frac{\partial f}{\partial y} = Q\left(x,y\right) \]

It follows that

$\ds \frac{\partial P}{\partial y}$ $\ds = \frac{\partial^2 f}{\partial y\partial x}$ $\ds = \frac{\partial^2 f}{\partial x\partial y}$ $\ds = \frac{\partial Q}{\partial x}.$ $\quad\blacksquare$



3.2 Test for exactness

Proof: $\suf\;$ If $\ds \frac{\partial P}{\partial y} = \frac{\partial Q}{\partial x},$ then we can always find $\,f$ such that $f_x=P\left(x,y\right)$ and $f_y=Q\left(x,y\right)$. Indeed, let \[ f\left(x,y\right)=\int_{x_0}^{x}P\left(s,y\right)ds + \int_{y_0}^{y}Q\left(x_0,t\right)dt \] for fixed $x_0,y_0$.





3.2 Test for exactness

Proof: $\suf\;$ 👉 $\ds \frac{\partial P}{\partial y} = \frac{\partial Q}{\partial x}.$

\[ \text{👉}\quad f\left(x,y\right)=\int_{x_0}^{x}P\left(s,y\right)ds + \int_{y_0}^{y}Q\left(x_0,t\right)dt \,\text{ for fixed }\, x_0,y_0. \]

Then

$\ds \,f_x$ $\ds = \frac{\partial }{\partial x}\left( \int_{x_0}^{x}P\left(s,y\right)ds + \int_{y_0}^{y}Q\left(x_0,t\right)dt \right)$ $\ds = P \left(x,y\right)$

$\ds f_y = \frac{\partial }{\partial y}\left( \int_{x_0}^{x}P\left(s,y\right)ds + \int_{y_0}^{y}Q\left(x_0,t\right)dt \right) \qquad\qquad $

$\ds f_y = \int_{x_0}^{x}\frac{\partial P\left(s,y\right)}{\partial y} ds + \frac{d}{dy} \int_{y_0}^{y}Q\left(x_0,t\right)dt\qquad \qquad$

$\ds f_y = \int_{x_0}^{x}\frac{\partial Q\left(s,y\right)}{\partial s} ds + Q\left(x_0,y\right)\qquad \qquad \qquad \quad\;\;$

$\ds f_y = Q\left(x,y\right)- Q\left(x_0,y\right)+ Q\left(x_0,y\right)$ $=Q\left(x,y\right).$ $ \quad\;\;\blacksquare$





3.2 Test for exactness

For this proof we used the function \[ f\left(x,y\right)=\int_{x_0}^{x}P\left(s,y\right)ds + \int_{y_0}^{y}Q\left(x_0,t\right)dt. \]

The problem of actually determining $f(x,y)$ is still outstanding.







3.3 Example: $2x+ e^y + x e^y y' = 0$

Here we have that $P = 2x+ e^y$ and $Q = xe^y$.

So $\ds \frac{\partial P}{\partial y}$ $= e^y$ $ = \ds \frac{\partial Q}{\partial x}$. This means it is an exact ODE.

So there exists $\,f$ such that

$(1)$ $\;\ds \frac{\partial f}{\partial x}=P$ $=2x+e^y$

$(2)$ $\;\ds \frac{\partial f}{\partial y}=Q$ $=xe^y$

$(1) \; \Ra \; f = x^2 + xe^y+ g(y)$

$\; \Ra \; \ds \frac{\partial f}{\partial y} = 0 + xe^y + \frac{dg(y)}{dy}$

Compare with $(2)$ above to obtain $\ds \frac{dg}{dy} = 0 $ $\;\Ra \;g(y) = C.$


3.3 Example: $2x+ e^y + x e^y y' = 0$

Compare with $(2)$ above to obtain $\ds \frac{dg}{dy} = 0 $ $\;\Ra \;g(y) = C.$

And since $f = x^2 + xe^y + g(y),$ then \[ f\left(x, y\right) = x^2 + xe^y + C. \]

This is an implicit solution: $x^2 + xe^y = K.$

You should check that computing the derivative in both sides, implies that the ODE is satisfied. 📝




3.3 Example: $2x+ e^y + x e^y y' = 0$

$x^2 + xe^y = K\;$ or $\;y = \ln \left(\frac{K-x^2}{x}\right)$


3.3 Example: $2x+ e^y + x e^y y' = 0$

$x^2 + xe^y = K\;$ or $\;y = \ln \left(\frac{K-x^2}{x}\right)$


3.4 Almost exact ODEs and integrating factors

Let's say that we have an equation \[ P\left(x,y\right) + Q\left(x,y\right) \frac{dy}{dx} = 0 \] such that $\ds \frac{\partial P}{\partial y}\neq \frac{\partial Q}{\partial x}. $

The test we have just seen tells us that the ODE is not exact. Are we still able to do anything with it? Here we consider using an “integrating factor”, which is different to the one introduced to solve linear ODEs.


3.4 Almost exact ODEs and integrating factors

The idea is to multiply the ODE by a function $h(x, y)$ and then see if it is possible to choose $h(x, y)$ such that the resulting equation \[ h\left(x,y\right) P\left(x,y\right) + h\left(x,y\right) Q\left(x,y\right) \frac{dy}{dx} = 0 \] is exact. We know from the test that this new equation is exact if and only if \[ \frac{\partial }{\partial y}\big(h P \big) = \frac{\partial }{\partial x}\big(h Q \big). \]

Let's see if we can find such a function:



3.4 Almost exact ODEs and integrating factors

Let's see if we can find such a function:

From $\ds \frac{\partial }{\partial y}\big(h P \big) = \frac{\partial }{\partial x}\big(h Q \big)$, we have that

$h_yP + h P_y$ $= h_xQ + h Q_x$

$h_yP - h_xQ + h\left(P_y- Q_x\right) = 0$

Partial differential equation for $h(x,y)$.

In general, the equation for $h(x, y)$ is usually just as difficult to solve as the original ODE. In some cases, however, we may be able to find an integrating factor which is a function of only one of the variables $x$ or $y$.


3.4 Almost exact ODEs and integrating factors

Let's try $h \equiv h(x)$:

Then we have that \[ \frac{dh}{dx} = h \left(\frac{P_y-Q_x}{Q}\right). \]

If more over $\ds \frac{P_y-Q_x}{Q}$ is a function of $x$ only, then this is a separable ODE and can be solved for $h(x)$.

Similarly for $h\equiv h(y)$.



3.5 Example: $\ds \left( 3xy+y^2 \right) + \left( x^2 + xy\right)\frac{dy}{dx}=0$

Here we have that $\ds \frac{\partial P }{\partial y} = 3x+2y$ and $\ds \frac{\partial Q}{\partial x} =2x+y$.

Then $\ds \frac{\partial P }{\partial y} \neq \frac{\partial Q}{\partial x} $ Thus, it is not exact! 😮   It seems to be almost exact?

Try for example $h\equiv h(x)\neq 0$, then $$\ds h\left(3xy+y^2\right)+h\left(x^2+xy\right)\frac{dy}{dx}=0$$




3.5 Example: $\ds \left( 3xy+y^2 \right) + \left( x^2 + xy\right)\frac{dy}{dx}=0$

Try for example $h\equiv h(x)\neq 0$, then $$\ds \overbrace{h\left(3xy+y^2\right)}^{{\large \hat P }}+\overbrace{h\left(x^2+xy\right)}^{{\large \hat Q}}\frac{dy}{dx}=0$$

is exact iff $\ds \frac{\partial \hat P }{\partial y} = \frac{\partial \hat Q}{\partial x}.$





3.5 Example: $\ds \left( 3xy+y^2 \right) + \left( x^2 + xy\right)\frac{dy}{dx}=0$

👉   $\ds h\left(3xy+y^2\right)+h\left(x^2+xy\right)\frac{dy}{dx}=0$

Then $\ds \frac{\partial \hat P}{\partial y} = h\left(3x+2y\right)$ $\ds =\frac{\partial \hat Q}{\partial x}$ $=h\left(2x+y\right) +h'\left(x^2+xy\right)$

Thus $h\left(x+y\right)$ $=h'x \left(x+y\right)$   or   $h = h' x$   $\Ra \;h' = \ds \frac{h}{x}$   $\Ra \;h = K x$ for any constant $K$. Choose $K=1$ to obtain a new ODE: \[ 3x^2y+xy^2+\left(x^3+x^2y\right)\frac{dy}{dx}=0 \]



3.5 Example: $\ds \left( 3xy+y^2 \right) + \left( x^2 + xy\right)\frac{dy}{dx}=0$

👉   $\ds h\left(3xy+y^2\right)+h\left(x^2+xy\right)\frac{dy}{dx}=0$

\[ \text{Exact ODE  👉   }\;3x^2y+xy^2+\left(x^3+x^2y\right)\frac{dy}{dx}=0 \] Note: its solution is given by $\ds x^3y+\frac{1}{2}x^2y^2=C.$ 📝





Credits