online advertising

Monday, December 28, 2015

Integrating Factor

Problem:

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

Solution:

Let $ M(x, y) = \frac{2y}{x^2} $, $ N(x, y) = \frac{1}{x} $, now we have

$ \frac{\partial M}{\partial y} = \frac{2}{x^2} \ne \frac{-1}{x^2} = \frac{\partial N}{\partial x} $

But they look similar, so let's assume there exists $ \mu(x) $ such that

$ \frac{\partial \mu M}{\partial y} = \frac{\mu \partial N}{\partial x} $

Expanding, we get

$ \mu \frac{\partial M}{\partial y} = \frac{\partial \mu}{\partial x} N + \mu \frac{\partial N}{\partial x} $

or

$ \frac{1}{N}(\frac{\partial M}{\partial y} - \frac{\partial N}{\partial x})= \frac{1}{\mu}\frac{\partial \mu}{\partial x}$

so

$ \mu = e^{\int \frac{1}{N}(\frac{\partial M}{\partial y} - \frac{\partial N}{\partial x}) dx} $

Putting in the values, we have

$ \begin{eqnarray*} \mu &=& e^{\int \frac{1}{\frac{1}{x}}(\frac{2}{x^2} - \frac{-1}{x^2}) dx} \\ &=& e^{\int \frac{1}{\frac{3}{x}} dx} \\ &=& e^{3 \log x} \\ &=& x^3 \end{eqnarray*} $

The rest is rather easy now, we need to find $ f(x, y) $ such that $ \frac{\partial f}{\partial x} = x^3 \frac{2y}{x^2} = 2xy $ and $ \frac{\partial f}{\partial y} = x^3 \frac{1}{x} = x^2 $. We found $ f(x, y) = x^2y = c $, therefore the solution to the differential equation is $ y = cx^{-2} $.

Homogenous Equation

Problem:

$ (y^2 - x^2)dx + xydy = 0 $

Solution:

$ \begin{eqnarray*} (y^2 - x^2)dx + xydy &=& 0 \\ (y^2 - x^2)dx &=& -xydy \\ \frac{dy}{dx} &=& \frac{x^2 - y^2}{xy} \\ &=& \frac{x}{y} - \frac{y}{x} \\ \end{eqnarray*} $

Now let $ z = \frac{y}{x}, \frac{dz}{dx} = \frac{d}{dx}(y)\frac{1}{x} + y\frac{d}{dx}\frac{1}{x} = \frac{dy}{dx}\frac{1}{x} - \frac{y}{x^2} $, which implies $ \frac{dy}{dx} = x\frac{dz}{dx} + z $. Putting these back, we have

$ \begin{eqnarray*} \frac{dy}{dx} &=& \frac{x}{y} - \frac{y}{x} \\ x\frac{dz}{dx} + z &=& \frac{1}{z} - z \\ x\frac{dz}{dx} &=& \frac{1}{z} - 2z \\ \frac{zdz}{1-2z^2} &=& \frac{dx}{x} \\ \frac{-1}{4}\log(1-2z^2) &=& \log(x) + C_1 \\ \log(1-2z^2) &=& -4\log(x) + C_2 \\ 1-2z^2 &=& C_3x^{-4} \\ 1-2(\frac{y}{x})^2 &=& C_3x^{-4} \\ x^2-2y^2 &=& C_3x^{-2} \\ y^2 &=& \frac{1}{2}(x^2 - Cx^{-2}) \\ \end{eqnarray*} $

For a quick check, we have:

$ \begin{eqnarray*} y^2 &=& \frac{1}{2}(x^2 - Cx^{-2}) \\ 2y \frac{dy}{dx} &=& x + Cx^{-3} \\ &=& x + \frac{Cx^{-2}}{x} \\ &=& x + \frac{x^2 - 2y^2}{x} \\ &=& 2x - \frac{2y^2}{x} \\ \frac{dy}{dx} &=& \frac{x}{y} - \frac{y}{x} \\ \end{eqnarray*} $

