## Section1.8Exact equations

Note: 1–2 lectures, can safely be skipped, §1.6 in [EP], §2.6 in [BD]

Another type of equation that comes up quite often in physics and engineering is an exact equation. Suppose $F(x,y)$ is a function of two variables, which we call the potential function. The naming should suggest potential energy, or electric potential. Exact equations and potential functions appear when there is a conservation law at play, such as conservation of energy. Let us make up a simple example. Let

\begin{equation*} F(x,y) = x^2+y^2 . \end{equation*}

We are interested in the lines of constant energy, that is lines where the energy is conserved; we want curves where $F(x,y) = C\text{,}$ for some constant $C\text{.}$ In our example, the curves $x^2+y^2=C$ are circles. See Figure 2.8.1.

We take the total derivative of $F\text{:}$

\begin{equation*} dF = \frac{\partial F}{\partial x} dx + \frac{\partial F}{\partial y} dy . \end{equation*}

For convenience, we will make use of the notation of $F_x = \frac{\partial F}{\partial x}$ and $F_y = \frac{\partial F}{\partial y}\text{.}$ In our example,

\begin{equation*} dF = 2x \, dx + 2y \, dy . \end{equation*}

We apply the total derivative to $F(x,y) = C\text{,}$ to find the differential equation $dF = 0\text{.}$ The differential equation we obtain in such a way has the form

\begin{equation*} M \, dx + N \, dy = 0, \qquad \text{or} \qquad M + N \, \frac{dy}{dx} = 0 . \end{equation*}

An equation of this form is called exact if it was obtained as $dF = 0$ for some potential function $F\text{.}$ In our simple example, we obtain the equation

\begin{equation*} 2x \, dx + 2y \, dy = 0, \qquad \text{or} \qquad 2x + 2y \, \frac{dy}{dx} = 0 . \end{equation*}

Since we obtained this equation by differentiating $x^2+y^2=C\text{,}$ the equation is exact. We often wish to solve for $y$ in terms of $x\text{.}$ In our example,

\begin{equation*} y = \pm \sqrt{C^2-x^2} . \end{equation*}

An interpretation of the setup is that at each point $\vec{v} = (M,N)$ is a vector in the plane, that is, a direction and a magnitude. As $M$ and $N$ are functions of $(x,y)\text{,}$ we have a vector field. The particular vector field $\vec{v}$ that comes from an exact equation is a so-called conservative vector field, that is, a vector field that comes with a potential function $F(x,y)\text{,}$ such that

\begin{equation*} \vec{v} = \left( \frac{\partial F}{\partial x} ,\frac{\partial F}{\partial y} \right) . \end{equation*}

Let $\gamma$ be a path in the plane starting at $(x_1,y_1)$ and ending at $(x_2,y_2)\text{.}$ If we think of $\vec{v}$ as force, then the work required to move along $\gamma$ is

\begin{equation*} \int_\gamma \vec{v}(\vec{r}) \cdot d\vec{r} = \int_\gamma M \, dx + N \, dy = F(x_2,y_2) - F(x_1,y_1) . \end{equation*}

That is, the work done only depends on endpoints, that is where we start and where we end. For example, suppose $F$ is gravitational potential. The derivative of $F$ given by $\vec{v}$ is the gravitational force. What we are saying is that the work required to move a heavy box from the ground floor to the roof, only depends on the change in potential energy. That is, the work done is the same no matter what path we took; if we took the stairs or the elevator. Although if we took the elevator, the elevator is doing the work for us. The curves $F(x,y) = C$ are those where no work need be done, such as the heavy box sliding along without accelerating or breaking on a perfectly flat roof, on a cart with incredibly well oiled wheels.

An exact equation is a conservative vector field, and the implicit solution of this equation is the potential function.

### Subsection1.8.1Solving exact equations

Now you, the reader, should ask: Where did we solve a differential equation? Well, in applications we generally know $M$ and $N\text{,}$ but we do not know $F\text{.}$ That is, we may have just started with $2x + 2y \frac{dy}{dx} = 0\text{,}$ or perhaps even

