Saturday, 24 January 2015

Thursday, 22 January 2015

Use of vectors

Prove trigonometry identities
Sine formula $\LARGE \frac{a}{\sin\alpha}=\frac{b}{\sin\beta}=\frac{c}{\sin\gamma}$
$\vec{A}+\vec{B}+\vec{C}=\vec{0}\\
\begin{align}0&=\vec{A}\times (\vec{A}+\vec{B}+\vec{C})\\
&=\vec{A}\times\vec{B}+\vec{A}\times\vec{C}\\
\vec{B}\times\vec{A}&=\vec{A}\times\vec{C}\\
ba \sin\gamma&=ac \sin\beta\\
\frac{b}{\sin\beta}&=\frac{c}{\sin\gamma}\\
\end{align}$
Similarly, expand $\vec{B}\times (\vec{A}+\vec{B}+\vec{C})$, we have $\Large \frac{a}{\sin\alpha}=\frac{c}{\sin\gamma}$ $\Box$

Cosine formula $a^2+b^2-c^2=2ab\cos\gamma$
$\begin{align}c^2&=\vec{c}\cdot\vec{c}\\
&=(\vec{a}+\vec{b})\cdot(\vec{a}+\vec{b})\\
&=\vec{a}\cdot\vec{a}+2\vec{a}\cdot\vec{b}+\vec{b}\cdot\vec{b}\\
&=a^2+2ab\cos(\pi-\gamma)+b^2\\
&=a^2-2ab\cos\gamma+b^2\:\:\Box
\end{align}$

Prove inequalities

$\sqrt{a^2+(1-b)^2}+\sqrt{b^2+(1-c)^2}+\sqrt{c^2+(1-a)^2}\geq \dfrac{3}{\sqrt{2}}$
Proof: Let $\vec{x}=\small\begin{pmatrix}a \\ 1-b\end{pmatrix}$, $\vec{y}=\small\begin{pmatrix}b \\ 1-c\end{pmatrix}$,$\vec{z}=\small\begin{pmatrix}c \\ 1-a\end{pmatrix}$.
By Minowski's inequality, $|\vec{x}|+|\vec{y}|+|\vec{z}| \geq |\vec{x}+\vec{y}+\vec{z}|$.
$\begin{align}\sqrt{a^2+(1-b)^2}+\sqrt{b^2+(1-c)^2}+\sqrt{c^2+(1-a)^2}&\geq \sqrt{(a+b+c)^2-[3(a+b+c)]^2}\\&=\sqrt{2(a+b+c-\dfrac{3}{2})^2+\dfrac{9}{2}}\\&\geq \dfrac{3}{\sqrt{2}}\:\Box \end{align}$

$\sqrt{x^2+1}+\sqrt{y^2+1}+\sqrt{z^2+1}\geq \sqrt{6(x+y+z)}\quad x,y,z>0$
Proof: Let $\vec{a}=\small\begin{pmatrix}x \\ 1\end{pmatrix}$, $\vec{b}=\small\begin{pmatrix}y \\ 1\end{pmatrix}$,$\vec{b}=\small\begin{pmatrix}z \\ 1\end{pmatrix}$.
$\begin{align}|\vec{a}|+|\vec{b}|+|\vec{c}| &\geq |\vec{a}+\vec{b}+\vec{c}| \\
\iff \sqrt{x^2+1}+\sqrt{y^2+1}+\sqrt{z^2+1}&\geq \sqrt{(x+y+z)^2+3^2}\\
&\geq \sqrt{6(x+y+z)}\:\Box\end{align}$

Tuesday, 20 January 2015

Application of linear algebra: searching database

Basic idea:
$\large \cos\theta=\frac{|\vec{a} \cdot \vec{b}|}{|\vec{a}||\vec{b}|}=\vec{x}^T\vec{y}$
$\vec{x},\vec{y}$: unit vectors of $\vec{a}$ and $\vec{b}$ respectively
$\theta$: angle between $\vec{x}$ and $\vec{y}$.

database matrix: $\large \vec{x}=\frac{\vec{a}}{|\vec{a}|}$
search vector: $\large \vec{y}=\frac{\vec{b}}{|\vec{b}|}$

If $\cos\theta = 0$, $\theta=90^\circ$, the document does not contain any of the search words and the corresponding column vector of the database matrix is orthogonal to the search vector.

If $\cos\theta$ is close to $1$, $\theta \sim 0$, the data corresponding to that vector best matches our search criteria.

More to explore:
Latent Semantic Indexing (LSI)
Singular value decomposition
Covariance
Least squares problem

Monday, 19 January 2015

Cross Product and Lagrange's Identity

$\begin{align}|x \times y|^2&=\begin{vmatrix}x\cdot x&x\cdot y\\x\cdot y & y\cdot y \end{vmatrix}\\&=|x|^2|y|^2-(x\cdot y)^2\\
&=|x|^2|y|^2(1-\cos^2 \theta)\\
&=|x|^2|y|^2\sin^2 \theta\end{align}$

