online advertising
Showing posts with label Integral. Show all posts
Showing posts with label Integral. Show all posts

Monday, December 25, 2017

Integral (4)

Problem:

$ \int\frac{d\theta}{A + B \cos\theta} $

Solution:

Let $ t = \tan\frac{\theta}{2} $, $ \cos \theta = \frac{1 - t^2}{1 + t^2} $, $ d\theta = \frac{2}{1 + t^2}dt $

$ \begin{eqnarray*} & & \int\frac{d\theta}{A + B \cos\theta} \\ &=& \int\frac{\frac{2}{1 + t^2}dt}{A + B \frac{1 - t^2}{1 + t^2}} \\ &=& \int\frac{2dt}{A(1 + t^2) + B(1 - t^2)} \\ &=& \int\frac{2dt}{(A + B) + (A - B)t^2} \\ &=& 2\sqrt{\frac{1}{(A + B)(A - B)}}\tan^{-1}\left(\sqrt{\frac{A - B}{A + B}}t\right) \\ &=& 2\sqrt{\frac{1}{(A + B)(A - B)}}\tan^{-1}\left(\sqrt{\frac{A - B}{A + B}}\tan\frac{x}{2}\right) \\ \end{eqnarray*} $

The second last step comes from a previously derived result which can be found here.

Integral (3)

Problem:

$ \int\frac{dt}{P + Qt^2} $


Solution:

Let $ \sqrt{\frac{P}{Q}}y = t $, so $ \sqrt{\frac{P}{Q}}dy = dt $.


$ \begin{eqnarray*} & & \int\frac{dt}{P + Qt^2} \\ &=& \int\frac{\sqrt{\frac{P}{Q}}dy}{P + Q\left(\sqrt{\frac{P}{Q}}y\right)^2} \\ &=& \int\frac{\sqrt{\frac{P}{Q}}dy}{P + Q\frac{P}{Q}y^2} \\ &=& \int\frac{\sqrt{\frac{P}{Q}}dy}{P + Py^2} \\ &=& \sqrt{\frac{P}{Q}}\int\frac{dy}{P + Py^2} \\ &=& \sqrt{\frac{1}{PQ}}\int\frac{dy}{1 + y^2} \\ &=& \sqrt{\frac{1}{PQ}}\tan^{-1} y \\ &=& \sqrt{\frac{1}{PQ}}\tan^{-1} \left(\sqrt{\frac{Q}{P}}t\right) \\ \end{eqnarray*} $

Sunday, February 14, 2016

Integrating unit step and delta

In the previous problem, I was working on some piecewise linear functions and doing calculus there. Having many cases is just error prone. Now I try to do thing more algebraically.

The first thing I notice is integrating delta function is simply sampling property, but it applies only if the integrating domain contains 0, that make three cases and it is just not pleasant.

Now, let 'simplify' using step functions.

$ \int\limits_{a}^{b}{\delta(x)f(x)dx} = (\theta(b) - \theta(a))f(x) $

Similarly, we also have this:

$ \int\limits_{a}^{b}{\theta(x)f(x)} = \theta(b)(F(b) - F(0)) - \theta(a)(F(a) - F(0)) $.

To check these, one just consider all 6 permutations of $ a $, $ b $ and $ 0 $. 

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.

Friday, December 4, 2015

Integral (2)

Problem:

$ \int{\sqrt{\frac{4 - x}{4 + x}}dx} $

Solution:

This one is not easy, I am thinking about this identity

$ \sqrt{\frac{1 - \sin \theta}{1 + \sin\theta}} = \frac{1-\tan \frac{\theta}{2}}{1+\tan \frac{\theta}{2}} $

Therefore I let $ x = 4 \sin \theta $, that gives $ dx = 4 \cos \theta d\theta $, the integral becomes