\begin{equation*} x + y \frac{dy}{dx} = 0 . \end{equation*}

It is up to us to find some potential $F$ that works. Many different $F$ will work; adding a constant to $F$ does not change the equation. Once we have a potential function $F\text{,}$ the equation $F\bigl(x,y(x)\bigr) = C$ gives an implicit solution of the ODE.

###### Example1.8.1.

Let us find the general solution to $2x + 2y \frac{dy}{dx} = 0\text{.}$ Forget we knew what $F$ was.

If we know that this is an exact equation, we start looking for a potential function $F\text{.}$ We have $M = 2x$ and $N=2y\text{.}$ If $F$ exists, it must be such that $F_x (x,y) = 2x\text{.}$ Integrate in the $x$ variable to find

$$F(x,y) = x^2 + A(y) ,\label{eq_exact_fint}\tag{5}$$

for some function $A(y)\text{.}$ The function $A$ is the “constant of integration”, though it is only constant as far as $x$ is concerned, and may still depend on $y\text{.}$ Now differentiate (5) in $y$ and set it equal to $N\text{,}$ which is what $F_y$ is supposed to be:

\begin{equation*} 2y = F_y (x,y) = A'(y) . \end{equation*}

Integrating, we find $A(y) = y^2\text{.}$ We could add a constant of integration if we wanted to, but there is no need. We found $F(x,y) = x^2+y^2\text{.}$ Next for a constant $C\text{,}$ we solve

\begin{equation*} F\bigl(x,y(x)\bigr) = C . \end{equation*}

for $y$ in terms of $x\text{.}$ In this case, we obtain $y = \pm \sqrt{C^2-x^2}$ as we did before.

###### Exercise1.8.1.

Why did we not need to add a constant of integration when integrating $A'(y) = 2y\text{?}$ Add a constant of integration, say $3\text{,}$ and see what $F$ you get. What is the difference from what we got above, and why does it not matter?

The procedure, once we know that the equation is exact, is:

1. Integrate $F_x = M$ in $x$ resulting in $F(x,y) = \text{something} + A(y)\text{.}$

2. Differentiate this $F$ in $y\text{,}$ and set that equal to $N\text{,}$ so that we may find $A(y)$ by integration.

The procedure can also be done by first integrating in $y$ and then differentiating in $x\text{.}$ Pretty easy huh? Let's try this again.

###### Example1.8.2.

Consider now $2x+y + xy \frac{dy}{dx} = 0\text{.}$

OK, so $M = 2x+y$ and $N=xy\text{.}$ We try to proceed as before. Suppose $F$ exists. Then $F_x (x,y) = 2x+y\text{.}$ We integrate:

\begin{equation*} F(x,y) = x^2 + xy + A(y) \end{equation*}

for some function $A(y)\text{.}$ Differentiate in $y$ and set equal to $N\text{:}$

\begin{equation*} N = xy = F_y (x,y) = x+A'(y) . \end{equation*}

But there is no way to satisfy this requirement! The function $xy$ cannot be written as $x$ plus a function of $y\text{.}$ The equation is not exact; no potential function $F$ exists.

Is there an easier way to check for the existence of $F\text{,}$ other than failing in trying to find it? Turns out there is. Suppose $M = F_x$ and $N = F_y\text{.}$ Then as long as the second derivatives are continuous,

\begin{equation*} \frac{\partial M}{\partial y} = \frac{\partial^2 F}{\partial y \partial x} = \frac{\partial^2 F}{\partial x \partial y} = \frac{\partial N}{\partial x} . \end{equation*}

Let us state it as a theorem. Usually this is called the Poincarè Lemma 1 .

Named for the French polymath Jules Henri Poincarè (1854–1912).

The theorem doesn't give us a global $F$ defined everywhere. In general, we can only find the potential locally, near some initial point. By this time, we have come to expect this from differential equations.

