Upload
gamble19844891
View
232
Download
0
Embed Size (px)
Citation preview
8/2/2019 Lec2b [Compatibility Mode]
1/37
SET THEORY Set: It is an unordered collection of distinct
.
Finite Set: A set is finite if it contains a finite
A = {1, 3, 5, 7, 9, 11, 15, 17, 19}
infinite number of elements
B = 0 1 2 3 4 .
Empty Set: A set is empty if it contain noelements
= { }
8/2/2019 Lec2b [Compatibility Mode]
2/37
If X is a set:
x X x belon s to Xx X x does not belong to X{ x x N and x is odd } The set of all x such that x belongs to N
Subset: If every element of A is also an element of BA B
Proper Subset: A is proper subset of B if:
(i) A is subset of B.
A B
Improper Subset: A is an improper subset of B if:-
(i) A is a subset of B
(ii) There does not exist any element in B which does not belongto A.
Every set is an improper subset of itself
8/2/2019 Lec2b [Compatibility Mode]
3/37
Equal Sets: A and B are equal sets if:-
or
Union of X & Y:=
Intersection of X & Y:
Difference of sets:
=
Cartesian Product:
= ,
8/2/2019 Lec2b [Compatibility Mode]
4/37
INTEGERS, REALS AND INTERVALS Integers:
Set of integers : Z = { 0, 1, 2, 3, 4, .}Set of natural integers : N = { 0,1, 2, 3, 4, }
Set of positive integers : N+ = { 1, 2, 3, 4, }
Set of ne ative inte ers : N- = { -1, -2, -3, -4, }
Real Numbers:
Set of positive real numbers: R+ = { x R x > 0 }-v u : = x x n ]
For every natural number, there exists anothernatural number (m) greater than (n).
( m N) ( n N ) [ m > n ]
There is an integer m that is larger that everynatura num er nc u ng m tse .
It is obviously false
the order in which the quantifiers are presented isimportant.
8/2/2019 Lec2b [Compatibility Mode]
14/37
Sums and ProductsSums )2()1()( +++= f(n).....ffif
n
Sum of the values taken b on the first n ositive inte ers
1=i
i = 1
)(ifn
P(i)
Sum of the values taken by f on those integers between 1 and nfor which ro ert P holds.
If n = 10 and P(i) is odd
10
i = 1 P(i) is odd
2597531 =++++= i
8/2/2019 Lec2b [Compatibility Mode]
15/37
Productsn
(i) = (1) x (2) x (3) x .. x (n)
Product of (i) as i goes from 1 to n.If n = 0, the product is defined to be one.
Miscellaneous Notations
Logbx=y Where b1 and x are +ve realy = x
log10 1000 = 3 or 103 = 1000
numbers (b&x must be +ve)
natural logarithm (ln)
Loga(xy) = logax + logay
oga x y = ogax ogay
Logaxy = ylog
ax
a
xx
b
ba
log
loglog =
8/2/2019 Lec2b [Compatibility Mode]
16/37
729log729log)( 39 =i
4log
16log16log)(
2
24 =ii
xy bb
yx
loglog
=
Floor of x: If x is a real number, [x] denotes the
largest integer that is not larger than x.
3
2
13
=
=
x
x
2
13=x
77,95.8,25,3]14.3[
4
====
=
Floor
x
8/2/2019 Lec2b [Compatibility Mode]
17/37
Ceiling of x: If x is a real number, [x] denotesthe smallest integer that is not smaller than x.
213=x
13
4
=
=
x
x
77,85.8,35,4]14.3[
3
====
=
Ceilin
x
8/2/2019 Lec2b [Compatibility Mode]
18/37
Algorithm to Find a New Prime Number
uc e o
Function NewPrime (P : set of integers)-
primes}
x Product of the elements in Py x + 1d 1Repeat d d+1 until d divides yreturn d
8/2/2019 Lec2b [Compatibility Mode]
19/37
Another Algorithm to Find a New
r me um er
Function DumpEuclid (P : set of integers)-
primes}
x The lar est element in Prepeat x x + 1 until x is primereturn x
8/2/2019 Lec2b [Compatibility Mode]
20/37
PROOF
(1) Proof by contradiction
y
It is also known as indirect proof.eorem : There exist two irrational numbers x
and y such that xy is rational.
, =we know 2 is a irrational number
2
2=zLet
8/2/2019 Lec2b [Compatibility Mode]
21/37
By our assumption z is irrational
2zwLet =
s aga n rrat ona y our assumpt on
but
( )22 2222 =
==
zw
( ) 22 2 ==Here conclusion says that 2 is irrational which is false.
Thus, our assumption was false. So it is possible to
an irrational power. It is a proof by contradiction and isavoided in the context of algorithmics.
8/2/2019 Lec2b [Compatibility Mode]
22/37
Proof By Mathematical Induction(Very useful tool in algorithmics)
Induction Approach: inferring of general law from.
Deduction Approach: an inference from general toparticular (always valid if it is applied properly)
Induction Approach
(i) Eulers Conjecture (1769)
=
Enuler conjectured that this equation can never besatisfied.
Frye (after two centuries) using computing machines forhundreds of hours found that:
4+ 4+ 4= 4 ( -
8/2/2019 Lec2b [Compatibility Mode]
23/37
Proof By Mathematical Induction
(ii) Polynomial p(n) = n2 + n +41
+ 1 + 2 + + 4 + +
+p(7) + p(8) + p(9) + p(10) = 41, 43, 47, 53, 61,71, 83, 97, 113, 131 and 151.
It is natural to infer by induction that p(n) is
prime for all integer values of n. But p(40) = 1681 = 412 so induction has gone
wrong.
8/2/2019 Lec2b [Compatibility Mode]
24/37
(i) Sum of the cubes of the first n positive
integers is always a perfect square.13 = 1 = 12
13+23 = 9 = 32
13+23+33+43 = 100 = 102
13+23+33+43+53 = 225 = 152
8/2/2019 Lec2b [Compatibility Mode]
25/37
(ii) Algorithm for Mathematical Induction
function sq (n)
if n=0 then return 0
else return 2n + sq(n-1)-1
Check:
sq = , sq = + - =
sq(2)=4+1-1=4, sq(3)=6+4-1=9
= + - =
Proof:
= - -sq(n)=2n+n2-2n+1-12-
sq(n)=n2
8/2/2019 Lec2b [Compatibility Mode]
26/37
Tilin Pr l m m squares in each row and column where m
1 square is distinguished as special square.t s not covere y any t e.
1 tile takes 3 squares 2 x 2 board is formed
8/2/2019 Lec2b [Compatibility Mode]
27/37
The tiling problem
(a) Board with special square (c) One tile
(c) Placing the first tile (d) solution
8/2/2019 Lec2b [Compatibility Mode]
28/37
Proof by Mathematical Indirection
m = 2n where n is an integer
if n=0m=20=11x1 board1 square is special
Board is tiled by doing nothingif n=1
m=21=22x2 board
square s spec aBoard is tiled by putting 1 tile
8/2/2019 Lec2b [Compatibility Mode]
29/37
(ii) Induction Step
ons er nm = 2n
According to induction hypothesis theorem is true for2n-1 x 2n-1 boards
Suppose a m x m board containing one special square
Place the tile in the middle of the original board so to cover 1
square of three sub-boards. These three squares are also.
By induction hypothesis, each of these sub-boards can betiled
Thus theorem is for m=2 , and since its truth for m=2n
followsfrom its assumed truth for m=2n-1 for all n 1, it follows fromthe principle of mathematical induction that the theorem istrue or a m prov e m s a power o .
A suitable algorithm can be obtained to solve tiling problem.
8/2/2019 Lec2b [Compatibility Mode]
30/37
Construction Induction It can also be used to prove the truth of a partially
specified assertion and discover the missing
This technique can be illustrated featuring the Fibonaccise uence 12th centur , Italian mathematician .
Every month a breeding pair of rabbits produce a pair of
offspring. The offspring will in their turn start breeding after two
months and so on.Month-4
1
1
Month-2Month-1
Month-31
1
1
1
11 1 1
(2 pairs)(1 pair) (3 pairs)(5 pairs) and so on
8/2/2019 Lec2b [Compatibility Mode]
31/37
Format definition
=
2;0 2110 >=+=== noran nnn
, , , , , , , , , , , , ..
Constructive induction can be useful in the analysis of algorithms.
gor m or compu ng e onaccfunction Fibonacci (n)
if n
8/2/2019 Lec2b [Compatibility Mode]
32/37
Elementary Probability It is concerned with the study of random phenomena
whose future is not predictable with certainty.
xamp e
(i) Throwing of a dice
point in a given period of time
(iii) Measuring the response time of a computersystem
The set of all possible outcomes of a random experiment is
The individual outcomes are called sample points orelementary events.
8/2/2019 Lec2b [Compatibility Mode]
33/37
Possible outcomes of throwing an ordinary dice=6, namely1 to 6.
Sample space = S = {1, 2, 3, 4, 5, 6,} for throwing a dice
S = {0, 1, 2, 3, } for counting the carspassing a given point
(S is infinite but discrete)
for measuring the= >
(S is continuous)
An event is subset of S as it is a collection of sam le oints
response me o a
computer system
Universal Event: The entire sample space (S) is anevent called the universal event.
Impossible Event: The empty set () is an event called
the impossible event.
8/2/2019 Lec2b [Compatibility Mode]
34/37
Outline of the Basic Procedure
for Solving Problems
1. Identify the sample space, S..
elements in S.
. .
4. Compute the desired probabilities
8/2/2019 Lec2b [Compatibility Mode]
35/37
Example: To know probability that a random
num er genera or w pro uce a va ue a sprime (range 09999)
. = , , , , ,
2. Pr [1] = Pr [2] = Pr [3] = .. = Pr [9999]=1/10000. , , , .., ,
(Prime numbers,Total = 1229)
4. Probabilit of elementar events in A
1229
.10000 =
8/2/2019 Lec2b [Compatibility Mode]
36/37
Horse-Race with Five runners
Outcome : name of the winner
.
S : { A, B, C, D, E }-
Outcome Assigned Probability Winnings(amount)
(W)A 0.10 50
B 0.05 100
C 0.25 -30
D 0.50 -30
E 0.10 15
W is a random variable, amount to win or lose is shown
8/2/2019 Lec2b [Compatibility Mode]
37/37
3. Assigning Probabilities
W(A) = 50, W(B) =100, W(C) = -30 etc.
P(-30) = Pr(C)+Pr(D)= 0.25+0.50 = 0.75
P(15) = Pr(E) = 0.10
P(50) = Pr(A) = 0.10
P(100) = Pr(B) = 0.054. Expected winnings E(W)
E(W) = -30p(-30)+15p(15)+50p(50)+100p(100)
= -30(0.75)+15(0.10)+50(0.10)+100(0.05)
= -22.5+1.50+5.0+5.0= -22.50+11.50
= -11
Variance of X = Var[X] = E[(x-E[X])2] = p(x)(x-E[X])2
Var[W] = p(-30)x192 +p(15)x262+p(50)x612+p(100)x1112= 1326.5
Standard deviation of W = s rt 1326.5 =36.42
E[W] allows to predict the average observed value of W and the
variance serves to quantify how good this prediction is likely to be.