$ \begin{eqnarray*} &=& \int{\sqrt{\frac{4 - 4\sin\theta}{4 + 4\sin\theta}}4 \cos \theta d\theta} \\ &=& \int{2\sqrt{\frac{1 - \sin\theta}{1 + \sin\theta}}4 \cos \theta d\theta} \\ &=& \int{2\frac{1-\tan \frac{\theta}{2}}{1+\tan \frac{\theta}{2}}4 \cos \theta d\theta} \\ &=& \int{2\frac{1-\tan \frac{\theta}{2}}{1+\tan \frac{\theta}{2}}4 \frac{1-\tan^2 \frac{\theta}{2}}{1+\tan^2 \frac{\theta}{2}} d\theta} \end{eqnarray*} $

Now it is quite obvious that we should do the t - substitution

$ \begin{eqnarray*} t &=& \tan \frac{\theta}{2} \\ dt &=& \sec^2 \frac{\theta}{2} \frac{1}{2} d \theta\\ dt &=& (1 + t^2) \frac{1}{2} d \theta \\ d \theta &=& \frac{2tdt}{1 + t^2} \\ \end{eqnarray*} $

$ \begin{eqnarray*} & & \int{2\frac{1-\tan \frac{\theta}{2}}{1+\tan \frac{\theta}{2}}4 \frac{1-\tan^2 \frac{\theta}{2}}{1+\tan^2 \frac{\theta}{2}} d\theta} \\ &=& \int{2\frac{1-t}{1+t}4 \frac{1-t^2}{1+t^2} \frac{2tdt}{1 + t^2}} \\ &=& 8\int{\frac{1}{1+t^2} - \frac{2t}{(1 + t^2)^2}dt} \end{eqnarray*} $

The first term can be solved by substitute $ t = \tan \phi $, $ dt = \sec^2 \phi d\phi $

$ \begin{eqnarray*} & & \int{\frac{1}{1+t^2}dt} \\ &=&\int{\frac{1}{1+\tan^2 \phi}\sec^2 \phi d\phi} \\ &=&\int{\frac{1}{\sec^2 \phi}\sec^2 \phi d\phi} \\ &=&\int{d\phi} \\ &=&\phi \end{eqnarray*} $

The second term can be solved by substitute $ u = 1 + t^2 $, $ du = 2tdt $

$ \begin{eqnarray*} & & \int{\frac{2t}{(1 + t^2)^2}dt} \\ &=& \int{\frac{1}{u^2}du} \\ &=& \frac{-1}{u} \end{eqnarray*} $

Putting them together, we have

$ \begin{eqnarray*} & & \int{\sqrt{\frac{4 - x}{4 + x}}dx} \\ &=& 8\int{\frac{1}{1+t^2} - \frac{2t}{(1 + t^2)^2}dt} \\ &=& 8(\phi + \frac{1}{u}) \\ &=& 8(\phi + \frac{1}{1 + t^2}) \end{eqnarray*} $

Now we have $ t = \tan \phi, t = \tan \frac{\theta}{2} $, so we simply have $ \phi = \frac{\theta}{2} $

$ \begin{eqnarray*} & & 8(\frac{\theta}{2} + \frac{1}{1 + t^2}) \\ &=& 8(\frac{\theta}{2} + \frac{1}{1 + \tan^2 \frac{\theta}{2}}) \\ &=& 8(\frac{\theta}{2} + \frac{1}{\sec^2 \frac{\theta}{2}}) \\ &=& 8(\frac{\theta}{2} + \cos^2 \frac{\theta}{2}) \\ &=& 8(\frac{\theta}{2} + \frac{1 + \cos \theta}{2}) \\ &=& 4(\theta + 1 + \cos \theta) \end{eqnarray*} $

Now constant can be dropped for indefinite integral, and $ x = 4 \sin \theta $, so finally we have

$ \begin{eqnarray*} & & 4(\theta + \cos \theta) \\ &=& 4(\arcsin(\frac{x}{4}) + \cos \theta) \\ &=& 4(\arcsin(\frac{x}{4}) + \sqrt{1 - \sin^2 \theta}) \\ &=& 4(\arcsin(\frac{x}{4}) + \sqrt{1 - (\frac{x}{4})^2}) \end{eqnarray*} $

