Harmonic Motion: Undamped

A force exerted by an elastic cord or by a spring obeys Hooke’s law $F=-kx$ where $x$ is the displacement of the equilibrium position.

Credit: This picture was taken from a Wikipedia page at https://en.wikipedia.org/wiki/File:Hookes-law-springs.png

From Newton’s second law of motion we have $F=ma=m\ddot{x}$, so we obtain the second order linear differential equation \begin{equation}\label{eq:undamped}m\ddot{x}+kx=0\end{equation} Solving \eqref{eq:undamped} for $\ddot{x}$ we obtain $\ddot{x}=-\frac{k}{m}x\sim -x$. For a trial solution, $x=e^{qt}$ is a candidate. To see if this trial solution works, plug it back into \eqref{eq:undamped}. $$m\ddot{x}+kx=mq^2e^{qt}+ke^{qt}=0$$ i.e. \begin{equation}\label{eq:auxeq}mq^2+k=0\end{equation} whose solutions are $$q=\pm i\sqrt{\frac{k}{m}}=\pm i\omega_0$$ where $\omega_0=\sqrt{\frac{k}{m}}$. The equation \eqref{eq:auxeq} is called the auxiliary equation or the characteristic equation. So, $x_1=e^{i\omega_0 t}$ and $x_2=e^{-i\omega_0 t}$ are solutions of \eqref{eq:undamped}. It can be easily shown that their linear combination \begin{equation}\label{eq:undamped2}x=A_1e^{i\omega_0 t}+A_2e^{-i\omega_0 t}\end{equation} is also a solution of \eqref{eq:undamped}. \eqref{eq:undamped2} is a complex solution so it is not suitable for the physical analysis of a motion governed by \eqref{eq:undamped}. What we need is a real solution. It turns out that the real part and the imaginary part of $e^{i\omega_0 t}$ also, respectively, satisfy \eqref{eq:undamped}. This is due to the linearity of \eqref{eq:undamped}. Hence, an alternative form of the solution which is real is \begin{equation}\label{eq:undamped3}x=a\cos\omega_0 t+b\sin\omega_0 t\end{equation} Using a trigonometric identity \eqref{eq:undamped3} can be written as \begin{equation}\label{eq:undamped4}x=\sqrt{a^2+b^2}\cos(\omega_0 t-\theta_0)\end{equation} where $\theta_0=\tan^{-1}\frac{b}{a}$ or as \begin{equation}\label{eq:unddamped4a}x=\sqrt{a^2+b^2}\sin(\omega_0 t+\phi_0)\end{equation} where $\phi_0=\tan^{-1}\frac{a}{b}$. The angles $\theta_0$ and $\phi_0$ are called the phase.

Some Terminologies

The equation \eqref{eq:undamped} is called the differential equation of the harmonic oscillator. $\sqrt{a^2+b^2}$ is the amplitude (the maximum value of $x$) The period $T_0$ of the oscillation is the time required for one complete cycle. $$T_0=\frac{2\pi}{\omega_0}=2\pi\sqrt{\frac{m}{k}}$$ The linear frequency of oscillation $f_0$ is the number of cycles in unit time. $$f_0=\frac{1}{T_0}=\frac{\omega_0}{2\pi}=\frac{1}{2\pi}\sqrt{\frac{k}{m}}$$ $\omega_0=2\pi f_0$ is called the angular frequency and is also called the natural frequency.

Example. Suppose that a mass weighing 10 lb stretches a spring 2 in. If the mass is displaced an additional 2 in and is then set in motion with an initial upward velocity of 1 ft/s, determine the position of the mass at any later time. Also determine the period, amplitude, and phase of the motion.

Solution. $k=10\mathrm{lb}/2\mathrm{in}=60\mathrm{lb}/\mathrm{ft}$ and $m=\mathrm{weight}/g=10\mathrm{lb}/32\mathrm{ft}/\mathrm{s}^2$. Thus $$m\ddot{x}+kx=\frac{10}{32}\ddot{x}+60x=0$$ i.e. $$\ddot{x}+192x=0$$ The auxiliary equation is $q^2+192=0$ and $q=\pm i8\sqrt{3}$. The solution $x(t)$ is then given by $$x(t)=a\cos(8\sqrt{3}t)+b\sin(8\sqrt{3}t)$$ From the initial conditions $x(0)=\frac{1}{6}$ ft and $\dot{x}(0)=-1$ ft/s, we find $a=\frac{1}{6}$ and $b=-\frac{1}{8\sqrt{3}}$. The natural frequency is $\omega_0=8\sqrt{3}\approx 13.856$ rad/s. The period is $T_0=\frac{2\pi}{\omega_0}=\frac{2\pi}{8\sqrt{3}}\approx 0.453$ sec. The amplitude is $\sqrt{a^2+b^2}=\sqrt{\frac{19}{576}}\approx 0.182$ ft. The phase is $\theta_0=\tan^{-1}\left(\frac{b}{a}\right)=-\frac{\sqrt{3}}{4}\approx -0.408645$ rad. Therefore, $x(t)$ can be written as $$x(t)=0.182\cos(13.856t+0.40864)$$ Figure 1 shows a complete cycle.

Figure 1. A complete cycle of x(t)=0.182cos(13.856t+0.40864)

Figure 2. shows an animation of $x(t)$.

Figure 2. An animation of x(t)=0.182cos(13.856t+6.283185308k+0.40864) with k=1..5, t=1..100, and FPS=10

