Showing posts with label partial fractions. Show all posts
Showing posts with label partial fractions. Show all posts

Thursday, 29 June 2017

A Difficult Integral

I'm wanting to keep up my LaTeX skills so I'm returning to an integral, specifically: $$  \int\limits_0^1 \, \frac{x}{x^3+1}\text{d}x$$The integral is not all that difficult really but it does involve a fair number of steps to get it right. Here is a graph of what is being attempted:


I used symbolab to work through the solution which turns out to be:\[\frac{1}{9}(\sqrt{3}\pi-\ln{(8)})\]The first step in the solution is to factorise the denominator. This is easy because \(x^3+1 \) is a sum of two cubes and so can be written as \((x+1)(x^2-x+1)\). Using partial fractions, the integral can be converted into the following form:\[ \frac{1}{3} \int\limits_0^1 \frac{x+1}{x^2-x+1} \text{d}x-\frac{1}{3} \int\limits_0^1 \frac{1}{x+1} \text{d}x \]The RHS integral is straightforward but the LHS one poses more difficulties. The way forward with the former is to write the quadratic in the denominator as a sum of two squares:\[ \frac{1}{3} \int\limits_0^1  \frac{x+1}{(x-\frac{1}{2})^2+\frac{3}{4}} \text{d}x \]This newly changed denominator can then be divided into the two parts of the numerator to yield:\[ \frac{1}{3} \int\limits_0^1 \frac{x}{(x-\frac{1}{2})^2+\frac{3}{4}}+\frac{1}{3} \int\limits_0^1 \frac{1}{(x-\frac{1}{2})^2+\frac{3}{4}} \]I'm not going to go into the details here but, with the appropriate substitutions, the LHS of this integral can be integrated to a logarithm and the RHS to an arctan using the formulae:\[ \int \frac{2t}{t^2+1} \text{d}t = \ln|t^2+1| + C \text{ and }\int \frac{1}{t^2+1} \text{d}t=\tan \!^{-1}{t}+C \]The indefinite integral for \( x/(x^3+1) \) turns out to be: \[ \frac{1}{6} \Big( \ln|4x^2-4x+4|+2\sqrt{3} \, \tan^{-1} \big( \frac{2}{\sqrt{3}}(x-\frac{1}{2}) \big) \Big)-\frac{1}{3}\ln|x+1|+C \]The definite integral for the limits of 0 and 1 is what was quoted earlier at the beginning of this post. In conclusion, I must say that Blogger is still inconsistently handling the display mode for LaTeX: sometimes it renders the LaTeX using the Javascript and other times it returns an image of the rendered code. Annoying.

Thursday, 23 February 2017

LaTeX and Integrating Square Root of Tangent Function

The following integration follows the steps outlined in this YouTube video that I watched, so I'm not claiming any originality here. However, I wanted to practise my LaTeX skills and so, using MacTex, a LaTeX implementation for OS X, and TeXShop, the front-end text editor, I translated the steps outlined in the video into LaTeX. MacTex produced a crisp PDF output file but later I wondered what would happen if I copied the code and pasted it into this blog. Well, turns out it rendered almost perfectly. The result is shown below:

**********************************************

How can we deal with  \( \! \! \int \sqrt{\tan x} \, \mathrm {d} x \)? If the square root sign wasn't there it would be easy and we'd get \( \ - \log(\cos x)+C \). However, it is there and we need to find a way to deal with it. Well, it turns out that there is a judicious substitution that we can use to get the process started and that substitution is \( u=\sqrt{\tan x} \).

This means that \( u^2=\tan x \) and so \( {2 \, u \, \mathrm {d} u} /{\mathrm {d}  x}=\sec^2 x \). \( \mathrm{d}x \)can now be written as \( 2 \, u \, \mathrm {d} u /sec^2 x \) and thus the integral becomes \( \! \! \int 2 \, u^2 \, \mathrm{d} u/\sec^2x \)and the problem now is to express \( \sec^2 x \) in terms of \(u\). Fortunately that's not too difficult with recourse to a little trigonometry. We know \( \tan x=u^2 \) and if we write this as \( \tan x=u^2/1 \) (opposite over adjacent) then the hypotenuse of the associated right-angled triangle is \( \sqrt{1+u^4} \).

