13.01.2015 Views

MAS 801 It's a Discreetly Discrete World – Mathematics in Real-life ...

MAS 801 It's a Discreetly Discrete World – Mathematics in Real-life ...

MAS 801 It's a Discreetly Discrete World – Mathematics in Real-life ...

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Lecture 9: 22 October 2008<br />

<strong>MAS</strong> <strong>801</strong><br />

It’s a <strong>Discreetly</strong> <strong>Discrete</strong> <strong>World</strong> –<br />

<strong>Mathematics</strong> <strong>in</strong> <strong>Real</strong>-<strong>life</strong> Applications


Lecture 9: 22 October 2008<br />

Prov<strong>in</strong>g Optimality: Method of Tight Restrictions<br />

• For simple 2-variable LPs, we have seen how the graphical method<br />

can be used to f<strong>in</strong>d the optimal solution rather easily<br />

• To prove that the answer obta<strong>in</strong>ed by the graphical method is actually<br />

optimal, we need more than just draw<strong>in</strong>g diagrams<br />

• For example, we have obta<strong>in</strong>ed (x,y) = (100,100) as the optimal solution<br />

to the LP<br />

maximize z = 1000x + 3000y<br />

subject to x + 2y ≤ 300<br />

x + 5y ≤ 600<br />

x ≥ 0<br />

y ≥ 0<br />

• How do we know (100,100) is really the optimal solution


Lecture 9: 22 October 2008<br />

Prov<strong>in</strong>g Optimality: Method of Tight Restrictions<br />

• What does it take to show that (x,y) is really an optimal solution<br />

• We need to show two th<strong>in</strong>gs:<br />

• That (x,y) is a feasible solution<br />

• No other feasible solution gives a better objective function value<br />

• To show that (x,y) is a feasible solution is easy<br />

• Just plug the values of x and y <strong>in</strong>to the constra<strong>in</strong>ts and show that<br />

they are all satisfied<br />

• To show the second is harder


Lecture 9: 22 October 2008<br />

Prov<strong>in</strong>g Optimality: Method of Tight Restrictions<br />

• The method of tight restrictions tries to comb<strong>in</strong>e the constra<strong>in</strong>ts to<br />

show that the objective function value must be greater than some value<br />

p or less than some value q<br />

• Let’s illustrate this with an example<br />

maximize<br />

z = 1000x + 3000y<br />

subject to x + 2y ≤ 300<br />

x + 5y ≤ 600<br />

x ≥ 0<br />

y ≥ 0<br />

• First note that the po<strong>in</strong>t (100,100) gives an objective function value of<br />

400000<br />

• If we can comb<strong>in</strong>e the constra<strong>in</strong>ts to show that 1000x + 3000y ≤ 400000,<br />

then (100,100) must be optimal


Lecture 9: 22 October 2008<br />

Prov<strong>in</strong>g Optimality: Method of Tight Restrictions<br />

• Let’s multiply the 1st constra<strong>in</strong>t throughout by a nonnegative number a<br />

ax + 2ay ≤ 300a<br />

• Let’s multiply the 2nd constra<strong>in</strong>t throughout by a nonnegative number b<br />

• Add<strong>in</strong>g these two constra<strong>in</strong>ts give<br />

maximize z = 1000x + 3000y<br />

subject to x + 2y ≤ 300<br />

x + 5y ≤ 600<br />

x ≥ 0<br />

y ≥ 0<br />

bx + 5by ≤ 600b<br />

(a+b)x + (2a+5b)y ≤ 300a + 600b<br />

• If we want the left hand side to be 1000x + 3000y we need<br />

a + b = 1000 and 2a + 5b = 3000


Lecture 9: 22 October 2008<br />

Prov<strong>in</strong>g Optimality: Method of Tight Restrictions<br />

• Solv<strong>in</strong>g<br />

a + b = 1000 and 2a + 5b = 3000<br />

gives a = 2000/3 and b = 1000/3<br />

• Hence, plugg<strong>in</strong>g these values <strong>in</strong>to<br />

gives<br />

(a+b)x + (2a+5b)y ≤ 300a + 600b<br />

1000x + 3000y ≤ 400000<br />

• This shows that the objective function value can never exceed 400000<br />

• S<strong>in</strong>ce the po<strong>in</strong>t (100,100) gives an objective function value of 400000<br />

and it is a feasible solution, it must be optimal


Lecture 9: 22 October 2008<br />

Exercise 7<br />

• Us<strong>in</strong>g the method of tight restrictions, show that the solution you<br />

obta<strong>in</strong>ed from Exercise 5 is optimal<br />

