Exact Equations

The differential equation M(x,y)dx+N(x,y)dy=0{M}{\left({x},{y}\right)}{d}{x}+{N}{\left({x},{y}\right)}{d}{y}={0} is exact, if there exists a function f{f{}} such that df=M(x,y)dx+N(x,y)dy{d}{f{=}}{M}{\left({x},{y}\right)}{d}{x}+{N}{\left({x},{y}\right)}{d}{y}.

In this case, the equation can be rewritten as df=0{d}{f{=}}{0}, which gives the solution f=C{f{=}}{C}.

Test for exactness: if M(x,y){M}{\left({x},{y}\right)} and N(x,y){N}{\left({x},{y}\right)} are continuous functions and have continuous first partial derivatives on some rectangle of the xy-plane, the differential equation is exact, if and only if M(x,y)y=N(x,y)x\frac{{\partial{M}{\left({x},{y}\right)}}}{{\partial{y}}}=\frac{{\partial{N}{\left({x},{y}\right)}}}{{\partial{x}}}.

To solve this equation, we use the facts that f(x,y)x=M(x,y)\frac{{\partial{f{{\left({x},{y}\right)}}}}}{{\partial{x}}}={M}{\left({x},{y}\right)} and f(x,y)y=N(x,y)\frac{{\partial{f{{\left({x},{y}\right)}}}}}{{\partial{y}}}={N}{\left({x},{y}\right)}. We integrate the first equation with respect to x{x} to obtain f(x,y){f{{\left({x},{y}\right)}}} through x{x} and an unknown function g(y){g{{\left({y}\right)}}}. We then differentiate the result with respect to y{y} and use the second equation. After this, we find g(y){g{{\left({y}\right)}}} and thus f(x,y){f{{\left({x},{y}\right)}}}. The solution, as already stated above, is given as f(x,y)=C{f{{\left({x},{y}\right)}}}={C}.

Example 1. Solve (x+sin(y))dx+(xcos(y)2y)dy=0{\left({x}+{\sin{{\left({y}\right)}}}\right)}{d}{x}+{\left({x}{\cos{{\left({y}\right)}}}-{2}{y}\right)}{d}{y}={0}.

Here, M(x,y)=x+sin(y){M}{\left({x},{y}\right)}={x}+{\sin{{\left({y}\right)}}}, N(x,y)=xcos(y)2y{N}{\left({x},{y}\right)}={x}{\cos{{\left({y}\right)}}}-{2}{y}. Since My=cos(y)\frac{{\partial{M}}}{{\partial{y}}}={\cos{{\left({y}\right)}}} and Nx=cos(y)\frac{{\partial{N}}}{{\partial{x}}}={\cos{{\left({y}\right)}}}, we have that My=Nx\frac{{\partial{M}}}{{\partial{y}}}=\frac{{\partial{N}}}{{\partial{x}}} and the differential equation is exact.

Thus, there exists a function f{f{}} such that fx=M(x,y)=x+sin(y)\frac{{\partial{f}}}{{\partial{x}}}={M}{\left({x},{y}\right)}={x}+{\sin{{\left({y}\right)}}} and fy=N(x,y)=xcos(y)2y\frac{{\partial{f}}}{{\partial{y}}}={N}{\left({x},{y}\right)}={x}{\cos{{\left({y}\right)}}}-{2}{y}.

Integrate the first equation with respect to x{x} to obtain that f=(x+sin(y))dx=12x2+xsin(y)+g(y){f{=}}\int{\left({x}+{\sin{{\left({y}\right)}}}\right)}{d}{x}=\frac{{1}}{{2}}{{x}}^{{2}}+{x}{\sin{{\left({y}\right)}}}+{g{{\left({y}\right)}}}.

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

Now, differentiate the resulting equation with respect to y{y}:

fy=0+xcos(y)+g(y)\frac{{\partial{f}}}{{\partial{y}}}={0}+{x}{\cos{{\left({y}\right)}}}+{g{'}}{\left({y}\right)}.

On the other hand, fy=N(x,y)=xcos(y)2y\frac{{\partial{f}}}{{\partial{y}}}={N}{\left({x},{y}\right)}={x}{\cos{{\left({y}\right)}}}-{2}{y}.

So, xcos(y)+g(y)=xcos(y)2y{x}{\cos{{\left({y}\right)}}}+{g{'}}{\left({y}\right)}={x}{\cos{{\left({y}\right)}}}-{2}{y}, or g(y)=2y{g{'}}{\left({y}\right)}=-{2}{y}. Integrating it, we obtain that g(y)=y2+c1{g{{\left({y}\right)}}}=-{{y}}^{{2}}+{c}_{{1}}.

Thus,

f=12x2+xsin(y)y2+c1{f{=}}\frac{{1}}{{2}}{{x}}^{{2}}+{x}{\sin{{\left({y}\right)}}}-{{y}}^{{2}}+{c}_{{1}}. The solution is given as 12x2+xsin(y)y2+c1=C\frac{{1}}{{2}}{{x}}^{{2}}+{x}{\sin{{\left({y}\right)}}}-{{y}}^{{2}}+{c}_{{1}}={C},

Or 12x2+xsin(y)y2=c2\frac{{1}}{{2}}{{x}}^{{2}}+{x}{\sin{{\left({y}\right)}}}-{{y}}^{{2}}={c}_{{2}}, where c2=Cc1{c}_{{2}}={C}-{c}_{{1}}.

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

Let's work another example.

Example 2. Solve y=2+yexy2yxexy{y}'=\frac{{{2}+{y}{{e}}^{{{x}{y}}}}}{{{2}{y}-{x}{{e}}^{{{x}{y}}}}}.

First, rewrite it into the differential form: dydx=2+yexy2yxexy\frac{{{d}{y}}}{{{d}{x}}}=\frac{{{2}+{y}{{e}}^{{{x}{y}}}}}{{{2}{y}-{x}{{e}}^{{{x}{y}}}}}, or (2+yexy)dx+(xexy2y)dy=0{\left({2}+{y}{{e}}^{{{x}{y}}}\right)}{d}{x}+{\left({x}{{e}}^{{{x}{y}}}-{2}{y}\right)}{d}{y}={0}.

Here, M(x,y)=2+yexy{M}{\left({x},{y}\right)}={2}+{y}{{e}}^{{{x}{y}}}, and N(x,y)=xexy2y{N}{\left({x},{y}\right)}={x}{{e}}^{{{x}{y}}}-{2}{y}.

Since My=exy+xyexy\frac{{\partial{M}}}{{\partial{y}}}={{e}}^{{{x}{y}}}+{x}{y}{{e}}^{{{x}{y}}} and Nx=exy+xyexy\frac{{\partial{N}}}{{\partial{x}}}={{e}}^{{{x}{y}}}+{x}{y}{{e}}^{{{x}{y}}}, we have thatMy=Nx\frac{{\partial{M}}}{{\partial{y}}}=\frac{{\partial{N}}}{{\partial{x}}} and the differential equation is exact.

So, there exists a function f{f{}} such that fx=M(x,y)=2+yexy\frac{{\partial{f}}}{{\partial{x}}}={M}{\left({x},{y}\right)}={2}+{y}{{e}}^{{{x}{y}}} and fy=N(x,y)=xexy2y\frac{{\partial{f}}}{{\partial{y}}}={N}{\left({x},{y}\right)}={x}{{e}}^{{{x}{y}}}-{2}{y}. In the previous example, we took the first equation and integrated it with respect to x{x}. Actually, we could take the second equation and integrate it with respect to y{y}. The final answer is the same. In this example, we will take the second equation and integrate it with respect to y{y}:

f=(xexy2y)dy=exyy2+g(x){f{=}}\int{\left({x}{{e}}^{{{x}{y}}}-{2}{y}\right)}{d}{y}={{e}}^{{{x}{y}}}-{{y}}^{{2}}+{g{{\left({x}\right)}}}. Note that the constant of integration depends on x{x}, since we integrate with respect to y{y}.

Now, differentiate the resulting equation with respect to x{x}:

fx=yexy+g(x)\frac{{\partial{f}}}{{\partial{x}}}={y}{{e}}^{{{x}{y}}}+{g{'}}{\left({x}\right)}.

On the other hand, fx=2+yexy\frac{{\partial{f}}}{{\partial{x}}}={2}+{y}{{e}}^{{{x}{y}}}; so, yexy+g(x)=2+yexy{y}{{e}}^{{{x}{y}}}+{g{'}}{\left({x}\right)}={2}+{y}{{e}}^{{{x}{y}}}, or g(x)=2{g{'}}{\left({x}\right)}={2}.

Integrating with respect to x{x} gives g(x)=2x+c1{g{{\left({x}\right)}}}={2}{x}+{c}_{{1}}.

So, f=exyy2+g(x)=exyy2+2x+c1{f{=}}{{e}}^{{{x}{y}}}-{{y}}^{{2}}+{g{{\left({x}\right)}}}={{e}}^{{{x}{y}}}-{{y}}^{{2}}+{2}{x}+{c}_{{1}}.

And the solution is exyy2+2x+c1=C{{e}}^{{{x}{y}}}-{{y}}^{{2}}+{2}{x}+{c}_{{1}}={C} or exyy2+2x=c2{{e}}^{{{x}{y}}}-{{y}}^{{2}}+{2}{x}={c}_{{2}}, where c2=Cc1{c}_{{2}}={C}-{c}_{{1}}.

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

So, I(x,y){I}{\left({x},{y}\right)} is the integrating factor for the differential equation, if I(x,y)(M(x,y)dx+N(x,y)dy)=0{I}{\left({x},{y}\right)}{\left({M}{\left({x},{y}\right)}{d}{x}+{N}{\left({x},{y}\right)}{d}{y}\right)}={0} is exact.

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

If 1N(MyNx)=g(x)\frac{{1}}{{N}}{\left(\frac{{\partial{M}}}{{\partial{y}}}-\frac{{\partial{N}}}{{\partial{x}}}\right)}={g{{\left({x}\right)}}}, a function of x{x} alone, then I(x,y)=eg(x)dx{I}{\left({x},{y}\right)}={{e}}^{{\int{g{{\left({x}\right)}}}{d}{x}}}.

If 1M(MyNx)=h(y)\frac{{1}}{{M}}{\left(\frac{{\partial{M}}}{{\partial{y}}}-\frac{{\partial{N}}}{{\partial{x}}}\right)}={h}{\left({y}\right)}, a function of y{y} alone, then I(x,y)=eh(y)dy{I}{\left({x},{y}\right)}={{e}}^{{-\int{h}{\left({y}\right)}{d}{y}}}.

Now, let's do some more work with another example

Example 3. Solve (y+1)dxxdy=0{\left({y}+{1}\right)}{d}{x}-{x}{d}{y}={0}.

Here, M(x,y)=y+1{M}{\left({x},{y}\right)}={y}+{1}, and N(x,y)=x{N}{\left({x},{y}\right)}=-{x}. Since My=1\frac{{\partial{M}}}{{\partial{y}}}={1} and Nx=1\frac{{\partial{N}}}{{\partial{x}}}=-{1}, we have that MyNx\frac{{\partial{M}}}{{\partial{y}}}\ne\frac{{\partial{N}}}{{\partial{x}}} and the equation is not exact. However, note that 1N(MyNx)=1x(1(1))=2x=g(x)\frac{{1}}{{N}}{\left(\frac{{\partial{M}}}{{\partial{y}}}-\frac{{\partial{N}}}{{\partial{x}}}\right)}=\frac{{1}}{{-{x}}}{\left({1}-{\left(-{1}\right)}\right)}=-\frac{{2}}{{x}}={g{{\left({x}\right)}}}.

So, I(x,y)=e2xdx=e2ln(x)=1x2{I}{\left({x},{y}\right)}={{e}}^{{\int-\frac{{2}}{{x}}{d}{x}}}={{e}}^{{-{2}{\ln{{\left({x}\right)}}}}}=\frac{{1}}{{{x}}^{{2}}}.

Multiplying the differential equation by the integrating factor gives: y+1x2dx1xdy=0\frac{{{y}+{1}}}{{{x}}^{{2}}}{d}{x}-\frac{{1}}{{x}}{d}{y}={0}.

This equation is exact; so, there exists a function f{f{}} such that df=y+1x2dx1xdy{d}{f{=}}\frac{{{y}+{1}}}{{{x}}^{{2}}}{d}{x}-\frac{{1}}{{x}}{d}{y}. Using the fact that fx=y+1x2\frac{{\partial{f}}}{{\partial{x}}}=\frac{{{y}+{1}}}{{{x}}^{{2}}}, we find that f=y+1x2dx=y+1x+g(y){f{=}}\int\frac{{{y}+{1}}}{{{x}}^{{2}}}{d}{x}=-\frac{{{y}+{1}}}{{x}}+{g{{\left({y}\right)}}}. Now, differentiating with respect to y{y} gives: fy=1x+g(y)\frac{{\partial{f}}}{{\partial{y}}}=-\frac{{1}}{{x}}+{g{'}}{\left({y}\right)}. On the other hand, fy=1x\frac{{\partial{f}}}{{\partial{y}}}=-\frac{{1}}{{x}}; so, 1x+g(y)=1x-\frac{{1}}{{x}}+{g{'}}{\left({y}\right)}=-\frac{{1}}{{x}}, or g(y)=0{g{'}}{\left({y}\right)}={0}.

Solving it, we obtain that g(y)=C1{g{{\left({y}\right)}}}={C}_{{1}}.

So, f(x,y)=y+1x+g(y)=y+1x+C1{f{{\left({x},{y}\right)}}}=-\frac{{{y}+{1}}}{{x}}+{g{{\left({y}\right)}}}=-\frac{{{y}+{1}}}{{x}}+{C}_{{1}}.

Therefore, the solution is y+1x+C1=C-\frac{{{y}+{1}}}{{x}}+{C}_{{1}}={C}, or y=c2x1{y}={c}_{{2}}{x}-{1}, where c2=C1C{c}_{{2}}={C}_{{1}}-{C}.

Let's solve another equation.

Example 4. Solve 2xydx+y2dy=0{2}{x}{y}{d}{x}+{{y}}^{{2}}{d}{y}={0}.

Here, M(x,y)=2xy{M}{\left({x},{y}\right)}={2}{x}{y}, and N(x,y)=y2{N}{\left({x},{y}\right)}={{y}}^{{2}}. Since My=2x\frac{{\partial{M}}}{{\partial{y}}}={2}{x} and Nx=0\frac{{\partial{N}}}{{\partial{x}}}={0}, we have that MyNx\frac{{\partial{M}}}{{\partial{y}}}\ne\frac{{\partial{N}}}{{\partial{x}}} and the differential equation is not exact.

However, note that 1M(My=Nx)=12xy(2x0)=1y=h(y)\frac{{1}}{{M}}{\left(\frac{{\partial{M}}}{{\partial{y}}}=\frac{{\partial{N}}}{{\partial{x}}}\right)}=\frac{{1}}{{{2}{x}{y}}}{\left({2}{x}-{0}\right)}=\frac{{1}}{{y}}={h}{\left({y}\right)}.

So, the integrating factor is I(x,y)=e1ydy=eln(y)=1y{I}{\left({x},{y}\right)}={{e}}^{{-\int\frac{{1}}{{y}}{d}{y}}}={{e}}^{{-{\ln{{\left({y}\right)}}}}}=\frac{{1}}{{y}}.

Multiplying the differential equation by the integrating factor yields 1y(2xydx+y2dy)=0\frac{{1}}{{y}}{\left({2}{x}{y}{d}{x}+{{y}}^{{2}}{d}{y}\right)}={0}, or 2xdx+ydy=0{2}{x}{d}{x}+{y}{d}{y}={0}.

This equation is exact. Using the fact that fx=2x\frac{{\partial{f}}}{{\partial{x}}}={2}{x}, we have that f=(2x)dx=x2+h(y){f{=}}\int{\left({2}{x}\right)}{d}{x}={{x}}^{{2}}+{h}{\left({y}\right)}. Differentiating the last eqaution with respect to y{y} gives: fy=h(y)\frac{{\partial{f}}}{{\partial{y}}}={h}'{\left({y}\right)}.

On the other hand, fy=y\frac{{\partial{f}}}{{\partial{y}}}={y}; so, h(y)=y{h}'{\left({y}\right)}={y}, or h(y)=ydy=12y2+c1{h}{\left({y}\right)}=\int{y}{d}{y}=\frac{{1}}{{2}}{{y}}^{{2}}+{c}_{{1}}.

Hence, f=x2+h(y)=x2+12y2+c1{f{=}}{{x}}^{{2}}+{h}{\left({y}\right)}={{x}}^{{2}}+\frac{{1}}{{2}}{{y}}^{{2}}+{c}_{{1}}, and the solution is x2+12y2+c1=C{{x}}^{{2}}+\frac{{1}}{{2}}{{y}}^{{2}}+{c}_{{1}}={C}, or x2+12y2=c2{{x}}^{{2}}+\frac{{1}}{{2}}{{y}}^{{2}}={c}_{{2}}, where c2=Cc1{c}_{{2}}={C}-{c}_{{1}}.

Another case when the integrating factor can be found easily is when M=yf(xy){M}={y}{f{{\left({x}{y}\right)}}} and N=xg(xy){N}={x}{g{{\left({x}{y}\right)}}}. In this case, I(x,y)=1xMyN{I}{\left({x},{y}\right)}=\frac{{1}}{{{x}{M}-{y}{N}}}.

Example 5. Solve y(1xy)dx+xdy=0{y}{\left({1}-{x}{y}\right)}{d}{x}+{x}{d}{y}={0}.

The equation is not exact; however, note that M(x,y){M}{\left({x},{y}\right)} is in the form y(1xy){y}{\left({1}-{x}{y}\right)} and N(x,y)=x1{N}{\left({x},{y}\right)}={x}\cdot{1}; so, the integrating factor is I(x,y)=1xy(1xy)xy=1(xy)2{I}{\left({x},{y}\right)}=\frac{{1}}{{{x}{y}{\left({1}-{x}{y}\right)}-{x}{y}}}=-\frac{{1}}{{{\left({x}{y}\right)}}^{{2}}}. Multiplying by I(x,y){I}{\left({x},{y}\right)} yields:

xy1x2ydx1xy2dy=0\frac{{{x}{y}-{1}}}{{{{x}}^{{2}}{y}}}{d}{x}-\frac{{1}}{{{x}{{y}}^{{2}}}}{d}{y}={0}. This equation is exact.

Using the fact that fx=xy1x2y\frac{{\partial{f}}}{{\partial{x}}}=\frac{{{x}{y}-{1}}}{{{{x}}^{{2}}{y}}}, we have that f=(xy1x2y)dx=ln(x)+1xy+g(y){f{=}}\int{\left(\frac{{{x}{y}-{1}}}{{{{x}}^{{2}}{y}}}\right)}{d}{x}={\ln{{\left({\left|{x}\right|}\right)}}}+\frac{{1}}{{{x}{y}}}+{g{{\left({y}\right)}}}.

Differentiating with respect to y{y} gives: fy=1xy2+g(y)\frac{{\partial{f}}}{{\partial{y}}}=-\frac{{1}}{{{x}{{y}}^{{2}}}}+{g{'}}{\left({y}\right)}. On the other hand, fy=1xy2\frac{{\partial{f}}}{{\partial{y}}}=-\frac{{1}}{{{x}{{y}}^{{2}}}}.

So, g(y)=0{g{'}}{\left({y}\right)}={0}, or g(y)=c1{g{{\left({y}\right)}}}={c}_{{1}}.

Thus, f(x,y)=ln(x)+1xy+c1{f{{\left({x},{y}\right)}}}={\ln{{\left({\left|{x}\right|}\right)}}}+\frac{{1}}{{{x}{y}}}+{c}_{{1}}.

Finally, the solution is ln(x)+1xy+c1=C{\ln{{\left({\left|{x}\right|}\right)}}}+\frac{{1}}{{{x}{y}}}+{c}_{{1}}={C}, or ln(x)+1xy=c2{\ln{{\left({\left|{x}\right|}\right)}}}+\frac{{1}}{{{x}{y}}}={c}_{{2}}, where c2=Cc1{c}_{{2}}={C}-{c}_{{1}}.

Below is the list of common integrating factors:

Group of terms I(x,y){I}{\left({x},{y}\right)} Exact differential dg(x,y){d}{g{{\left({x},{y}\right)}}}
ydxxdy{y}{d}{x}-{x}{d}{y} 1x2-\frac{{1}}{{{x}}^{{2}}} ydxxdyx2=d(yx)-\frac{{{y}{d}{x}-{x}{d}{y}}}{{{x}}^{{2}}}={d}{\left(\frac{{y}}{{x}}\right)}
ydxxdy{y}{d}{x}-{x}{d}{y} 1y2\frac{{1}}{{{y}}^{{2}}} ydxxdyy2=d(xy)\frac{{{y}{d}{x}-{x}{d}{y}}}{{{y}}^{{2}}}={d}{\left(\frac{{x}}{{y}}\right)}
ydxxdy{y}{d}{x}-{x}{d}{y} 1xy-\frac{{1}}{{{x}{y}}} ydxxdyxy=d(ln(yx))-\frac{{{y}{d}{x}-{x}{d}{y}}}{{{x}{y}}}={d}{\left({\ln{{\left(\frac{{y}}{{x}}\right)}}}\right)}
ydxxdy{y}{d}{x}-{x}{d}{y} 1x2+y2-\frac{{1}}{{{{x}}^{{2}}+{{y}}^{{2}}}} ydxxdyx2+y2=d(arctan(yx))-\frac{{{y}{d}{x}-{x}{d}{y}}}{{{{x}}^{{2}}+{{y}}^{{2}}}}={d}{\left({\operatorname{arctan}{{\left(\frac{{y}}{{x}}\right)}}}\right)}
ydy+xdx{y}{d}{y}+{x}{d}{x} 1xy\frac{{1}}{{{x}{y}}} ydy+xdxxy=d(ln(xy))\frac{{{y}{d}{y}+{x}{d}{x}}}{{{x}{y}}}={d}{\left({\ln{{\left({x}{y}\right)}}}\right)}
ydy+xdx{y}{d}{y}+{x}{d}{x} 1(xy)n,n>1\frac{{1}}{{{\left({x}{y}\right)}}^{{n}}},{n}>{1} ydy+xdx(xy)n=d(1(n1)(xy)n1)\frac{{{y}{d}{y}+{x}{d}{x}}}{{{\left({x}{y}\right)}}^{{n}}}=-{d}{\left(\frac{{1}}{{{\left({n}-{1}\right)}{{\left({x}{y}\right)}}^{{{n}-{1}}}}}\right)}
ydy+xdx{y}{d}{y}+{x}{d}{x} 1x2+y2\frac{{1}}{{{{x}}^{{2}}+{{y}}^{{2}}}} ydy+xdxx2+y2=d(12ln(x2+y2))\frac{{{y}{d}{y}+{x}{d}{x}}}{{{{x}}^{{2}}+{{y}}^{{2}}}}={d}{\left(\frac{{1}}{{2}}{\ln{{\left({{x}}^{{2}}+{{y}}^{{2}}\right)}}}\right)}
ydy+xdx{y}{d}{y}+{x}{d}{x} 1(x2+y2)n,n>1\frac{{1}}{{{\left({{x}}^{{2}}+{{y}}^{{2}}\right)}}^{{n}}},{n}>{1} ydy+xdx(x2+y2)n=d(12(n1)(x2+y2)n1)\frac{{{y}{d}{y}+{x}{d}{x}}}{{{\left({{x}}^{{2}}+{{y}}^{{2}}\right)}}^{{n}}}=-{d}{\left(\frac{{1}}{{{2}{\left({n}-{1}\right)}{{\left({{x}}^{{2}}+{{y}}^{{2}}\right)}}^{{{n}-{1}}}}}\right)}
aydx+bxdy{a}{y}{d}{x}+{b}{x}{d}{y} (a{a} and b{b} are constants) xa1yb1{{x}}^{{{a}-{1}}}{{y}}^{{{b}-{1}}} xa1yb1(aydx+bxdy)=d(xayb){{x}}^{{{a}-{1}}}{{y}}^{{{b}-{1}}}{\left({a}{y}{d}{x}+{b}{x}{d}{y}\right)}={d}{\left({{x}}^{{a}}{{y}}^{{b}}\right)}

In general, integrating factors are difficult to uncover. If a differential equation doesn't have one of the forms given above, searching for the integrating factor will likely be unsuccessful, and one should resort to other solution methods.