Thursday, 15 January 2015

Eigenvalues and eigenvectors

$\lambda$ is an eigenvalue of $A$ if there exists a non-zero vector $\vec{v}$ such that
$A\vec{v}=\lambda \vec{v}$.
Vector $\vec{v}$ is called an eigenvector of $A$ corresponding to $\lambda$.

$A\vec{v}=\lambda \vec{v}\\
(A-\lambda I)\vec{v}=\vec{0}$

Note that $A-\lambda I$ must be singular, implying that $\det(A-\lambda I)=0$.
[If $A-\lambda I$ is invertible, $(A-\lambda I)^{-1}(A-\lambda I)\vec{v}=(A-\lambda I)^{-1}\vec{0} \Rightarrow \vec{v}=\vec{0}$. Contradiction. We want a non-zero vector.]
After dealing with some algebra, we know the eigenvalues.

Sidenote: the set of all vectors $\vec{v}$ satisfying $A\vec{v}=\lambda \vec{v}$ is called the eigenspace of $A$ corresponding to $\lambda$.

Application: solving differential equations

Example:
$\frac{dx}{dt}=4x-y\\ \frac{dy}{dt}=2x+y$
$\frac{dX}{dt}=AX$ where $X=\begin{pmatrix}x\\y \end{pmatrix},A=\begin{pmatrix}4&-1\\2&1 \end{pmatrix}$

$\frac{d}{dt}PY=APY\\
P\frac{dY}{dt}=APY\\
\frac{dY}{dt}=P^{-1}APY$
Characteristic polynomial $\delta(t)$ of $A$:
$\delta(t)=|tI-A|=\begin{vmatrix} t-4 & 1\\ -2 & t-1 \end{vmatrix}=t^2-5t+6=(t-3)(t-2)$
Eigenvalues of $A$: $2,3$
Substitute $t=3$, we have the homogeneous system $-x+y=0$ and $-2x+2y=0 \Rightarrow \vec{v_1}=(1,1)$.
Substitute $t=2$, $-2x+y=0 \Rightarrow \vec{v_2}=(1,2)$.
$P=(\vec{v_1}\vec{v_2})=\begin{pmatrix}1&1\\1&2\end{pmatrix}$
$B=P^{-1}AP=\begin{pmatrix}3&0\\0&2\end{pmatrix}$
Diagonalise the system by changing variables using $P$.
$\begin{pmatrix}x\\y \end{pmatrix}=P\begin{pmatrix}r\\s \end{pmatrix}\\
x = r + s\\
y = r + 2s\\
\frac{d}{dt}\begin{pmatrix}r\\s \end{pmatrix}=\begin{pmatrix}3&0\\0&2\end{pmatrix}\begin{pmatrix}r\\s \end{pmatrix}\\
\begin{pmatrix}\frac{dr}{dt}\\\frac{ds}{dt} \end{pmatrix}=\begin{pmatrix}3r\\2s \end{pmatrix}\\
\therefore x=ae^{3t}+be^{2t}\\
y=ae^{3t}+2be^{2t}$

More applications

Saturday, 10 January 2015

Methods of integration

Usual methods:
1. Direct Integration
It's not too difficult to recognise integrals of the form $\int f(x)f'(x)dx=\int f(x) d[f(x)]$.

Example:
$\int (5x^3+4x^2)(15x^2+8x)dx\\= \int (5x^3+4x^2) d(5x^3+4x^2)\\= \frac{(5x^3+4x^2)^2}{2}+C$

2. Expansion
Whenever we see (x ±  )^(a number) and it seems that substitution won't work, expansion is a good approach.

Example:
$\int (x^2-1)^6 dx\\= \int (x^{12}-6x^{10}+15x^8-20x^6+15x^4-6x^2+1) dx\\= \frac{x^{13}}{13}-6\frac{x^{11}}{11}+5\frac{x^9}{3}-20\frac{x^7}{7}+\frac{x^5}{3}-2x^3+x+C$

3. Substitution
i. u-substitution
ii. trig-substitution
[How to find the right substitution?]
[<=> change of coordinates]
[<=> linear algebra]

4. Integration by parts
$\frac{d}{dx}(uv)=u\frac{dv}{dx}+v\frac{du}{dx}\\ uv=\int udv+\int vdu\\ \int udv=uv - \int vdu$

[How to know which is u and which is v?]


6. Reduction formula
Technical.

