# Exact Differential Equations 2

In here, we discussed that a first-order differential equation $M(x,y)dx+N(x,y)dy=0$ is exact if and only if $\frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}$ in which case we can solve the exact equation by finding a potential $U$ such that $M(x,y)dx+N(x,y)dy=dU$. Let $\frac{\partial M}{\partial y}\ne\frac{\partial N}{\partial x}$ and multiply the equation by a function $\mu(x,y)$ (which is unbeknownst to us at the moment). $$\mu(x,y)M(x,y)dx+\mu(x,y)N(x,y)dy=0$$ Assume that this new equation is exact. Then $$\frac{\partial \mu M}{\partial y}=\frac{\partial \mu N}{\partial x}$$ which is equivalent to \begin{equation}\label{eq:exact}N\frac{\partial\mu}{\partial x}-M\frac{\partial\mu}{\partial y}=\mu\left(\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}\right)\end{equation} Let us consider a simple case $\mu=\mu(x)$. Then \eqref{eq:exact} reduces to \begin{equation}\label{eq:exact2}\frac{d\mu}{dx}=\frac{\mu\left(\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}\right)}{N}\end{equation} If the RHS of \eqref{eq:exact2} depends only on the $x$ variable, \eqref{eq:exact2} is a separable equation $$\frac{d\mu}{\mu}=\frac{\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}}{N}dx$$ and $\mu(x)$ is found by $$\mu(x)=\exp\left[\int\frac{\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}}{N}dx\right]$$ Similarly, if $\mu=\mu(y)$ then $$\mu(y)=\exp\left[-\int\frac{\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}}{M}dx\right]$$ provided $\frac{\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}}{M}$ depends only on the $y$ variable.

Example. Solve the equation $$(x^2-y)dx+(x^2y^2+x)dy=0$$

Solution. $\frac{\partial M}{\partial y}=-1$, $\frac{\partial N}{\partial x}=2xy^2+1$. $\frac{\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}}{N}=-\frac{2}{x}$ so $\mu(x)=\frac{1}{x^2}$. Now, \begin{align*}\mu Mdx+\mu Ndy&=\left(1-\frac{y}{x^2}\right)dx+\left(y^2+\frac{1}{x}\right)dy\\&=dx+y^2dy+\frac{xdy-ydx}{x^2}=0\end{align*} Since the last term is $d\left(\frac{y}{x}\right)$, by integrating we find the solution $$3x^2+xy^3+3y-Cx=0$$

Revisiting First-Order Linear Differential Equations

A first-order linear differential equation $\frac{dy}{dx}+P(x)y=Q(x)$ can be written as $$(P(x)y-Q(x))dx+dy=0$$ Let $M=Py-Q$ and $N=1$. Then $\frac{\partial M}{\partial y}=P$ and $\frac{\partial N}{\partial x}=0$ so $$\mu=e^{\int\frac{\frac{\partial M}{\partial y}-\frac{\partial N}{\partial x}}{N}dx}=e^{\int P(x)dx}$$ Now let $$\mu(P(x)y-Q(x))dx+\mu dy=dU$$ for some scalar function $U$. Then $$\frac{\partial U}{\partial x}=\mu Py-\mu Q,\ \frac{\partial U}{\partial y}=\mu$$ $$U(x,y)=\int_0^y\mu dy+\varphi(x)=\mu y+\varphi(x)$$ and $$\frac{\partial U}{\partial x}=\mu’y+\varphi'(x)=\mu Py+\varphi'(x)=\mu Py-\mu Q$$ Thus $\varphi'(x)=-\mu Q$ and hence $\varphi(x)=-\int\mu Qdx$. Since $\varphi(x)$ contains an arbitrary constant, we can set $U(x,y)=0$ for the general solution i.e. $\mu y-\int\mu Qdx=0$ and thereby $$y=\frac{\int\mu Qdx}{\mu}$$

