Final_1.pdf

(Tuis.) #1

Calculating the Cosine of the Angle between
Two Vectors


It is useful at this point to define the inner product of two vectors. Given two
vectorseAandeBas follows:


(6.14)


The inner product between the two vectors is given by the formula


(6.15)

In matrix notation, the inner product may be represented as , where
is the transpose of the vector. The length of a vector is the square root of its
inner product. Therefore, we have


(6.16)


With the preceding equations, we are now ready to calculate the angle be-
tween two vectors. The steps involved in calculating the angle between two
vectors are as follows.


Step 1. We first evaluate the unit vectors (vectors of length one) pointing
in the direction of the two vectors. We do this by scaling each
element of the vector by its length.
Step 2. The cosine of the angle between the two vectors is now the inner
product of the unit vectors pointing in their directions.
We will leave it to the reader to work out that the two steps
may be condensed into a single formula as given in Equation 6.17.


(6.17)


Example


Let us say we are required to calculate the cosine of the angle between the
vectorsA= (0, 2) and B= (3, 0). Calculating the lengths of these vectors, we
have


cosθ=
()()

ee

ee ee

AB

T

AA

T
BB

T

length()eeeAAA= T

eeABT eBT

eeAB=++...+ee 11 AB ee 22 AB e eAN NB

eee e

eee e

A

AA
N

A

B

BB
N

B

=...()


=...()


12

12

,,,


,,,


Pairs Selection in Equity Markets 95

Free download pdf