Thus \( \cos x=1/\sqrt{1+u^4} \), \( \sec^2 x=1+u^4 \) and the integral becomes: $$\! \! \int \frac{2 \, u^2}{1+u^4} \mathrm {d} u$$There is still a way to go before we arrive at the solution to our problem but this is a far more manageable integral than the one that we started with. Now we need to spend some time manipulating the integral to get it into the right form. Firstly, let's divide top and bottom by \(u^2\). This gives us: $$\! \! \int \frac {2} {u^2+1/u^2} \mathrm {d} u$$The next step is to us modify the numerator 2 so that it looks like this:$$1+1/u^2+1-1/u^2$$Now we separate the integral into two halves as follows:$$\! \! \int \frac {1 + 1/u^2}{u^2+1/u^2} \mathrm {d} u \quad + \quad \! \! \int \frac {1 - 1/u^2}{u^2+1/u^2} \mathrm {d} u$$The denominators in both integrals can be rewritten as shown:$$\! \! \int \frac {1 + 1/u^2}{(u-1/u)^2+2} \mathrm {d} u \quad + \quad \! \! \int \frac {1 - 1/u^2}{(u+1/u)^2-2} \mathrm {d} u$$Each integral needs to be dealt with separately so let's begin with the integral on the left hand side. However, we need to make another substitution before we proceed. Let $t=u-1/u$. Differentiating both sides w.r.t. u, gives $\mathrm {d} t/\mathrm{d}u=1+1/u^2$ and so the integral on the left hand side can be rewritten:$$\! \! \int \frac {1 + 1/u^2}{(u-1/u)^2+2} \mathrm {d} u=\! \! \int \frac {1}{t^2+2} \mathrm {d} t$$An integral of the form $$\! \! \int \frac {1}{t^2+a^2} \mathrm {d} t =\frac{1}{a} \tan^{-1} \bigg (\frac{t}{a}\bigg ) + C $$and so we end up with $$\frac{1}{\sqrt{2}}\tan^{-1} \bigg (\frac {t}{\sqrt{2}}\bigg ) + C $$Now we need to backtrack, replacing $t$ by $u$ and $u$ by $\sqrt{\tan x}$. This will give us firstly $$\frac{1}{\sqrt{2}}\tan^{-1} \bigg (\frac {u-1/u}{\sqrt{2}}\bigg ) + C $$And then $$\frac{1}{\sqrt{2}}\tan^{-1} \bigg (\frac {\sqrt{\tan x}-1/\sqrt{\tan x}}{\sqrt{2}}\bigg ) + C $$But this is only the left hand side of our integral! Now we need to go back and deal with the right hand side integral which was:$$\quad \! \! \int \frac {1 - 1/u^2}{(u+1/u)^2-2} \mathrm {d} u$$This time let $t=u+1/u$. Differentiating both sides w.r.t. u, gives $\mathrm {d} t/\mathrm{d}u=1-1/u^2$ and so the integral on the left hand side can be rewritten:$$\quad \! \! \int \frac {1 - 1/u^2}{(u+1/u)^2-2} \mathrm {d} u=\! \! \int \frac {1}{t^2-2} \mathrm {d} t$$This integral can be solved by rewriting $t^2-2$ as $(t-\sqrt{2})(t+\sqrt{2})$ and then using the method of partial fractions to find A and B in the expression:$$\frac{A}{t-\sqrt{2}}+\frac{B}{t+\sqrt{2}}$$This leads to $(A+B)t+(A-B)\sqrt{2}=1$, $A=-B$, $2A\sqrt{2}=1$ and $A=1/2\sqrt{2}$
Hence $B=-1/2\sqrt{2}$ and the integral can be now be rewritten as:$$\int \frac{1/2\sqrt{2}}{t-\sqrt{2}} \mathrm {d} t-\int \frac{1/2\sqrt{2}}{t+\sqrt{2}} \mathrm {d} t$$Both these integrals are natural logarithms and so the result obtained is:
$$\frac{1}{2\sqrt{2}}(\ln (t-\sqrt{2})-\ln (t+\sqrt{2}))+C$$This simplifies to:$$\frac{1}{2\sqrt{2}}\ln \bigg(\frac {t-\sqrt{2}}{t+\sqrt{2}} \bigg )+C$$Now we need to backtrack, replacing $t$ by $u$ and $u$ by $\sqrt{\tan x}$. This will give us firstly$$\frac{1}{2\sqrt{2}}\ln \bigg(\frac {(u+1/u)-\sqrt{2}}{(u+1/u)+\sqrt{2}} \bigg )+C$$And then $$\frac{1}{2\sqrt{2}}\ln \bigg(\frac {(\sqrt{\tan x}+1/\sqrt{\tan x})-\sqrt{2}}{(\sqrt{\tan x}+1/\sqrt{\tan x})+\sqrt{2}} \bigg )+C$$Putting both integrals together now we get the result that:$$\! \! \int \sqrt{\tan x} \mathrm {d} x=\frac{1}{\sqrt{2}}\tan^{-1} \bigg (\frac {\sqrt{\tan x}-1/\sqrt{\tan x}}{\sqrt{2}}\bigg )+ \\ \frac{1}{2\sqrt{2}}\ln \bigg(\frac {(\sqrt{\tan x}+1/\sqrt{\tan x})-\sqrt{2}}{(\sqrt{\tan x}+1/\sqrt{\tan x})+\sqrt{2}} \bigg )+C$$
It was an arduous process but in the end our goal was accomplished.