m<strong>in</strong>imize<br />

z = -2x + y<br />

subject to -x + y ≥ -1<br />

-x + 2y ≤ 2<br />

x ≥ 0<br />

y ≥ 0


Lecture 9: 22 October 2008<br />

Tight Inequalities<br />

• An <strong>in</strong>equality is tight at a po<strong>in</strong>t P if equality holds at P<br />

• Example<br />

2x + 3y ≤ 6 is tight at the po<strong>in</strong>t (0,2)<br />

Theorem<br />

If the optimal solution of an LP occurs at an extreme po<strong>in</strong>t P, then<br />

optimality can be proved by comb<strong>in</strong><strong>in</strong>g constra<strong>in</strong>ts that are tight at P


The <strong>Mathematics</strong> of<br />

Lecture 9: 22 October 2008


Lecture 9: 22 October 2008<br />

The Web Graph<br />

• Primary focus is mathematics surround<strong>in</strong>g a real-world network called<br />

the web graph - denoted W<br />

• vertices of W represent web pages<br />

• edges of W represent the l<strong>in</strong>ks between pages<br />

• The terms “Internet” and “<strong>World</strong> Wide Web” are often treated as<br />

synonymous, but they are actually different<br />

• Internet is a vast network of smaller <strong>in</strong>terconnected networks,<br />

exchang<strong>in</strong>g data by certa<strong>in</strong> protocols<br />

• The <strong>World</strong> Wide Web consists of <strong>in</strong>formation stored and available<br />

on the Internet<br />

• Most of these <strong>in</strong>formation are web pages <strong>in</strong> the form of HTML<br />

documents identified with str<strong>in</strong>gs called universal resource<br />

locators (URL)<br />

• HTML documents are jo<strong>in</strong>ed by l<strong>in</strong>ks, represented as arcs <strong>in</strong> W


Lecture 9: 22 October 2008<br />

How Big is the Web (Graph)<br />

• Even a casual surf will conv<strong>in</strong>ce you that the Web is huge!<br />

• Rapid growth<br />

• 1997: 320 million web pages<br />

• 1999: 800 million web pages<br />

• 2005: 53.7 billion web pages (34.7 billion <strong>in</strong>dexed by Google)


How Big is the Web (Graph)<br />

Lecture 9: 22 October 2008


How Big is the Web (Graph)<br />

Lecture 9: 22 October 2008


Lecture 9: 22 October 2008<br />

Search<strong>in</strong>g the Web<br />

• We have seen the web conta<strong>in</strong>s a huge amount of <strong>in</strong>formation<br />

• Travers<strong>in</strong>g the web unaided would be difficult if not impossible<br />

• Search eng<strong>in</strong>es are an <strong>in</strong>valuable tool<br />

• Modern search eng<strong>in</strong>es exploit the graph structure of the web<br />

• L<strong>in</strong>k analysis


Lecture 9: 22 October 2008<br />

Overview of Search Eng<strong>in</strong>es<br />

• How does a search eng<strong>in</strong>e work<br />

• A search eng<strong>in</strong>e conta<strong>in</strong>s the follow<strong>in</strong>g components<br />

• Crawler<br />

• Indexer<br />

• Query eng<strong>in</strong>e


Lecture 9: 22 October 2008<br />

Crawler<br />

• Program that browses WWW <strong>in</strong> a methodical, automated fashion<br />

• The process is called crawl<strong>in</strong>g or spider<strong>in</strong>g<br />

• downloads a copy of all the visited pages for later use by an <strong>in</strong>dexer<br />

• Characteristics of WWW that makes crawl<strong>in</strong>g difficult<br />

• WWW has large volume<br />

• can only download a fraction of the web pages <strong>in</strong> a given time;<br />

need to prioritize which page to download<br />

• WWW has fast rate of change<br />

• by the time the pages of a site are downloaded, new pages may<br />

have been added, or content of pages may have changed<br />

• Behaviour of a crawler is governed by its policies<br />

• Selection policy: which page to download<br />

• Revisit policy: when to check for changes


Lecture 9: 22 October 2008<br />

Indexer<br />

• The <strong>in</strong>dexer builds an <strong>in</strong>dex from the downloaded web pages<br />

• The <strong>in</strong>dex conta<strong>in</strong>s keywords and key phrases that po<strong>in</strong>ts back to the<br />

web pages conta<strong>in</strong><strong>in</strong>g them


Lecture 9: 22 October 2008<br />

Query Eng<strong>in</strong>e<br />

• When given <strong>in</strong>put keywords or key phrases, responds <strong>in</strong> realtime with<br />