Special methods:
3. Substitution (cont'd)
iii. Weierstrass t-substitution / Tangent half-angle substitution

Fundamental Theorem of Calculus

Example:
$\large \int_0^1 \frac{x^t-1}{\ln x} dx$ where $t\geq 0$

Let $\large{F(t)=\int_0^1 \frac{x^t-1}{\ln x}dx\\
\begin{align}F'(t)&=\frac{d}{dt}\int_0^1\frac{x^t-1}{\ln x}dx\\
&=\int_0^1 \frac{d}{dt}\frac{x^t-1}{\ln x}dx\\
&=\int_0^1\frac{1}{\ln x}\frac{d}{dt}(x^t-1)dx \:\:\:\:\:[\frac{d}{dx}x^t=x^t \ln x]\\
&=\int_0^1 x^t dx\\
&=\frac{1}{t+1}\end{align}}$

Integrate again,
$F(t)=\ln(t+1)+C$
Since $F(0)=0$, we have $C=0$ and $F(t)=\ln(t+1)$.

Make use of known integrals

Manipulations

Change of coordinates (Transform into a double integral then switch to polar coordinates)

Let I = $\int_0^\infty e^{-x^2}dx$

$I^2=\int_0^\infty e^{-x^2}dx \int_0^\infty e^{-y^2}dy$

$=\int_0^\infty[\int_0^\infty e^{-x^2}dx]e^{-y^2}dy$

$=\int_0^\infty \int_0^\infty e^{-(x^2+y^2)}dx dy$

$=\int_0^{\frac{\pi}{2}}\int_0^\infty e^{-r^2}rdr d\theta$

$=\int_0^{\frac{\pi}{2}}-\frac{1}{2}e^{-r^2}|_0^\infty d\theta$

$=\frac{\pi}{4}$

It follows that I = $\frac{\sqrt\pi}{2}$.

Evaluate a general integral first: Parameter differentiation p56

Symmetry
http://www2.math.umd.edu/~punshs/Calculus/Integration.pdf

Odd function
$\int_{-2}^2 (1-2x-x^{16} \sin x+17x^7\sqrt{1+x^2}-x^{11} \cos x )dx$
Let $f(x)=-2x-x^{16} \sin x+17x^7\sqrt{1+x^2}-x^{11} \cos x$
$f(-x)=2x+x^{16} \sin x-17x^7\sqrt{1+x^2}+x^{11} \cos x=-f(x)$
$\Rightarrow \int_{-2}^2 (1-2x-x^{16} \sin x+17x^7\sqrt{1+x^2}-x^{11} \cos x )dx\\=\int_{-2}^2 (1+f(x))dx\\=4$

Linear Algebra
i. Orthogonality
Example:
$\int_{-\pi}^\pi (3+2\sin x+3\cos x)(1+4\sin x)dx$

$1,\sin x,\cos x$ are orthogonal on $[-\pi,\pi]$

$=\int_{-\pi}^\pi 3 dx+\int_{-\pi}^\pi 8\sin^2 x dx$

$=3(2\pi)+8\pi$

$=14\pi$

ii. Change of basis
Example:
Let $\mathbb{B}=\left\{1,\cos t,\cos^2 t,...,\cos^6 t\right\}$ and $\mathbb{C}=\left\{1,\cos t,\cos 2t,...,\cos 6t\right\}$.
By De Moivre's theorem,
$\cos 2t=-1+2\cos^2 t$
$\cos 3t=-3\cos t+4\cos^3 t$
$\cos 4t=1-8\cos^2 t+8\cos^4 t$
$\cos 5t=5\cos t-20\cos^3 t+16\cos^5 t$
$\cos 6t=-1+18\cos^2 t-48\cos^4 t+32\cos^6 t$

$P=[\mathbb{B}]_\mathbb{C}=\begin{pmatrix} 1 & 0 & -1 & 0 & 1 & 0 & -1\\ 0 & 1 & 0 & -3 & 0 & 5 & 0 \\ 0 & 0 & 2 & 0 & -8 & 0 & 18 \\ 0 & 0 & 0 & 4 & 0 & -20 & 0 \\ 0 & 0 & 0 & 0 & 8 & 0 & -48 \\ 0 & 0 & 0 & 0 & 0 & 16 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 32 \end{pmatrix}$

$P^{-1}=\frac{1}{32}\begin{pmatrix} 32 & 0 & 16 & 0 & 12 & 0 & 10\\ 0 & 32 & 0 & 24 & 0 & 20 & 0 \\ 0 & 0 & 16 & 0 & 16 & 0 & 15 \\ 0 & 0 & 0 & 8 & 0 & 10 & 0 \\ 0 & 0 & 0 & 0 & 4 & 0 & 6 \\ 0 & 0 & 0 & 0 & 0 & 2 & 0 \\ 0 & 0 & 0 & 0 & 0 & 0 & 1 \end{pmatrix}$

Say we want to evaluate $\int (5\cos^3 t-6\cos^4 t+5\cos^5 t-12\cos^6 t)dt$.

$P^{-1}(0,0,0,5,-6,5,-12)=(-6,\frac{55}{8},-\frac{69}{8},\frac{45}{16},-3,\frac{5}{16},\frac{-3}{8})$

$\int (5\cos^3 t-6\cos^4 t+5\cos^5 t-12\cos^6 t)dt\\
=\int (-6+\frac{55}{8}\cos t-\frac{69}{8}\cos 2t+\frac{45}{16}\cos 3t-3\cos 4t+\frac{5}{16}\cos 5t-\frac{3}{8}\cos 6t)dt\\
=-6t+\frac{55}{8}\sin t-\frac{69}{16}\sin 2t+\frac{15}{16}\sin 3t-\frac{3}{4}\sin 4t+\frac{1}{16}\sin 5t-\frac{1}{16}\sin 6t+C$

Geometry
$\int_0^1 [(1-x^5)^{\frac{1}{4}}-(1-x^4)^{\frac{1}{5}}]dx$
Note that $\int_0^1 (1-x^5)^{\frac{1}{4}}dx=\int_0^1 (1-y^4)^{\frac{1}{5}}dy$.
Both are the area bounded by $x^5+y^4=1$ with the x and y-axes.
So answer: 0.

Recursive [prob solv] refer to notebook

Probability density function
This will be explained in another post.

Examples:
Normal distribution
$\large \int_{-\infty}^\infty e^{-4x^2}dx$
$\large =\int_{-\infty}^\infty exp\left\{\frac{x^2}{\frac{1}{4}} \right\}dx$
$\large =\int_{-\infty}^\infty exp\left\{\frac{x^2}{2(\frac{1}{8})} \right\}dx$
$\large \sigma^2=\frac{1}{8}$ and $\mu =0$
$\large{\begin{align}\therefore \int_{-\infty}^\infty e^{-4x^2}dx &= \sqrt{\frac{1}{8}} \sqrt{2\pi} \int_{-\infty}^\infty \frac{1}{\sqrt{\frac{1}{8}} \sqrt{2\pi}}exp\left\{\frac{x^2}{2(\frac{1}{8})} \right\}dx\\
&=\sqrt{\frac{1}{8}} \sqrt{2\pi}\\
&=\frac{\sqrt{\pi}}{2}\end{align}}$

Gamma distribution
$\large \int_0^\infty 81e^{-3x}x^4dx$

$\large =\frac{\Gamma(5)}{3}\int_0^\infty \frac{3e^{-3x}(3x)^4}{\Gamma(5)}dx$

$\large =\frac{4!}{3}$

$\large =8$

We can integrate a function of the form $e^{-kx}x^s$ using gamma distribution. This avoids integrating by parts as many as s times.

Beta distribution
$\large \int_0^1 x^5 (1-x^2)^9 dx$

$\large =\int_0^1 (x^2)^{\frac{5}{2}} (1-x^2)^9 dx$

$\large \stackrel{y=x^2}{=}\int_0^1 \frac{y^{\frac{5}{2}}(1-y)^9}{2\sqrt{y}}dy$

$\large =\frac{1}{2}\int_0^1 y^2(1-y)^9dy$

$\large =\frac{1}{2}B(3,10) \int_0^1 \frac{y^2(1-y)^9}{B(3,10)}dy$

$\large =\frac{1}{2}\frac{\Gamma(3)\Gamma(10)}{\Gamma(13)}$

$\large =\frac{1}{2}\frac{2!9!}{12!}$

$\large =\frac{1}{12\cdot 11\cdot 10}$

$\large =\frac{1}{1320}$

Tabular Integration by Parts
Refer to http://www.maa.org/sites/default/files/pdf/mathdl/CMJ/Horowitz307-311.pdf

Comparing coefficients
Refer to https://johnmayhk.wordpress.com/2014/08/08/integration-by-comparing-coefficients/

Laplace transform <=> residue theory

Complex analysis

Friday, 9 January 2015

Integration and statistics

Have you ever wondered why you see many integration problems of the form $\int xf(x)dx$ or $\int (x-\text{a number})^2 f(x)dx$ in your textbook?

Those problems are related to expected value and variance, which are applied in statistics.

Prerequisite knowledge:
For a discrete random variable, the expected value is the sum of all xP(x). For a continuous random variable, P(x) is the probability density function, and integration takes the place of addition.

Definitions:
Let X be an absolutely continuous random variable with probability density function $f_X(x)$.

The expected value of X is:
$E(X)=\int_{-\infty}^{\infty}xf_X(x)dx$

It should fulfill absolute integrability, i.e. $\int_{-\infty}^{\infty}|x|f_X(x)dx<\infty$. This ensures that the improper integral $\int_{-\infty}^{\infty}xf_X(x)dx$, a shorthand for $\lim\limits_{t \to -\infty} \int_t^0 xf_X(x)dx+\lim\limits_{t \to \infty} \int_0^t xf_X(x)dx$, is well-defined. When the absolute integrability condition is not satisfied, the expected value of X does not exist.

Let f(x) be a probability density function on the domain [a,b], then the variance of f(x) is $\int_a^b(x-\mu)^2 f(x)dx$.

Examples

Monday, 5 January 2015

Generating functions in probability

Say we want to find the probability of a family of three children having exactly two boys and one girl.

Conventional methods
1. List out all possibilities
There are $2^3 = 8$ possibilities (because a child can be either boy or girl, and there are three of them): BBB, BBG, BGB, BGG, GBB, GBG, GGB, and GGG.
As a result, the required probability is $\dfrac{3}{8}$.

2. Binomial probability
$$P(X=r)=C^n_r\:p^r (1-p)^{n-r}$$In this case, $r$ is the number of boy(s), $n = 3, p = 1-p = \frac{1}{2}$. $$P(X=2)=C^3_2 (\frac{1}{2})^2 (\frac{1}{2})^1 = \frac{3}{8}$$

Generating function method
This method makes use of properties of combination.
The function $(b+g)^3=b^3+3b^2g+3bg^2+g^3$ demonstrates that there is 1 possibility of having 3 boys, 3 possibilities of having 2 boys and 1 girl (BBG, BGB, GBB), and so on.
$$\text{Required probability}=\dfrac{\text{coefficient of}\: b^2g}{\text{sum of all coefficients}}=\dfrac{3}{8}$$
Example:

Conventional method
7 can only be obtained if we have 2, 2, 3 or 1, 3, 3.

Cases for 2, 2, 3:
2, 2, 3 --> 3*3*1
2, 3, 2 --> 3*1*3
3, 2, 2 --> 1*3*3

Cases for 1, 3, 3:
1, 3, 3 --> 2*1*1
3, 1, 3 --> 1*2*1
3, 3, 1 --> 1*1*2

So probability: $\dfrac{3(3\cdot3 + 2)}{6^3}=\dfrac{11}{72}$

Generating function method
The outcomes of a single die are given by the polynomial
and the outcomes of three dice rolls are given by .
Let .
Number of dice outcomes with a value of $7$ is the coefficient of $x^7$. $$\begin{align}f(x)&=(2x+3x^2+x^3)^3\\
&=\cdots+3(3\cdot 3+2)x^7+\cdots\\
&=\cdots+33x^7+\cdots\end{align}$$
[Here we are essentially doing the same thing as the conventional method, looking for the coefficient of $x^2x^2x^3$ and $xx^3x^3$. This generating function method can be useful to those who doesn't know the convention method.]
So the probability of getting a total of $7$ is $\dfrac{33}{6^3}=\dfrac{11}{72}$.

How to find the right function?
[Disclaimer: The followings are just my interpretations.]
For an event repeated for n times, each time with mutually exclusive outcomes a, b and c, the function will be $(a+b+c)^n$.
The coefficient of a particular term of the function which represents a particular outcome will be the number of possibilities of that outcome. The sum of all the coefficients of the function will be the total number of possibilities. Alternatively, you can find it by referring to the question. For example, for the dice question, we know the total number of possibilities is $6^3$ because we are rolling $3$ dice and there are $6$ possible outcomes in rolling each dice.

Thursday, 1 January 2015

Differential equations

First Order Linear Differential Equations:
1. Separating variables
Example 1:
$\dfrac{dy}{dx}=f(y)\\
\dfrac{dy}{f(y)}=dx\\
\int \dfrac{dy}{f(y)}=\int dx$

Example 2:
$\dfrac{dy}{dx}=\dfrac{1}{f(x)f(y)}\\
f(y)dy=\dfrac{dx}{f(x)}\\
\int f(y)dy=\int \dfrac{dx}{f(x)}$

2. Integrating factors

To solve equations of the form
$a(x)\dfrac{dy}{dx}+b(x)y=c(x)$

i. Express in standard form
$\dfrac{dy}{dx}+p(x)y=q(x)$

ii. Multiply both sides by the integrating factor $e^{\int p(x) dx}$

iii. $\dfrac{d}{dx}(ye^{\int p(x) dx})=q(x)e^{\int p(x) dx}$

iv. $ye^{\int p(x) dx}=\int q(x)e^{\int p(x) dx}+C$

v. Divide both sides by the integrating factor

vi. Use initial conditions to find particular solutions

3. Laplace Transform