# Exact Equations

Differential equation `M(x,y)dx+N(x,y)dy=0` is exact if there exist function f such that `df=M(x,y)dx+N(x,y)dy` .

In this case equation can be rewritten as `df=0` which gives solution f=C.

**Test for exactness:** if M(x,y) and N(x,y) are continuous functions and have continuous first partial derivatives on some rectangle of the xy-plane, then differential equation is exact if and only if `(partial M(x,y))/(partial y)=(partial N(x,y))/(partial x)`.

To solve this equation we use the facts that `(partial f(x,y))/(partial x)=M(x,y)` and `(partial f(x,y))/(partial y)=N(x,y)`. We integrate first equation with respect to x to obtain `f(x,y)` through x and unknown function g(y). We then differentiate result with respect to y and use second equation. After this we find g(y) and thus f(x,y). Solution, as already stated above, is given as `f(x,y)=C` .

Example 1. Solve `(x+sin(y))dx+(x cos(y)-2y)dy=0`

Here `M(x,y)=x+sin(y)` , `N(x,y)=xcos(y)-2y` . Since `(partial M)/(partial y)=cos(y)` and `(partial N)/(partial x)=cos(y)` then `(partial M)/(partial y)=(partial N)/(partial x)` and differential equation is exact.

Thus, there exist function f such that `(partial f)/(partial x)=M(x,y)=x+sin(y)` and `(partial f)/(partial y)=N(x,y)=xcos(y)-2y` .

Integrate first equation with respect to x to obtain that `f=int (x+sin(y))dx=1/2 x^2+xsin(y)+g(y)` .

Note that here constant of integration can depend on y (because we integrate with respect to x).

Now diffetiate resulting equation with respect to y:

`(partial f)/(partial y)=0+xcos(y)+g'(y)` .

From another side `(partial f)/(partial y)=N(x,y)=xcos(y)-2y`

So, `xcos(y)+g'(y)=xcos(y)-2y` , or `g'(y)=-2y` . Integrating it we obtain that `g(y)=-y^2+c_1` .

Thus,

`f=1/2 x^2+xsin(y)-y^2+c_1` . Solution is given as `1/2 x^2 +xsin(y)-y^2+c_1=C`

Or `1/2 x^2 +xsin(y)-y^2=c_2` where (`c_2=C-c_1` ).

We obtain implicit solution and there is no way to find explicit solution.

Example 2. Solve `y'=(2+ye^(xy))/(2y-xe^(xy))` .

First rewrite it into differential form: `(dy)/(dx)=(2+ye^(xy))/(2y-xe^(xy))` or `(2+ye^(xy))dx+(xe^(xy)-2y)dy=0` .

Here `M(x,y)=2+ye^(xy)` and `N(x,y)=xe^(xy)-2y` .

Since `(partial M)/(partial y)=e^(xy)+xye^(xy)` and `(partial N)/(partial x)=e^(xy)+xye^(xy)` then `(partial M)/(partial y)=(partial N)/(partial x)` and differential equation is exact.

So, exist function f such that `(partial f)/(partial x)=M(x,y)=2+ye^(xy)` and `(partial f)/(partial y)=N(x,y)=xe^(xy)-2y` . In previous example we took first equation and integrated it with respect to x. Actuall y we could take second equation and integrate it with respect to y. Final answer is the same. In this example we will take second equation and integrate it with respect to y:

`f=int (xe^(xy)-2y)dy=e^(xy)-y^2+g(x)` . Note that constant of integration depends on x, since we integrate with respect to y.

Now, differentiate resulting equation with respect to x:

`(partial f)/(partial x)=y e^(xy)+g'(x)`

From another side `(partial f)/(partial x)=2+ye^(xy)` , so `ye^(xy)+g'(x)=2+ye^(xy)` or `g'(x)=2` .

Integrating with respect to x gives `g(x)=2x+c_1` .

So, `f=e^(xy)-y^2+g(x)=e^(xy)-y^2+2x+c_1` .

And solution is `e^(xy)-y^2+2x+c_1=C` or `e^(xy)-y^2+2x=c_2` where `(c_2=C-c_1)` .

Sometimes, equation can be not exact, but it can be transformed into exact by multiplying equation by integrating factor.

So, I(x,y) is integrating factor for differential equation is exact if `I(x,y)(M(x,y)dx+N(x,y)dy)=0` is exact.

There are 2 conditions that allow to find integrating factor easily:

If `1/N((partial M)/(partial y)-(partial N)/(partial x))=g(x)` , a function of x alone, then `I(x,y)=e^(int g(x)dx)`

If `1/M((partial M)/(partial y)-(partial N)/(partial x))=h(y)` , a function of x alone, then `I(x,y)=e^(-int h(y)dy)`

Example 3. Solve `(y+1)dx-xdy=0`

Here `M(x,y)=y+1` and `N(x,y)=-x` . Since `(partial M)/(partial y)=1` and `(partial N)/(partial x)=-1` then `(partial M)/(partial y)!=(partial N)/(partial x)` and equation is not exact. However, note that `1/N((partial M)/(partial y)-(partial N)/(partial x))=1/(-x)(1-(-1))=-2/x=g(x)` .