relevant web pages conta<strong>in</strong><strong>in</strong>g keywords or key phrases<br />

• As part of the query eng<strong>in</strong>e, a rank<strong>in</strong>g algorithm attempts to rank web<br />

pages <strong>in</strong> order of their relevance to the query


Lecture 9: 22 October 2008<br />

Rank<strong>in</strong>g Algorithm<br />

• Early search eng<strong>in</strong>es rank web pages accord<strong>in</strong>g to the number of query<br />

keywords and/or key phrases they conta<strong>in</strong><br />

• This is susceptible to keyword spamm<strong>in</strong>g<br />

• A bookstore who wants to attract people to its website will just<br />

create one that conta<strong>in</strong>s lots of the word “book”<br />

• Modern search eng<strong>in</strong>es analyzes the l<strong>in</strong>ks <strong>in</strong> W to rank a page<br />

• Most famous of this is the PageRank algorithm of Google, <strong>in</strong>vented<br />

by Larry Page and Sergey Br<strong>in</strong> <strong>in</strong> 1998


Lecture 9: 22 October 2008<br />

PageRank<br />

• Assigns a rank to every web page<br />

• Influences the order <strong>in</strong> which Google displays search results<br />

• Based on l<strong>in</strong>k structure of W<br />

• Does not depend on content of web pages<br />

• Does not depend on query<br />

• Higher PageRank = more visitors


Lecture 9: 22 October 2008<br />

PageRank<br />

• L<strong>in</strong>ks are the currency of the web<br />

• Exchang<strong>in</strong>g and buy<strong>in</strong>g of l<strong>in</strong>ks<br />

• Backl<strong>in</strong>k obsession


Lecture 9: 22 October 2008<br />

PageRank: First Try<br />

• We want to assign an “importance” to every web page<br />

• Let xi be the importance of web page i<br />

• We can just measure the importance of a web page by the number of<br />

web pages that l<strong>in</strong>ks to it<br />

• Example<br />

2 3 4<br />

• x1 = 3<br />

1<br />

• Given the web graph W, how do we compute the importance of each<br />

node <strong>in</strong> W


Lecture 9: 22 October 2008<br />

Adjacency Matrix of a Digraph<br />

Adjacency Matrix<br />

• Given a digraph G with n vertices, its adjacency matrix is the n x n<br />

matrix A whose entry <strong>in</strong> row i and column j is given by<br />

aij =<br />

{ 1,<br />

if (i, j) is an arc of G<br />

0, otherwise


Lecture 9: 22 October 2008<br />

Adjacency Matrix of a Digraph<br />

• Example<br />

2 3 4<br />

• Adjacency matrix of the graph above is<br />

1<br />

( )<br />

0 0 0 0<br />

1 0 0 0<br />

1 0 0 0<br />

1 0 0 0


Lecture 9: 22 October 2008<br />

Exercise 1<br />

• What is the adjacency matrix of the digraph below<br />

2 3 4<br />

1


Lecture 9: 22 October 2008<br />

Matrix Transpose<br />

Matrix Transpose<br />

• Given a matrix A, its transpose A T is the matrix created by writ<strong>in</strong>g the<br />

rows of A as the columns of A T .<br />

• Example


Lecture 9: 22 October 2008<br />

PageRank: First Try<br />

• Let A be the adjacency matrix of the web graph W<br />

• What is the sum of entries <strong>in</strong> the i-th row of A T <br />

• The number of nodes po<strong>in</strong>t<strong>in</strong>g to node i<br />

• This is precisely the importance of node (web page) i<br />

• Comput<strong>in</strong>g the importance of every node is just comput<strong>in</strong>g<br />

x = A T J<br />

where J is the vector of all 1’s


Lecture 9: 22 October 2008<br />

Exercise 2<br />

• Compute the importance of all the nodes for the “web graph” below<br />

2 3 4<br />

1


Lecture 9: 22 October 2008<br />

Exercise 2: Answer<br />

2 3 4<br />

)<br />

1 0 0 0<br />

• The adjacency matrix for the graph is A =<br />

0 0 0 0 (1<br />

(<br />

0 1 0 1<br />

)<br />

0 1 0<br />

0 0 0 0<br />

( ( ) )<br />

1<br />

• The transpose of A is A T =<br />

• A T J =<br />

0 1 0 1<br />

0 0 0 0<br />

1 0 0 1<br />

0 0 0 0<br />

)<br />

1<br />

1<br />

1<br />

1<br />

0 0 0 0<br />

1 0 0 1<br />