There we go, what a complicated problem!

Sunday, November 29, 2015

Integral (1)

Let's do some integrals! The good thing about integral is

(a) It requires some tricks to get it done, an interesting intellectual challenge.
(b) It is easy to check if I have got the right answer, even without the model answer, just differentiate it.

Problem:

$ \int{\frac{dx}{\sqrt{x} + \sqrt{x + 1}}} $

Solution:

 The trick is rationalizing:

$ \begin{eqnarray*} & & \int{\frac{dx}{\sqrt{x} + \sqrt{x + 1}}} \\ &=& \int{\frac{dx}{\sqrt{x} + \sqrt{x + 1}}\frac{\sqrt{x + 1} - \sqrt{x}}{\sqrt{x + 1} - \sqrt{x}}} \\ &=& \int{(\sqrt{x + 1} - \sqrt{x})dx} \\ &=& \frac{2}{3}(x+1)^{\frac{3}{2}} - \frac{2}{3}x^{\frac{3}{2}} + C \end{eqnarray*} $

Sunday, November 15, 2015

Area under parabola

Problem:

You have a symmetric parabola shape like this, and you are trying to compute the area, what do you do?



Solution:

To generalize the problem let me denote $ b $ as the base and $ h $ as the height instead of those specific numbers

The first thing to do is to find the equation. It passes through $ (-\frac{b}{2}, 0) $ and $ (\frac{b}{2}, 0) $ suggest that it has the form $ y = s(x - \frac{b}{2})(x + \frac{b}{2}) = s(x^2 - \frac{b^2}{4}) $

It passes through $ (0, h) $ suggest that $ -s\frac{b^2}{4} = h $ or $ s = -\frac{4h}{b^2} $.

So the full equation of the parabola is $ -\frac{4h}{b^2}x^2 + h $.

The area can be found as

$ \begin{eqnarray*} A &=& \int\limits_{-\frac{b}{2}}^{\frac{b}{2}}(-\frac{4h}{b^2}x^2 + h)dx \\ &=& -\frac{4h}{3b^2}x^3 + hx |_{-\frac{b}{2}}^{\frac{b}{2}} \\ &=& (-\frac{4h}{3b^2}(\frac{b}{2})^3 + h(\frac{b}{2})) - (-\frac{4h}{3b^2}(-\frac{b}{2})^3 + h(-\frac{b}{2})) \\ &=& (-\frac{hb}{6} + \frac{hb}{2}) - (\frac{hb}{6} - \frac{hb}{2}) \\ &=& \frac{2hb}{3} \end{eqnarray*} $

This last formula is really simple and worth remembering. A triangle is $ \frac{hb}{2} $, and a parabola is $ \frac{2hb}{3} $.

Wednesday, September 9, 2015

Indefinite integral using hyperbolic function

Problem:

$ \int{\frac{1}{\sqrt{4x^2 + 25}}dx} $

Solution:

The key substitution to use is $ x = \frac{5}{2}\sinh y $. Then we have $ dx = \frac{5}{2}\cosh y dy$.

$ \begin{eqnarray*} & & int{\frac{1}{\sqrt{4x^2 + 25}}dx} \\ &=& \int{\frac{1}{\sqrt{4(\frac{5}{2}\sinh y)^2 + 25}}\frac{5}{2}\cosh y dy} \\ &=& \int{\frac{1}{\sqrt{25\sinh^2 y + 25}}\frac{5}{2}\cosh y dy} \\ &=& \int{\frac{1}{\sqrt{\sinh^2 y + 1}}\frac{1}{2}\cosh y dy} \\ &=& \int{\frac{1}{\cosh y}\frac{1}{2}\cosh y dy} \\ &=& \int{\frac{1}{2} dy} \\ &=& \frac{1}{2}y + C \\ &=& \frac{1}{2}\sinh^{-1}\frac{2x}{5} + C \\ \end{eqnarray*} $