Sunday, December 27, 2015

Orthogonal Trajectories

Problem:

Find the orthogonal trajectories to the curves $ y = x^2 + c $.

Solution:

First, we express the parabolas as differential equations

$ \frac{dy}{dx} = 2x $

Next, the slope of the tangent lines for the orthogonal trajectories is determined, so we solve this

$ \frac{dy}{dx} = \frac{-1}{2x} $

This is separable, and therefore the solution is simply

$ y = \frac{-1}{2}sgn(x)\ln|x| + c $

Exact differential equation

Problem:

$ 3x^2y dx + x^3dy = 0 $

Solution:

We have $ \frac{\partial 3x^2y}{\partial y} = 3x^2 = \frac{\partial x^3}{\partial x} $, therefore, we can find $ f(x, y) $ such that $ \frac{\partial f}{\partial x} = 3x^2y $ and $ \frac{\partial f}{\partial y} = x^3 $

It is quite obvious that $ f(x, y) = x^3y + c $.

The answer to the differential equation is therefore $ y = cx^{-3} $.

As a quick check, we have $ \frac{dy}{dx} = -3cx^{-4} $, therefore

$ 3x^2y dx + x^3dy = 3x^2(cx^{-3})dx + x^3(-3cx^{-4})dx = 0 $.

First order linear differential equation

Problem:

$ y' + 2xy = x $

Solution:

This is a first order linear differential equation, let's consider the derivative of the following form:

$ (p(x)e^{q(x)})' = p'(x)e^{q(x)} + p(x)q'(x)e^{q(x)} = e^{q(x)}(p'(x) + p(x)q'(x)) $

Now we set $ p(x) = y $, $ q'(x) = 2x $, we can multiply both side by $ e^{x^2} $ to get