So, `I(x,y)=e^(int -2/xdx)=e^(-2ln(x))=1/x^2` .

Multiplying differential equation by integrating factor gives: `(y+1)/x^2dx-1/xdy=0`.

This equation is exact, so exist function f such that `df=(y+1)/x^2 dx-1/x dy` . Using the fact that `(partial f)/(partial x)=(y+1)/x^2`, we find that `f=int (y+1)/x^2 dx=-(y+1)/x+g(y)` . Now, differentiating with respect to y gives: `(partial f)/(partial y)=-1/x+g'(y)` . From another side `(partial f)/(partial y)=-1/x` , so `-1/x+g'(y)=-1/x` or `g'(y)=0` .

Solving it we obtain that `g(y)=C_1` .

So, `f(x,y)=-(y+1)/x+g(y)=-(y+1)/x+C_1` .

Therefore, solution is `-(y+1)/x+C_1=C` or `y=c_2 x-1` where `c_2=C_1-C` .

Example 4. Solve `2xydx+y^2dy=0`

Here `M(x,y)=2xy` and `N(x,y)=y^2` . Since `(partial M)/(partial y)=2x` and `(partial N)/(partial x)=0` then `(partial M)/(partial y)!=(partial N)/(partial x)` and differential equation is not exact.

However, note that `1/M((partial M)/(partial y)=(partial N)/(partial x))=1/(2xy)(2x-0)=1/y=h(y)` .

So, integrating factor is `I(x,y)=e^(-int 1/y dy)=e^(-ln(y))=1/y` .

Multiplying differential equation by integrating factor yields `1/y(2xydx+y^2dy)=0` or `2xdx+ydy=0`

This equation is exact. Using the fact that `(partial f)/(partial x)=2x` we have that `f=int (2x)dx=x^2+h(y)` . Differentiating last eqaution with respect to y gives: `(partial f)/(partial y)=h'(y)` .

From another side `(partial f)/(partial y)=y` , so `h'(y)=y` or `h(y)=int ydy=1/2 y^2+c_1`

So, `f=x^2+h(y)=x^2+1/2 y^2+c_1` and solution is ` x^2+1/2 y^2+c_1=C` or `x^2+1/2 y^2=c_2` where (`c_2=C-c_1` ) .

Another case when there can be easily found integrating factor is case when `M=yf(xy)` and `N=xg(xy)` . In this case `I(x,y)=1/(xM-yN)` .

Example 5. Solve `y(1-xy)dx+xdy=0` .

Equation is not exact, however, note that `M(x,y)` is in the form `y(1-xy)` and `N(x,y)=x*1` ,so integrating factor is `I(x,y)=1/(xy(1-xy)-xy)=-1/(xy)^2` . Multiplying by I(x,y) yields:

`(xy-1)/(x^2y)dx-1/(xy^2)dy=0` . This equation is exact.

Using the fact that `(partial f)/(partial x)=(xy-1)/(x^2y)` we have that `f=int ((xy-1)/(x^2 y))dx=ln(|x|)+1/(xy)+g(y)` .

Differentiating with respect to y gives: `(partial f)/(partial y)=-1/(xy^2)+g'(y)` . From another side `(partial f)/(partial y)=-1/(xy^2)` .

So, `g'(y)=0` or `g(y)=c_1` .

So, `f(x,y)=ln(|x|)+1/(xy)+c_1` .

Finally, solution is `ln(|x|)+1/(xy)+c_1=C` or `ln(|x|)+1/(xy)=c_2` where `c_2=C-c_1` .

Below is the list of common integrating factors:

Group of terms |
I(x,y) |
Exact differential dg(x,y) |

ydx-xdy | `-1/x^2` | `-(ydx-xdy)/x^2=d(y/x)` |

ydx-xdy | `1/y^2` | `(ydx-xdy)/y^2=d(x/y)` |

ydx-xdy | `-1/(xy)` | `-(ydx-xdy)/(xy)=d(ln(y/x))` |

ydx-xdy | `-1/(x^2+y^2)` | `-(ydx-xdy)/(x^2+y^2)=d(arctan(y/x))` |

ydy+xdx | `1/(xy)` | `(ydy+xdx)/(xy)=d(ln(xy))` |

ydy+xdx | `1/(xy)^n,n>1` | `(ydy+xdx)/(xy)^n=-d(1/((n-1)(xy)^(n-1)))` |

ydy+xdx | `1/(x^2+y^2)` | `(ydy+xdx)/(x^2+y^2)=d(1/2 ln(x^2+y^2))` |

ydy+xdx | `1/(x^2+y^2)^n, n>1` | `(ydy+xdx)/(x^2+y^2)^n=-d(1/(2(n-1)(x^2+y^2)^(n-1)))` |

aydx+bxdy (a and b constants) | `x^(a-1)y^(b-1)` | `x^(a-1)y^(b-1)(aydx+bxdy)=d(x^ay^b)` |

In general, integrating factors are difficult to uncover. If a differential equation doesn't have a one of the forms given above, then a search for an integrating factor likely will not be successful, and other methods of solution should be used.