# Exact Differential Equations 1

A first-order differential equation $$M(x,y)dx+N(x,y)dy=0$$ is called an exact differential equation is there is a scalar function $U(x,y)$ such that $$M(x,y)dx+N(x,y)dy=dU$$ The solution is then $U(x,y)=C$ where $C$ is a constant.

Theorem. Suppose that $M(x,y)$ and $N(x,y)$ have continuous partial derivatives in an open region $\mathcal{R}$. Then the equation $$M(x,y)dx+N(x,y)dy=0$$ is exact if and only if $$\frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}$$ for all $(x,y)\in\mathcal{R}$.

Proof. Suppose that $$M(x,y)dx+N(x,y)dy=0$$ is exact. Then there exists a scalar function $U(x,y)$ such that $$M(x,y)dx+N(x,y)dy=dU$$ Thus $\frac{\partial U}{\partial x}=M(x,y)$ and $\frac{\partial U}{\partial y}=N(x,y)$. Now, $$\frac{\partial M}{\partial y}=\frac{\partial^2U}{\partial y\partial x}=\frac{\partial^2U}{\partial x\partial y}=\frac{\partial N}{\partial x}$$ since $M$ and $N$ have continuous partial derivatives. Conversely suppose that $$\frac{\partial M}{\partial y}=\frac{\partial N}{\partial x}$$ for all $(x,y)\in\mathcal{R}$. Since $\frac{\partial U}{\partial x}=M$, $$U(x,y)=\int_{x_0}^x M(x,y)dx+\varphi(y)$$ So \begin{align*}\frac{\partial U}{\partial y}&=\frac{\partial}{\partial y}\int_{x_0}^x M(x,y)dx+\varphi(y)\\&=\int_{x_0}^x \frac{\partial M}{\partial y}dx+\varphi'(y)\\&=\int_{x_0}^x \frac{\partial N}{\partial x}dx+\varphi'(y)\\&=N(x,y)-N(x_0,y)+\varphi'(y)\end{align*} Since $\frac{\partial U}{\partial y}=N$, we have $$\varphi'(x)=N(x_0,y)$$ and so $\varphi(y)$ is found to be $$\varphi(y)=\int_{y_0}^y N(x_0,y)dy+C$$ where $C$ is a constant. Therefore, $$U(x,y)=\int_{x_0}^x M(x,y)dx+\int_{y_0}^yN(x_0,y)dy+C$$ This completes the proof.

Remark. Let $\mathbf{F}(x,y)=M(x,y)\mathbf{i}+N(x,y)\mathbf{j}$. Then $M(x,y)dx+N(x,y)dy$ being an exact differential is equivalent to $\mathbf{F}$ being conservative, because $M(x,y)dx+N(x,y)dy=dU$ if and only if $\mathbf{F}=\nabla U$. A scalar function $U(x,y)$ such that $\mathbf{F}=\nabla U$ is called a potential energy function or shortly a potential in physics. Also $\mathbf{F}\cdot d\mathbf{r}=M(x,y)dx+N(x,y)dy$ so $\mathbf{F}\cdot d\mathbf{r}=dU$ means that the work done by the force $\mathbf{F}$does not depend on the particle’s path but only depends on the initial point and the terminal point of the particle’s path.