Let us return to the example above where $M = 2x + y$ and $N = xy\text{.}$ Notice $M_y = 1$ and $N_x = y\text{,}$ which are clearly not equal. The equation is not exact.

###### Example1.8.3.

Solve

\begin{equation*} \frac{dy}{dx} = \frac{-2x-y}{x-1}, \qquad y(0) = 1. \end{equation*}

We write the equation as

\begin{equation*} (2x+y) + (x-1)\frac{dy}{dx} = 0 , \end{equation*}

so $M = 2x+y$ and $N = x-1\text{.}$ Then

\begin{equation*} M_y = 1 = N_x . \end{equation*}

The equation is exact. Integrating $M$ in $x\text{,}$ we find

\begin{equation*} F(x,y) = x^2+xy + A(y) . \end{equation*}

Differentiating in $y$ and setting to $N\text{,}$ we find

\begin{equation*} x-1 = x + A'(y) . \end{equation*}

So $A'(y) = -1\text{,}$ and $A(y) = -y$ will work. Take $F(x,y) = x^2+xy-y\text{.}$ We wish to solve $x^2+xy-y = C\text{.}$ First let us find $C\text{.}$ As $y(0)=1$ then $F(0,1) = C\text{.}$ Therefore $0^2+0\times 1 - 1 = C\text{,}$ so $C=-1\text{.}$ Now we solve $x^2+xy-y = -1$ for $y$ to get

\begin{equation*} y = \frac{-x^2-1}{x-1} . \end{equation*}
###### Example1.8.4.

Solve

\begin{equation*} -\frac{y}{x^2+y^2} dx + \frac{x}{x^2+y^2} dy = 0 , \qquad y(1) = 2. \end{equation*}

We leave to the reader to check that $M_y = N_x\text{.}$

This vector field $(M,N)$ is not conservative if considered as a vector field of the entire plane minus the origin. The problem is that if the curve $\gamma$ is a circle around the origin, say starting at $(1,0)$ and ending at $(1,0)$ going counterclockwise, then if $F$ existed we would expect

\begin{equation*} 0 = F(1,0) - F(1,0) = \int_\gamma F_x \, dx + F_y \, dy = \int_\gamma \frac{-y}{x^2+y^2} \, dx + \frac{x}{x^2+y^2} \, dy = 2\pi . \end{equation*}

That is nonsense! We leave the computation of the path integral to the interested reader, or you can consult your multivariable calculus textbook. So there is no potential function $F$ defined everywhere outside the origin $(0,0)\text{.}$

If we think back to the theorem, it does not guarantee such a function anyway. It only guarantees a potential function locally, that is only in some region near the initial point. As $y(1) = 2$ we start at the point $(1,2)\text{.}$ Considering $x > 0$ and integrating $M$ in $x$ or $N$ in $y\text{,}$ we find

\begin{equation*} F(x,y) = \operatorname{arctan} \bigl( \nicefrac{y}{x} \bigr) . \end{equation*}

The implicit solution is $\operatorname{arctan} \bigl( \nicefrac{y}{x} \bigr) = C\text{.}$ Solving, $y = \tan(C) x\text{.}$ That is, the solution is a straight line. Solving $y(1) = 2$ gives us that $\tan(C) = 2\text{,}$ and so $y= 2x$ is the desired solution. See Figure 2.8.8, and note that the solution only exists for $x > 0\text{.}$

###### Example1.8.5.

Solve

\begin{equation*} x^2+y^2 + 2y(x+1) \frac{dy}{dx} = 0 . \end{equation*}

The reader should check that this equation is exact. Let $M= x^2+y^2$ and $N=2y(x+1)\text{.}$ We follow the procedure for exact equations

\begin{equation*} F(x,y) = \frac{1}{3}x^3 + xy^2 + A(y) , \end{equation*}

and

\begin{equation*} 2y(x+1) = 2xy + A'(y) . \end{equation*}

Therefore $A'(y) = 2y$ or $A(y) = y^2$ and $F(x,y) = \frac{1}{3}x^3 + xy^2 + y^2\text{.}$ We try to solve $F(x,y) = C\text{.}$ We easily solve for $y^2$ and then just take the square root:

\begin{equation*} y^2 = \frac{C-(\nicefrac{1}{3})x^3}{x+1}, \qquad \text{so} \qquad y = \pm \sqrt{\frac{C-(\nicefrac{1}{3})x^3}{x+1}} . \end{equation*}

When $x=-1\text{,}$ the term in front of $\frac{dy}{dx}$ vanishes. You can also see that our solution is not valid in that case. However, one could in that case try to solve for $x$ in terms of $y$ starting from the implicit solution $\frac{1}{3}x^3 + xy^2 + y^2 = C\text{.}$ The solution is somewhat messy and we leave it as implicit.

### Subsection1.8.2Integrating factors

Sometimes an equation $M\, dx + N \, dy = 0$ is not exact, but it can be made exact by multiplying with a function $u(x,y)\text{.}$ That is, perhaps for some nonzero function $u(x,y)\text{,}$

\begin{equation*} u(x,y) M(x,y) \, dx + u(x,y) N(x,y) \, dy = 0 \end{equation*}

is exact. Any solution to this new equation is also a solution to $M\, dx + N \, dy = 0\text{.}$

In fact, a linear equation

\begin{equation*} \frac{dy}{dx} + p(x) y = f(x), \qquad \text{or} \qquad \bigl( p(x) y - f(x) \bigr)\, dx + dy = 0 \end{equation*}

is always such an equation. Let $r(x) = e^{\int p(x)\,dx}$ be the integrating factor for a linear equation. Multiply the equation by $r(x)$ and write it in the form of $M + N \frac{dy}{dx} = 0\text{.}$

\begin{equation*} r(x) p(x) y - r(x) f(x) + r(x) \frac{dy}{dx} = 0 . \end{equation*}

Then $M = r(x) p(x) y - r(x) f(x)\text{,}$ so $M_y = r(x) p(x)\text{,}$ while $N = r(x)\text{,}$ so $N_x = r'(x) = r(x) p(x)\text{.}$ In other words, we have an exact equation. Integrating factors for linear functions are just a special case of integrating factors for exact equations.

But how do we find the integrating factor $u\text{?}$ Well, given an equation

\begin{equation*} M \, dx + N \, dy = 0 , \end{equation*}

$u$ should be a function such that

\begin{equation*} \frac{\partial}{\partial y} \bigl[ u M \bigr] = u_y M + u M_y = \frac{\partial}{\partial x} \bigl[ u N \bigr] = u_x N + u N_x . \end{equation*}

Therefore,

\begin{equation*} (M_y-N_x)u = u_x N - u_y M . \end{equation*}

At first it may seem we replaced one differential equation by another. True, but all hope is not lost.

A strategy that often works is to look for a $u$ that is a function of $x$ alone, or a function of $y$ alone. If $u$ is a function of $x$ alone, that is $u(x)\text{,}$ then we write $u'(x)$ instead of $u_x\text{,}$ and $u_y$ is just zero. Then

\begin{equation*} \frac{M_y-N_x}{N}u = u' . \end{equation*}

In particular, $\frac{M_y-N_x}{N}$ ought to be a function of $x$ alone (not depend on $y$). If so, then we have a linear equation

\begin{equation*} u' - \frac{M_y-N_x}{N} u = 0 . \end{equation*}

Letting $P(x) = \frac{M_y-N_x}{N}\text{,}$ we solve using the standard integrating factor method, to find $u(x) = C e^{\int P(x) \, dx}\text{.}$ The constant in the solution is not relevant, we need any nonzero solution, so we take $C=1\text{.}$ Then $u(x) = e^{\int P(x) \, dx}$ is the integrating factor.

Similarly we could try a function of the form $u(y)\text{.}$ Then

\begin{equation*} \frac{M_y-N_x}{M} u = - u' . \end{equation*}

In particular, $\frac{M_y-N_x}{M}$ ought to be a function of $y$ alone. If so, then we have a linear equation