Proof of $|x \times y|^2=|x|^2|y|^2-(x\cdot y)^2$ (Lagrange's Identity):

$\large{\begin{align}RHS
&=\sum_{i=1}^n {x_i}^2 \sum_{i=1}^n {y_i}^2-(\sum_{i=1}^n {x_i y_i})^2\\
&=\sum_{i=1}^n {x_i}^2 \sum_{j=1}^n {y_j}^2-\sum_{i=1}^n {x_i y_i}\sum_{j=1}^n {x_j y_j}\\
&=\sum_{i,j=1}^n {x_i}^2 {y_j}^2-\sum_{i,j=1}^n {x_i y_i x_j y_j}\\
&=\sum_{i<j} {x_i}^2{y_j}^2+\sum_{i=1}^n {x_i}^2 {y_i}^2+\sum_{i>j} {x_i}^2{y_j}^2\\
& -\sum_{i<j} x_i y_i x_j y_j- \sum_{i=1}^n{x_i}^2{y_i}^2-\sum_{i>j} x_i y_i x_j y_j\\
&=\sum_{i<j} {x_i}^2 {y_j}^2+\sum_{i<j} {x_j}^2 {y_i}^2-2\sum_{i<j} x_i y_i x_j y_j\\
&=\sum_{i<j} ({x_i}^2{y_j}^2-2x_i y_i x_j y_j+{x_j}^2{y_i}^2)\\
&=\sum_{i<j} (x_i y_j-x_j y_i)^2\\
&=LHS \end{align}}$

Computations with cross products:

Area of triangle in space
Let $u,v,w$ be vertices of a triangle. Treat them as arrows from the origin. Then, two sides of the triangle can be given by $v-u$ and $w-u$. Thus, the area of the triangle is $\frac{1}{2}|(v-u)\times (w-u)|$.
By the bilinearity of cross products, $(\boldsymbol{v-u})\times (\boldsymbol{w-u})=v\times w-u\times w-v\times u+u\times u$.
By antisymmetry, $u\times u=0$.
Therefore, the area of the triangle is given by $\frac{1}{2}|v\times w+w\times u+u\times v|$. Note the cyclic pattern.

Remark: We can make use of this result to prove the three dimensional Pythagorean theorem. Consider the tetrahedron with vertices $A=(a,0,0)$, $B=(0,b,0)$, $C=(0,0,c)$ and $O=(0,0,0)$. For any three points $X,Y,Z$ in space, write $[X,Y,Z]$ for the area of the triangle with vertices $X,Y,Z$. Then, the three dimensional Pythagorean theorem states that $[ABC]^2=[OAB]^2+[OBC]^2+[OCA]^2$.

Equation of the plane spanned by two vectors (skipped)

Intersection of two planes
Say we have two non-parallel planes $ax+by+cz=0$ and $a'x+b'y+c'z=0$. They have normal vectors $n=(a,b,c)$ and $n’=(a',b',c')$ respectively. The vector $n \times n’$ is perpendicular to both $n$ and $n’$, so it lies on both planes. The line of intersection of the planes is therefore the line through $n \times n’$.

References:
http://www.owlnet.rice.edu/~fjones/chap7.pdf
https://www2.bc.edu/~reederma/Linalg13.pdf

Useful:
http://www.odeion.org/pythagoras/pythag3d.html
http://www.netcomuk.co.uk/~jenolive/homevec.html

Sunday, 18 January 2015

Interesting Graphs: Conics

Conic sections: intersection curves of a plane and a right circular conical surface



The four conic sections (hyperbola, parabola, ellipse, circle) are produced when the plane does NOT pass through the vertex. When the plane passes through the vertex, degenerate conics (two intersecting lines, a line, a point) will be produced.

Conics are generally given by a second degree equation: $Ax^2+Bxy+Cy^2+Dx+Ey+F=0$
$Δ>0$ hyperbola, pair of intersecting lines
$Δ<0$ ellipse, circle, point or no graph
$Δ=0$ parabola, line, pair of parallel lines or no graph

Demonstration:


Green: Hyperbola $Δ=5^2-4(2)(2)=9>0$
Orange: Ellipse $Δ=1^2-4(2)(2)=-15<0$
Blue: Circle $Δ=0^2-4(2)(2)=-16<0$
Purple: Parabola $Δ=4^2-4(2)(2)=0$

 

Hyperbola: the set of points in a plane whose distances from two fixed points (foci) in the plane have a constant difference.
Implicit form: $\dfrac{(x-h)^2}{a^2}-\dfrac{(y-k)^2}{b^2}=1$
Parametric form: $x=h+a\sec\theta$, $y=k+b\tan\theta$

 

Ellipse: the set of all points in a plane whose distances from two fixed points (foci) in the plane have a constant sum.
Implicit form: $\dfrac{(x-h)^2}{a^2}+\dfrac{(y-k)^2}{b^2}=1$
Parametric form: $x=h+a\cos\theta$, $y=k+b\sin\theta$

Ellipses and hyperbolas are called central conics because they have a centre of symmetry, while parabolas are non-central. For both ellipses and hyperbolas, a and b are the axis lengths. The larger one of a and b is the major axis while the smaller one is the minor axis.

Circle:
Implicit form: $(x-h)^2+(y-k)^2=r^2$
Parametric form: $x=h+r\cos\theta$, $y=k+r\sin\theta$

 

Parabola:
Implicit form: $x^2=4py$
Parametric form: $x=t$, $y=\dfrac{t^2}{4p}$

How to distinguish between non-degenerate and degenerate conics?
[pending]

Conics in matrix form
Each point $\vec{x}=(x,y)$ is considered to be a column vector with 1 as its third component, i.e. $\vec{x}=\begin{pmatrix} x\\y\\1\end{pmatrix}$ and $\vec{x}^T= (x, y, 1)$. The six coefficients of the general second degree polynomial are then used to construct a 3x3 symmetric matrix as follows: $\vec{Q}=\begin{pmatrix} A&B&D\\B&C&E\\D&E&F\end{pmatrix}$
$\vec{x}^T\vec{Q}\vec{x}=\vec{0}$

Application:
Although conics and quadric surfaces existed around 2000 years ago, they are still the most popular objects in many computer aided design and modeling systems.