Remark. Let us consider a complex differential $f(z)dz$. Let $z=x+iy$ and $f(z)=u(x,y)+iv(x,y)$ where $u(x,y)$ and $v(x,y)$ are scalar functions. Then $$f(z)dz=(u+iv)(dx+idy)=(udx-vdy)+i(vdx+udy)$$ This complex differential is exact if and only if both $udx-vdy$ and $vdx+udy$ are exact i.e. $u$ and $v$ satisfy \begin{equation}\begin{aligned}\frac{\partial u}{\partial x}&=\frac{\partial v}{\partial y}\\\frac{\partial v}{\partial x}&=-\frac{\partial u}{\partial y}\end{aligned}\label{eq:cauchy-riemann}\end{equation} \eqref{eq:cauchy-riemann} are called the Cauchy-Riemann equations.  If $u$ and $v$ satisfy the Cauchy-Riemann equations \eqref{eq:cauchy-riemann}, they both satisfy Laplace’s equation $$\nabla^2\varphi=\frac{\partial^2\varphi}{\partial x^2}+\frac{\partial^2\varphi}{\partial y^2}=0$$ i.e. $u$ and $v$ are harmonic functions, in particular $v$ is called the harmonic conjugate of $u$. Furthermore $f(z)=u(x,y)+iv(x,y)$ is analytic meaning $\frac{df}{dz}$ exist and is given by $\frac{df}{dz}=\frac{\partial u}{\partial x}+i\frac{\partial v}{\partial x}$. Conversely, if $f(z)=u(x,y)+iv(x,y)$ is analytic then $v$ is a harmonic conjugate of $u$. For more details about harmonic functions see my lecture note here. Functions of a Complex Variable studies differentiation and integrations of complex analytic functions. Laplace’s equation is related to a minimum electrostatic energy. If $\mathbf{E}$ is the electrostatic force field, then in terms of the static potential energy $\varphi$, $\mathbf{E}=\nabla\varphi$. If one imposes the requirement that the static potential energy (associated with the field) in a given volume be a minimum, then it can be shown using Calculus of Variations that $\varphi$ satisfies $\nabla^2\varphi=0$. For details see page 943 of George Arfken, Mathematical Methods for Physicists, 3rd Edition, Academic Press, 1985.

Example.  Show that each equation is exact and find solution.

1. $2xydx+(x^2-2y)dy$
2. $(7x+3y)dx+(3x-5y)dy=0$

Solution.

1. $M=2xy$ and $N=x^2-2y$. Since $\frac{\partial M}{\partial y}=2x=\frac{\partial N}{\partial x}$, the equaiton is exact. Let $U$ be a scalar function such that $2xydx+(x^2-2y)dy=dU$. Then $\frac{\partial U}{\partial x}=2xy$, $\frac{\partial U}{\partial y}=x^2-2y$. From $\frac{\partial U}{\partial x}=2xy$, we get \begin{align*}U(x,y)&=\int_0^x\frac{\partial U}{\partial x}dx+\varphi(y)\\&=\int_0^x 2xydx+\varphi(y)\\&=x^2y+\varphi(y)\end{align*} Differentiating $U$ with respect to y  $$\frac{\partial U}{\partial y}=x^2+\varphi'(y)$$ Since we also have $\frac{\partial U}{\partial y}=x^2-2y$, $\varphi'(y)=-2y$ and $$\varphi(y)=\int_0^y -2ydy+C_1=-y^2+C_1$$ Therefore $U(x,y)=x^2y-y^2+C_1$. The solution is $x^2y-y^2+C_1=C_2$ which can then be written as $x^2y-y^2=C$.
2. Left as exercise for readers. The answer is $$\frac{7}{2}x^2+3xy-\frac{5}{2}y^2=C$$

Remark. The equation in #2 is also homogeneous so of course it can be solved as one. $$f(u)=-\frac{M(1,y)}{N(1,y)}=-\frac{7+3u}{3-5u}$$ and so \begin{align*}\int\frac{du}{f(u)-u}&=-\int\frac{5u-3}{5u^2-6u-7}du\\&=-\frac{1}{2}\int\frac{10u-6}{5u^2-6u-7}du\\&=-\frac{1}{2}\ln(5u^2-6u-7)\\&=\ln\frac{1}{\sqrt{5u^2-6u-7}}\end{align*} Hence the solution is $$x=C_1e^{\int\frac{du}{f(u)-u}}=\frac{C_1}{\sqrt{5u^2-6u-7}}$$ which can be written as $$5x^2y^2-6xy-7x^2=C_2$$ Notice that this is equivalent to the solution given above.