\begin{equation*} u' + \frac{M_y-N_x}{M} u = 0 . \end{equation*}

Letting $Q(y) = \frac{M_y-N_x}{M}\text{,}$ we find $u(y) = C e^{-\int Q(y) \, dy}\text{.}$ We take $C=1\text{.}$ So $u(y) = e^{-\int Q(y) \, dy}$ is the integrating factor.

###### Example1.8.6.

Solve

\begin{equation*} \frac{x^2+y^2}{x+1} + 2y \frac{dy}{dx} = 0 . \end{equation*}

Let $M= \frac{x^2+y^2}{x+1}$ and $N=2y\text{.}$ Compute

\begin{equation*} M_y-N_x = \frac{2y}{x+1} - 0 = \frac{2y}{x+1} . \end{equation*}

As this is not zero, the equation is not exact. We notice

\begin{equation*} P(x) = \frac{M_y-N_x}{N} = \frac{2y}{x+1} \frac{1}{2y} = \frac{1}{x+1} \end{equation*}

is a function of $x$ alone. We compute the integrating factor

\begin{equation*} e^{\int P(x) \, dx} = e^{\ln (x+1)} = x+1 . \end{equation*}

We multiply our given equation by $(x+1)$ to obtain

\begin{equation*} x^2+y^2 + 2y(x+1) \frac{dy}{dx} = 0 , \end{equation*}

which is an exact equation that we solved in Example 1.8.5. The solution was

\begin{equation*} y = \pm \sqrt{\frac{C-(\nicefrac{1}{3})x^3}{x+1}} . \end{equation*}
###### Example1.8.7.

Solve

\begin{equation*} y^2 + (xy+1) \frac{dy}{dx} = 0 . \end{equation*}

First compute

\begin{equation*} M_y-N_x = 2y-y = y . \end{equation*}

As this is not zero, the equation is not exact. We observe

\begin{equation*} Q(y) = \frac{M_y-N_x}{M} = \frac{y}{y^2} = \frac{1}{y} \end{equation*}

is a function of $y$ alone. We compute the integrating factor

\begin{equation*} e^{-\int Q(y) \, dy} = e^{-\ln y} = \frac{1}{y} . \end{equation*}

Therefore we look at the exact equation

\begin{equation*} y + \frac{xy+1}{y} \frac{dy}{dx} = 0 . \end{equation*}

The reader should double check that this equation is exact. We follow the procedure for exact equations

\begin{equation*} F(x,y) = xy + A(y) , \end{equation*}

and

$$\frac{xy+1}{y} = x+\frac{1}{y} = x+ A'(y) .\tag{6}$$

Consequently $A'(y) = \frac{1}{y}$ or $A(y) = \ln y\text{.}$ Thus $F(x,y) = xy + \ln y\text{.}$ It is not possible to solve $F(x,y)=C$ for $y$ in terms of elementary functions, so let us be content with the implicit solution:

\begin{equation*} xy + \ln y = C . \end{equation*}

We are looking for the general solution and we divided by $y$ above. We should check what happens when $y=0\text{,}$ as the equation itself makes perfect sense in that case. We plug in $y=0$ to find the equation is satisfied. So $y=0$ is also a solution.

### Subsection1.8.3Exercises

###### Exercise1.8.2.

Solve the following exact equations, implicit general solutions will suffice:

1. $(2 xy + x^2) \, dx + (x^2+y^2+1) \, dy = 0$

2. $x^5 + y^5 \frac{dy}{dx} = 0$

3. $e^x+y^3 + 3xy^2 \frac{dy}{dx} = 0$

4. $(x+y)\cos(x)+\sin(x) + \sin(x)y' = 0$

###### Exercise1.8.3.

Find the integrating factor for the following equations making them into exact equations:

1. $e^{xy} \, dx + \frac{y}{x} e^{xy} \, dy = 0$

2. $\frac{e^x+y^3}{y^2} \, dx + 3x \, dy = 0$

3. $4(y^2+x) \, dx + \frac{2x+2y^2}{y} \, dy = 0$