The Conservation of Total Energy

Let us calculate the work done by an external force $F_{\mathrm{ext}}$ in moving the mass from the equilibrium position ($x=0$) to some position $x$. $F_{\mathrm{ext}}=-F=kx$ and $$W=\int F_{\mathrm{ext}} dx=\int_0^x kx dx=\frac{1}{2}kx^2$$ The work $W$ is stored in the spring as potential energy $V(x)=W=\frac{1}{2}kx^2$. The potential energy $V(x)$ for a force $F(x)$ is defined by \begin{equation}\label{eq:conservative}F=-\frac{dV}{dx}\end{equation} In our case, $F=-\frac{dV}{dx}=-kx$. For any force $F$ satisfying \eqref{eq:conservative}, the total energy $$E=T+V,$$ the sum of the kinetic energy $T=\frac{1}{2}m\dot{x}^2$ and the potential energy $V$, is  constant. For this reason, a force satisfying \eqref{eq:conservative} is called a conservative force.  Since $$\ddot{x}=\frac{d\dot{x}}{dt}=\frac{d\dot{x}}{dx}\frac{dx}{dt}=v\frac{dv}{dx},$$ $$F(x)=m\ddot{x}=mv\frac{dv}{dx}=\frac{1}{2}m\frac{dv^2}{dx}=\frac{dT}{dx}$$ The work done on the particle by impress force $F(x)$ is $$\int F(x)dx=\int dT=\frac{1}{2}m\dot{x}^2+C_1$$ where $C_1$ is a constant. On the other hand, from \eqref{eq:conservative} we also have $$\int F(x)dx=-\int dV=-V(x)+C_2$$ where $C_2$ is a constant. Therefore, $$T+V=\frac{1}{2}m\dot{x}^2+V(x)=E$$ is a constant. In our case the conservation of total energy $E$ \begin{equation}\label{eq:totalenergy}E=\frac{1}{2}m\dot{x}^2+\frac{1}{2}kx^2\end{equation} can be more directly shown. Differentiating the total energy \eqref{eq:totalenergy} with respect to $t$ \begin{align*}\frac{dE}{dt}&=m\ddot{x}\dot{x}+kx\dot{x}\\&=(m\ddot{x}+kx)\dot{x}\\&=0\end{align*} So the restoring force $F=-kx$ for an undamped harmonic motion is conservative.

The solution \eqref{eq:undamped4} can be also obtained by considering energy. Solving \eqref{eq:totalenergy} for $\dot{x}$ \begin{equation}\label{eq:velocityundamped}\dot{x}=\pm\sqrt{\frac{2E-kx^2}{m}}\end{equation} This is a separable equation. For $\dot{x}=\sqrt{\frac{2E-kx^2}{m}}$ it’s solution is  $$x=\sqrt{\frac{2E}{k}}\sin\left(\sqrt{\frac{k}{m}}t+\phi_0\right)$$ and for $\dot{x}=-\sqrt{\frac{2E-kx^2}{m}}$, it’s solution is $$x=\sqrt{\frac{2E}{k}}\cos\left(\sqrt{\frac{k}{m}}t-\theta_0\right)$$ So the amplitude is $A=\sqrt{\frac{2E}{k}}$ and the angular frequency is $\omega_0=\sqrt{\frac{k}{m}}$. In order for \eqref{eq:velocityundamped} to make sense $\frac{2E-kx^2}{m}\geq 0$ i.e. the total energy is greater than or equal to the potential energy $V(x)=\frac{1}{2}kx^2$. This means that the particle is confined to the region $-\sqrt{\frac{2E}{k}}\leq x\leq\sqrt{\frac{2E}{k}}$. Also the speed becomes zero when $V(x)=E$. This means that the particle must come to rest and reverse its motion at $x=\pm\sqrt{\frac{2E}{k}}$. The points $x=\pm\sqrt{\frac{2E}{k}}$ are called the turning points of the motion. The maximum value of $\dot{x}$ occurs at $x=0$. $v_{\max}=\frac{k}{m}A=\omega_0A$ and $E=\frac{1}{2}mv_{\max}^2=\frac{1}{2}kA^2$.

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 if 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=0$
  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$.

Solution. Let $M(x,y)=(y-x)y$ and $N(x,y)=x^2$. Notice that both $M$ and $N$ are homogeneous functions of degree 2. $$f(u)=-\frac{M(1,u)}{N(1,u)}=-u^2+u$$ and so $$\int\frac{du}{f(u)-u}=-\int\frac{du}{u^2}=\frac{1}{u}=\frac{x}{y}$$ Hence by \eqref{eq:homeq2} the solution is given by $$x=Ce^{\frac{x}{y}}$$

You don’t really have to remember the formula \eqref{eq:homeq2} to solve a homogeneous differential equation. In fact all you have to know is to use the substitution $y=ux$. $dy=xdu+udx$ so the given differential equation can be written as $u^2dx+xdu=0$. By integrating we obtain $$\ln x-\frac{x}{y}=\ln C$$ hence $$x=Ce^{\frac{x}{y}}$$

Example. Solve $3x^2\frac{dy}{dx}=2x^2+y^2$.

Solution. The equation is a homogeneous equation. By the substitution $y=ux$ the equation turns into $$\frac{dx}{3x}-\frac{du}{u^2-3u+2}=0$$ By integrating the solution is given by $$y=\frac{(C\root 3\of{x}-2)x}{C\root 3\of{x}-1}$$