$ \begin{eqnarray*} e^{x^2}(y' + 2xy) &=& xe^{x^2} \\ (e^{x^2}y)' &=& xe^{x^2} \\ (e^{x^2}y) &=& \int{xe^{x^2}dx} \\ &=& \frac{1}{2}\int{e^{x^2}d(x^2)} \\ &=& \frac{1}{2}e^{x^2} + C \\ y &=& \frac{1}{2} + Ce^{x^{-2}} \\ \end{eqnarray*} $

Thursday, December 24, 2015

Definite Integrals using Complex Residue (2)

Problem:

For $ b^2 < 4ac $: $ \int\limits_{-\infty}^{+\infty}{\frac{dx}{(ax^2+bx+c)^2}} $

Solution:

Consider the contour concatenating $ -R $ to $ R $ and then go through a half circle in the upper half plane back to $ -R $, the half circle part goes to 0 (*), so all we need to do is to compute the residue in the upper half plane.

The integrand can be factorized as:

$ \begin{eqnarray*} & & \frac{1}{(ax^2 + bx + c)^2} \\ &=& \frac{1}{(\frac{1}{4a}(2ax + b + \sqrt{b^2 - 4ac})(2ax + b - \sqrt{b^2 - 4ac}))^2} \\ &=& \frac{16a^2}{(2ax + b + \sqrt{b^2 - 4ac})^2(2ax + b - \sqrt{b^2 - 4ac})^2} \\ \end{eqnarray*} $

So we have two poles with order 2: $ x = \frac{-b + \sqrt{b^2 - 4ac}}{2a} $ and $ x = \frac{-b - \sqrt{b^2 - 4ac}}{2a} $, only the first pole is in the upper half plane, so we compute the residue there.

$ \begin{eqnarray*} & & Res[\frac{16a^2}{(2ax + b + \sqrt{b^2 - 4ac})^2(2ax + b - \sqrt{b^2 - 4ac})^2}, \frac{-b + \sqrt{b^2 - 4ac}}{2a}] \\ &=& \lim\limits_{x \to \frac{-b + \sqrt{b^2 - 4ac}}{2a}}{((x - \frac{-b + \sqrt{b^2 - 4ac}}{2a})^2\frac{16a^2}{(2ax + b + \sqrt{b^2 - 4ac})^2(2ax + b - \sqrt{b^2 - 4ac})^2})'} \\ &=& \lim\limits_{x \to \frac{-b + \sqrt{b^2 - 4ac}}{2a}}{((\frac{2ax + b - \sqrt{b^2 - 4ac}}{2a})^2\frac{16a^2}{(2ax + b + \sqrt{b^2 - 4ac})^2(2ax + b - \sqrt{b^2 - 4ac})^2})'} \\ &=& \lim\limits_{x \to \frac{-b + \sqrt{b^2 - 4ac}}{2a}}{(\frac{4}{(2ax + b + \sqrt{b^2 - 4ac})^2})'} \\ &=& \lim\limits_{x \to \frac{-b + \sqrt{b^2 - 4ac}}{2a}}{(\frac{(-2)4}{(2ax + b + \sqrt{b^2 - 4ac})^3})(2a)} \\ &=& \lim\limits_{x \to \frac{-b + \sqrt{b^2 - 4ac}}{2a}}{\frac{-16a}{(2ax + b + \sqrt{b^2 - 4ac})^3}} \\ &=& \frac{-16a}{(2a(\frac{-b + \sqrt{b^2 - 4ac}}{2a}) + b + \sqrt{b^2 - 4ac})^3} \\ &=& \frac{-16a}{((-b + \sqrt{b^2 - 4ac}) + b + \sqrt{b^2 - 4ac})^3} \\ &=& \frac{-16a}{(2\sqrt{b^2 - 4ac})^3} \\ &=& \frac{-2a}{(\sqrt{b^2 - 4ac})^3} \\ \end{eqnarray*} $

Going back to the integral, we get:

$ \begin{eqnarray*} & & \int\limits_{-\infty}^{+\infty}{\frac{dx}{(ax^2+bx+c)^2}} \\ &=& 2\pi i \frac{-2a}{(\sqrt{b^2 - 4ac})^3} \\ &=& \frac{-4\pi a i}{(\sqrt{b^2 - 4ac})^3} \\ &=& \frac{4\pi a}{(\sqrt{4ac - b^2})^3} \\ \end{eqnarray*} $

Definite Integrals using Complex Residue (1)

Problem:

$ \int\limits_{-\pi}^{\pi}{\frac{\cos\theta}{a + b \cos\theta}d\theta} $

Solution:

This exercise use the substitution $ z = e^{i\theta} $.
That led to $ dz = ie^{i\theta}d\theta $, and therefore $ \frac{dz}{iz} = d\theta $.
The integration limit becomes a unit circle.

Using the Euler's identity $ \cos \theta + i\sin\theta = e^{i\theta} = z $, we can write trigonometric functions in terms of $ z $

$ \cos \theta = \frac{e^{i\theta} + e^{-i\theta}}{2} = \frac{z + \frac{1}{z}}{2} $.
$ \sin \theta = \frac{e^{i\theta} - e^{-i\theta}}{2i} = \frac{z - \frac{1}{z}}{2i} $.

Here is one more convenient result for factorizing general quadratic equation:

$ \begin{eqnarray*} & & ax^2 + bx + c \\ &=& \frac{1}{4a}(4ax^2 + 4abx + 4ac) \\ &=& \frac{1}{4a}((2ax)^2 + 4abx + 4ac) \\ &=& \frac{1}{4a}((2ax)^2 + 4abx + b^2 - b^2 + 4ac) \\ &=& \frac{1}{4a}((2ax + b)^2 - b^2 + 4ac) \\ &=& \frac{1}{4a}((2ax + b)^2 - (b^2 - 4ac)) \\ &=& \frac{1}{4a}((2ax + b)^2 - (\Delta)^2) \\ &=& \frac{1}{4a}((2ax + b + \Delta)(2ax + b - \Delta)) \end{eqnarray*} $

Now, we are all set to start solving the problems.


$ \begin{eqnarray*} & & \int\limits_{-\pi}^{\pi}{\frac{\cos\theta}{a + b \cos\theta}d\theta} \\ &=& \oint{\frac{\frac{z + \frac{1}{z}}{2}}{a + b \frac{z + \frac{1}{z}}{2}}\frac{dz}{iz}} \\ &=& \oint{\frac{z + \frac{1}{z}}{2a + b (z + \frac{1}{z})}\frac{dz}{iz}} \\ &=& \oint{\frac{z^2 + 1}{2az + b (z^2 + 1)}\frac{dz}{iz}} \\ &=& \oint{\frac{z^2 + 1}{bz^2 + 2az + b}\frac{dz}{iz}} \\ \end{eqnarray*} $

To move on, we factorize the quadratic expression, computing $ \Delta $.

$ \begin{eqnarray*} \Delta &=& \sqrt{(2a)^2 - 4(b)(b)} \\ &=& 2 \sqrt{a^2 - b^2} \end{eqnarray*} $

So we move on

$ \begin{eqnarray*} & & \int\limits_{-\pi}^{\pi}{\frac{\cos\theta}{a + b \cos\theta}d\theta} \\ &=& \oint{\frac{z^2 + 1}{\frac{1}{4b}(2bz + 2a + 2 \sqrt{a^2 - b^2})(2bz + 2a - 2 \sqrt{a^2 - b^2})}\frac{dz}{iz}} \\ &=& \oint{\frac{z^2 + 1}{\frac{1}{b}(bz + a + \sqrt{a^2 - b^2})(bz + a - \sqrt{a^2 - b^2})}\frac{dz}{iz}} \\ &=& \oint{\frac{b(z^2 + 1)}{(bz + a + \sqrt{a^2 - b^2})(bz + a - \sqrt{a^2 - b^2})}\frac{dz}{iz}} \\ \end{eqnarray*} $

We have three poles with 1st order: $ z = 0 $, $ z = -\frac{a + \sqrt{a^2 - b^2}}{b} $ and $ z = \frac{\sqrt{a^2 - b^2} - a}{b} $ Only the first and last is within the unit circle.

Next, we compute the residue values using limits

$ \begin{eqnarray*} & & Res[\frac{b(z^2 + 1)}{(bz + a + \sqrt{a^2 - b^2})(bz + a - \sqrt{a^2 - b^2})}\frac{1}{iz}, 0] \\ &=& \lim\limits_{z \to 0}(z \frac{b(z^2 + 1)}{(bz + a + \sqrt{a^2 - b^2})(bz + a - \sqrt{a^2 - b^2})}\frac{1}{iz}) \\ &=& \lim\limits_{z \to 0}(\frac{b(z^2 + 1)}{(bz + a + \sqrt{a^2 - b^2})(bz + a - \sqrt{a^2 - b^2})}\frac{1}{i}) \\ &=& \frac{b((0)^2 + 1)}{(b(0) + a + \sqrt{a^2 - b^2})(b(0) + a - \sqrt{a^2 - b^2})}\frac{1}{i} \\ &=& \frac{b}{(a + \sqrt{a^2 - b^2})(a - \sqrt{a^2 - b^2})}\frac{1}{i} \\ &=& \frac{b}{(a^2 - (a^2 - b^2))}\frac{1}{i} \\ &=& \frac{b}{b^2}\frac{1}{i} \\ &=& \frac{1}{b}\frac{1}{i} \\ \end{eqnarray*} $

We also have

$ \begin{eqnarray*} & & Res[\frac{b(z^2 + 1)}{(bz + a + \sqrt{a^2 - b^2})(bz + a - \sqrt{a^2 - b^2})}\frac{1}{iz}, \frac{\sqrt{a^2 - b^2} - a}{b}] \\ &=& \lim\limits_{z \to \frac{\sqrt{a^2 - b^2} - a}{b}}((z - \frac{\sqrt{a^2 - b^2} - a}{b}) \frac{b(z^2 + 1)}{(bz + a + \sqrt{a^2 - b^2})(bz + a - \sqrt{a^2 - b^2})}\frac{1}{iz}) \\ &=& \lim\limits_{z \to \frac{\sqrt{a^2 - b^2} - a}{b}}(\frac{1}{b}(bz - (\sqrt{a^2 - b^2} - a)) \frac{b(z^2 + 1)}{(bz + a + \sqrt{a^2 - b^2})(bz + a - \sqrt{a^2 - b^2})}\frac{1}{iz}) \\ &=& \lim\limits_{z \to \frac{\sqrt{a^2 - b^2} - a}{b}}(\frac{1}{b}(bz + a - \sqrt{a^2 - b^2}) \frac{b(z^2 + 1)}{(bz + a + \sqrt{a^2 - b^2})(bz + a - \sqrt{a^2 - b^2})}\frac{1}{iz}) \\ &=& \lim\limits_{z \to \frac{\sqrt{a^2 - b^2} - a}{b}}(\frac{1}{b} \frac{b(z^2 + 1)}{bz + a + \sqrt{a^2 - b^2}}\frac{1}{iz}) \\ &=& \frac{1}{b} \frac{b((\frac{\sqrt{a^2 - b^2} - a}{b})^2 + 1)}{b(\frac{\sqrt{a^2 - b^2} - a}{b}) + a + \sqrt{a^2 - b^2}}\frac{1}{i(\frac{\sqrt{a^2 - b^2} - a}{b})} \\ &=& \frac{1}{b} \frac{b((\frac{\sqrt{a^2 - b^2} - a}{b})^2 + 1)}{\sqrt{a^2 - b^2} - a + a + \sqrt{a^2 - b^2}}\frac{1}{i(\frac{\sqrt{a^2 - b^2} - a}{b})} \\ &=& \frac{1}{b} \frac{b((\frac{\sqrt{a^2 - b^2} - a}{b})^2 + 1)}{2\sqrt{a^2 - b^2}}\frac{1}{i(\frac{\sqrt{a^2 - b^2} - a}{b})} \\ &=& \frac{1}{b} \frac{b^2((\frac{\sqrt{a^2 - b^2} - a}{b})^2 + 1)}{2\sqrt{a^2 - b^2}}\frac{1}{i(\sqrt{a^2 - b^2} - a)} \\ &=& \frac{1}{b} \frac{(\sqrt{a^2 - b^2} - a)^2 + b^2}{2\sqrt{a^2 - b^2}}\frac{1}{i(\sqrt{a^2 - b^2} - a)} \\ &=& \frac{1}{b} \frac{(a^2 - b^2) - 2a\sqrt{a^2 - b^2} + a^2 + b^2}{2\sqrt{a^2 - b^2}}\frac{1}{i(\sqrt{a^2 - b^2} - a)} \\ &=& \frac{1}{b} \frac{2a^2 - 2a\sqrt{a^2 - b^2}}{2\sqrt{a^2 - b^2}}\frac{1}{i(\sqrt{a^2 - b^2} - a)} \\ &=& \frac{1}{b} \frac{-2a(\sqrt{a^2 - b^2} - a)}{2\sqrt{a^2 - b^2}}\frac{1}{i(\sqrt{a^2 - b^2} - a)} \\ &=& \frac{1}{b} \frac{-a}{\sqrt{a^2 - b^2}}\frac{1}{i} \\ \end{eqnarray*} $

Last, we put these back to the integral, we have

$ \begin{eqnarray*} & & \int\limits_{-\pi}^{\pi}{\frac{\cos\theta}{a + b \cos\theta}d\theta} \\ &=& 2\pi i(\frac{1}{b}\frac{1}{i} + \frac{1}{b} \frac{-a}{\sqrt{a^2 - b^2}}\frac{1}{i}) \\ &=& \frac{2\pi}{b} (1 - \frac{a}{\sqrt{a^2 - b^2}}) \\ \end{eqnarray*} $

Q.E.D. This took me 1.5 hours.