4. $2\sin(y) \, dx + x\cos(y)\, dy = 0$

###### Exercise1.8.4.

Suppose you have an equation of the form: $f(x) + g(y) \frac{dy}{dx} = 0\text{.}$

1. Show it is exact.

2. Find the form of the potential function in terms of $f$ and $g\text{.}$

###### Exercise1.8.5.

Suppose that we have the equation $f(x) \, dx - dy = 0\text{.}$

1. Is this equation exact?

2. Find the general solution using a definite integral.

###### Exercise1.8.6.

Find the potential function $F(x,y)$ of the exact equation $\frac{1+xy}{x}\, dx + \bigl(\nicefrac{1}{y} + x \bigr) \, dy = 0$ in two different ways.

1. Integrate $M$ in terms of $x$ and then differentiate in $y$ and set to $N\text{.}$

2. Integrate $N$ in terms of $y$ and then differentiate in $x$ and set to $M\text{.}$

###### Exercise1.8.7.

A function $u(x,y)$ is said to be a harmonic function if $u_{xx} + u_{yy} = 0\text{.}$

1. Show that $-u_y \, dx + u_x \, dy = 0$ is an exact equation. Therefore there exists (at least locally) the so-called harmonic conjugate function $v(x,y)$ such that $v_x = -u_y$ and $v_y = u_x\text{.}$

Verify that the following $u$ are harmonic and find the corresponding harmonic conjugates $v\text{:}$

1. $u = 2xy$

2. $u = e^x \cos y$

3. $u = x^3-3xy^2$

###### Exercise1.8.101.

Solve the following exact equations, implicit general solutions will suffice:

1. $\cos(x)+ye^{xy} + xe^{xy} y' = 0$

2. $(2x+y)\, dx + (x-4y) \, dy = 0$

3. $e^x + e^y \frac{dy}{dx} = 0$

4. $(3x^2+3y)\,dx + (3y^2+3x)\, dy = 0$

a) $e^{xy}+\sin(x)=C$     b) $x^2+xy-2y^2=C$     c) $e^x+e^y=C$     d) $x^3 + 3xy+ y^3 = C$

###### Exercise1.8.102.

Find the integrating factor for the following equations making them into exact equations:

1. $\frac{1}{y}\, dx + 3y \, dy = 0$

2. $dx - e^{-x-y} \, dy = 0$

3. $\bigl( \frac{\cos(x)}{y^2} + \frac{1}{y} \bigr) \, dx + \frac{x}{y^2} \, dy = 0$

4. $\bigl( 2y + \frac{y^2}{x} \bigr) \, dx + ( 2y+x )\, dy = 0$

a) Integrating factor is $y\text{,}$ equation becomes $dx + 3y^2\,dy = 0\text{.}$     b) Integrating factor is $e^x\text{,}$ equation becomes $e^x \, dx - e^{-y}\,dy = 0\text{.}$     c) Integrating factor is $y^2\text{,}$ equation becomes $(\cos(x)+y)\, dx + x\,dy = 0\text{.}$     d) Integrating factor is $x\text{,}$ equation becomes $( 2xy+y^2 )\, dx + (x^2+2xy)\,dy = 0\text{.}$

###### Exercise1.8.103.

1. Show that every separable equation $y' = f(x)g(y)$ can be written as an exact equation, and verify that it is indeed exact.

2. Using this rewrite $y' = xy$ as an exact equation, solve it and verify that the solution is the same as it was in Example 1.3.1.

a) The equation is $- f(x) \, dx + \frac{1}{g(y)} \, dy\text{,}$ and this is exact because $M = -f(x)\text{,}$ $N = \frac{1}{g(y)}\text{,}$ so $M_y = 0 = N_x\text{.}$     b) $-x \, dx + \frac{1}{y} \, dy = 0\text{,}$ leads to potential function $F(x,y) = -\frac{x^2}{2} + \ln \lvert y \rvert\text{,}$ solving $F(x,y) = C$ leads to the same solution as the example.