# Bernoulli’s Differential Equations

Bernoull’s differential equation \begin{equation}\label{eq:bernoulli}\frac{dy}{dx}+P(x)y=Q(x)y^n\end{equation} is nonlinear for $n\ne 0, 1$. Assume $n>1$ and multiply \eqref{eq:bernoulli} by $\frac{1}{y^n}$. \begin{equation}\label{eq:bernoulli2}\frac{1}{y^n}\frac{dy}{dx}+P(x)\frac{1}{y^{n-1}}=Q(x)\end{equation} Let $z=\frac{1}{y^{n-1}}$. Then \begin{align*}\frac{dz}{dx}&=\frac{dz}{dy}\frac{dy}{dx}\\&=(1-n)\frac{1}{y^n}\frac{dy}{dx}\end{align*} The equation \eqref{eq:bernoulli2} is reduced to the linear equation \begin{equation}\label{eq:bernoulli3}\frac{dz}{dx}+(1-n)P(x)z=(1-n)Q(x)\end{equation}

Example. Solve the Bernoulli’s equation $$\frac{dy}{dx}-\frac{3}{x}y=-x^3y^2$$

Solution. The equation can be written as $$\frac{1}{y^2}\frac{dy}{dx}-\frac{3}{x}\frac{1}{y}=-x^3$$ Let $z=\frac{1}{y}$. Then $\frac{dz}{dx}=-\frac{1}{y^2}\frac{dy}{dx}$ and subsequently we obtain the first-order linear differential equation $$\frac{dz}{dx}+\frac{3}{x}z=x^3$$ The integrating factor $\mu(x)$ is given by $$\mu(x)=e^{\int\frac{3}{x}dx}=e^{\ln x^3}=x^3$$ and thus the solution $z(x)$ is $$z(x)=\frac{\int\mu Qdx}{\mu}=\frac{\int x^6dx}{x^3}=\frac{\frac{x^7}{7}+C}{x^3}$$ Since $z=\frac{1}{y}$, the final answer can be written as $$y\left(\frac{x^7}{7}+C\right)=x^3$$

# Homogeneous Differential Equations

Definition. A function $M(x,y)$ of two variables $x$ and $y$ is said to be homogeneous if for any parameter $\lambda$ $$M(\lambda x,\lambda y)=\lambda^n M(x,y)$$ The number $n$ is called the degree of the homogeneous function $M(x,y)$.

A first-order differential equation $$M(x,y)dx+N(x,y)dy=0$$ is said to be a homogeneous differential equation if both $M(x,y)$ and $N(x,y)$ are homogeneous functions of the same degree.

Solving Homogeneous Differential Equations

Consider a homogeneous differential equation $$M(x,y)dx+N(x,y)dy=0$$ For the parameter $\lambda=\frac{1}{x}$ we obtain \begin{equation}\label{eq:homeq}\frac{dy}{dx}=-\frac{M\left(1,\frac{y}{x}\right)}{N\left(1,\frac{y}{x}\right)}\end{equation} Let $u=\frac{y}{x}$. Then $y=ux$ and $\frac{dy}{dx}=x\frac{du}{dx}+u$. Since the RHS of \eqref{eq:homeq} can be considered as a function of $u$, say $f(u)$ we have $$x\frac{du}{dx}+u=f(u)$$ This is a separable equation as it can be written as $$\frac{du}{f(u)-u}=\frac{dx}{x}$$ and by integrating we find the solution \begin{equation}\label{eq:homeq2}x=C\exp\left[\int\frac{du}{f(u)-u}\right]\end{equation} Let $F(u)=\int\frac{du}{f(u)-u}$. Then \eqref{eq:homeq2} can be written as $$x=Ce^{F(u)}=Ce^{F\left(\frac{y}{x}\right)}$$

Example. Solve $(y-x)ydx+x^2dy=0$.