=<br />

(2<br />

0<br />

2<br />

0<br />

0 0 1 0<br />

• Importance of<br />

• node 1 = 2<br />

• node 2 = 0<br />

• node 3 = 2<br />

• node 4 = 0


Lecture 9: 22 October 2008<br />

PageRank: An Improvement<br />

• The previous def<strong>in</strong>ition of “importance” of a web page suffers from a<br />

problem<br />

• Can you see what it is<br />

• To be <strong>in</strong>cluded <strong>in</strong> a short list should mean more than be<strong>in</strong>g <strong>in</strong>cluded<br />

<strong>in</strong> a long list<br />

• Suggests that a l<strong>in</strong>k from i to j should be weighted by the number of<br />

pages l<strong>in</strong>ked to by i<br />

• Importance of a node i is the sum of the weights of the l<strong>in</strong>ks to i


Lecture 9: 22 October 2008<br />

Markov Matrix of a Digraph<br />

Markov Matrix<br />

• Given a digraph G with n vertices, its Markov matrix is the n x n matrix<br />

M whose entry <strong>in</strong> row i and column j is given by<br />

mij =<br />

{ 1/d i, if (i, j) is an arc of G, and di is the outdegree of i<br />

0, otherwise


Lecture 9: 22 October 2008<br />

Markov Matrix of a Digraph<br />

• Example<br />

2 3 4<br />

• Markov matrix of the graph above is<br />

1<br />

( )<br />

0 0 1 0<br />

1 0 0 0<br />

0 0 0 0<br />

1/2 0 1/2 0


Lecture 9: 22 October 2008<br />

Exercise 3<br />

• What is the Markov matrix of the digraph below<br />

1 2<br />

3<br />

4 5<br />

6


Lecture 9: 22 October 2008<br />

Exercise 3: Answer<br />

1 2<br />

3<br />

4 5<br />

6<br />

• The Markov matrix is P =<br />

0 1/3 1/3 1/3 0 0<br />

1/2 0 1/2 0 0 0<br />

1/4 1/4 0 1/4 1/4 0<br />

1/3 0 0 0 1/3 1/3<br />

0 1/3 0 1/3 0 1/3<br />

0 0 0 0 0 0


Lecture 9: 22 October 2008<br />

PageRank: An Improvement<br />

• Let P be the Markov matrix of the web graph W<br />

• What is the sum of entries <strong>in</strong> the i-th row of P T <br />

• The sum of weights of l<strong>in</strong>ks po<strong>in</strong>t<strong>in</strong>g to node i<br />

• This is precisely the importance of node (web page) i<br />

• Comput<strong>in</strong>g the importance of every node is just comput<strong>in</strong>g<br />

x = P T J<br />

where J is the vector of all 1’s


Lecture 9: 22 October 2008<br />

Exercise 4<br />

• Compute the importance of all the nodes <strong>in</strong> the “web graph”<br />

1 2<br />

3<br />

4 5<br />

6


Lecture 9: 22 October 2008<br />

Exercise 4: Answer<br />

1 2<br />

3<br />

4 5<br />

0 1/3 1/3 1/3 0 0<br />

T<br />

1<br />

6<br />

0 1/2 1/4 1/3 0 0<br />

1<br />

13/12<br />

1/2 0 1/2 0 0 0<br />

1<br />

1/3 0 1/4 0 1/3 0<br />

1<br />

11/12<br />

1/4 1/4 0 1/4 1/4 0<br />

1/3 0 0 0 1/3 1/3<br />

1<br />

1<br />

=<br />

1/3 1/2 0 0 0 0<br />

1/3 0 1/4 0 1/3 0<br />

1<br />

1<br />

=<br />

10/12<br />

11/12<br />

0 1/3 0 1/3 0 1/3<br />

1<br />

0 0 1/4 1/3 0 0<br />

1<br />

7/12<br />

0 0 0 0 0 0<br />

1<br />

0 0 0 1/3 1/3 0<br />

1<br />

8/12


Lecture 9: 22 October 2008<br />

PageRank: An Improvement<br />

• The previous def<strong>in</strong>ition of “importance” of a web page still suffers from<br />

a problem<br />

• Can you see what it is<br />

• Many fictitious web pages can be created to l<strong>in</strong>k to a web page i if<br />

we want to make web page i important (l<strong>in</strong>k spamm<strong>in</strong>g)<br />

• Suggests that a l<strong>in</strong>k from i to j should also be weighted by the<br />

importance of the web page i<br />

• Previously the weight of a l<strong>in</strong>k from i to j is given by<br />

1/di (di is the outdegree of node i)<br />

• We now modify this so that the weight of a l<strong>in</strong>k from i to j is give by<br />

xi/di (di is the outdegree of node i)<br />

• where xi is the importance of node i


Lecture 9: 22 October 2008<br />

PageRank: An Improvement<br />

• We seem to be runn<strong>in</strong>g <strong>in</strong>to a circular problem here<br />

• To determ<strong>in</strong>e the importance of a web page, we need to know the<br />

importance of other web pages<br />

• Where do we start<br />

• L<strong>in</strong>ear algebra to the rescue!


Lecture 9: 22 October 2008<br />

Some L<strong>in</strong>ear Algebra<br />

• Given an n x n matrix A, we can f<strong>in</strong>d nonzero vectors x such that<br />

• Ax = λx<br />

• x is called an eigenvector of A<br />

• λ is called an eigenvalue of A<br />

• To tie x and λ together, we say that x is the eigenvector correspond<strong>in</strong>g<br />

to λ<br />

• Example<br />

A x λ x<br />

3 1<br />

1 3<br />

1<br />

1<br />

4<br />

= = 4<br />

4<br />

1<br />

1<br />

• 4 is an eigenvalue of A and is an eigenvector correspond<strong>in</strong>g to 4<br />

1<br />

1


Lecture 9: 22 October 2008<br />

Eigenvalues & Eigenvectors<br />

• How can we f<strong>in</strong>d the eigenvalues and eigenvectors of a given n x n<br />

matrix A<br />

• We want to f<strong>in</strong>d λ and x such that Ax = λx<br />

• This can be rewritten as Ax - λx = 0 or (A - λI)x = 0<br />

• Turns out that λ is an eigenvalue of A if and only if<br />

det(A - λI) = 0<br />

The above equation is called the characteristic equation of A<br />

Example<br />

• If A = 3 1 , then det(A - λI) = 3-λ 1 = (3 - λ) 2 - 1 = λ 2 - 6λ + 8<br />

1 3<br />

1 3-λ<br />

• Solv<strong>in</strong>g the quadratic equation λ 2 - 6λ + 8 = 0 gives λ = 2 and λ = 4<br />

• The eigenvalues of A are therefore 2 and 4


Lecture 9: 22 October 2008<br />

Exercise 5<br />

• F<strong>in</strong>d the eigenvalues of the 3 x 3 matrix B =<br />

0 -1 -1<br />

1 2 1<br />

1 1 2


Lecture 9: 22 October 2008<br />

Eigenvalues & Eigenvectors<br />

• How do we f<strong>in</strong>d eigenvectors correspond<strong>in</strong>g to eigenvalues<br />

• This is more difficult than f<strong>in</strong>d<strong>in</strong>g eigenvalues<br />

• Eigenvectors are not unique<br />

• For A = 3 1 , any vector of the form k (k ≠ 0) is an<br />

1 3<br />

k<br />

eigenvector correspond<strong>in</strong>g to the eigenvalue 4<br />

• Check!<br />

• If x is an eigenvector of A, so is kx for every k ≠ 0<br />

• To f<strong>in</strong>d eigenvectors, we must solve systems of l<strong>in</strong>ear equations


Lecture 9: 22 October 2008<br />

Example<br />

• F<strong>in</strong>d all the eigenvectors of A =<br />

3 1<br />

1 3<br />

• We know the eigenvalues are 2 and 4<br />

• Let’s first try to f<strong>in</strong>d the eigenvectors correspond<strong>in</strong>g to eigenvalue 2<br />

• We have to f<strong>in</strong>d x such that Ax = 2x<br />

3 1<br />

1 3<br />

x1<br />

x2<br />

=<br />

2x1<br />

2x2<br />

<br />

3x1 + x2<br />

x1 + 3x2<br />

=<br />

2x1<br />

2x2<br />

• We get x1 + x2 = 0; if we let x1 = k then x2 = -k<br />

• The eigenvectors are given by k , where k ≠ 0<br />

-k


Lecture 9: 22 October 2008<br />

Exercise 6<br />

• F<strong>in</strong>d the eigenvectors of the 3 x 3 matrix B =<br />

0 -1 -1<br />

1 2 1<br />

1 1 2


Lecture 9: 22 October 2008<br />

Further Properties of Matrices<br />

• Let A be an m x n matrix and let B be an n x k matrix. Then<br />

(AB) T = B T A T<br />

• If A is an n x n matrix, then<br />

det(A T ) = det(A)<br />

• If A is an n x n matrix, then A and A T have the same eigenvalues

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!