lec2byuuryu compatibility mode
TRANSCRIPT
-
8/18/2019 Lec2byuuryu 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/18/2019 Lec2byuuryu 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 B A ⊆ 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 belong
to A.
“Every set is an improper subset of itself”
-
8/18/2019 Lec2byuuryu 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/18/2019 Lec2byuuryu 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 negative integers : N- = { -1, -2, -3, -4, …}
• Real Numbers:
Set of positive real numbers: R+ = { x ∈ R⎥ x > 0 }- = ∈
-
8/18/2019 Lec2byuuryu Compatibility Mode
5/37
• n n erva s a se o num ers y ngbetween two bounds.
– Open interval = { x ∈ R ⎥ a < x < b} – Semi-o en interval = x ∈ R ⎥ a < x ≤ b
or { x ∈ R ⎥ a ≤ x < b }
– Empty interval = { x ∈ R ⎥ a < x < b } where a=b
-
8/18/2019 Lec2byuuryu Compatibility Mode
6/37
FUNCTIONS AND RELATIONS• X & Y be two sets
• e re a on e ween an s ca e unc on :
for each x ∈ X, there exists one and only oney ∈ suc a x, y ∈ .
ƒ : X→Y⇒ ƒ is a function from X to Y.• n re at on x, y ∈ ƒ ⇒ xThe set X is called the domain of the function
The set Y is its imageThe set ƒ[X] = { ƒ(x)⎟ x ∈ X} is its range
-
8/18/2019 Lec2byuuryu Compatibility Mode
7/37
• Example(i) C={(x,1), (y,1)}Domain C={x, y}
(ii) D={(1, 1), (1, 2), (2, 1)}
Domain D= 1 2
Range D={1, 2}
• Injective Function (one-to-one): A function is injectiveere o no ex s wo s nc x1, x2 ∈
such that ƒ(x1) = ƒ(x2).
A={2, 3, 5} B={a, b, x, y}
ƒ={(2, a), (3, x), (5,y)}Domain ƒ={2, 3, 5}Range ƒ={a, x, y}
-
8/18/2019 Lec2byuuryu Compatibility Mode
8/37
A B
“ ”23
5
b
x
Domain ƒ=ARange ƒ≠B
(i)
ange ≠ mage
2 1
A B “A into B”Domain ƒ={2, 4, 6}
=
6 5
,
(Range ≠ image)
ƒ={(2,1), (4,3), {6, 3)}Domain ƒ = A
-
8/18/2019 Lec2byuuryu Compatibility Mode
9/37
Surjective function (onto)
2 1 A B “A onto B”
4
6
3
5
, ,
Range ƒ={1, 3, 5}
ƒ={(2,1), (4,3), (6, 5)}Domain ƒ = A ( ∴Range = image)
-
8/18/2019 Lec2byuuryu Compatibility Mode
10/37
(ii)23
23
“A onto A”Domain ƒ=A=
= 2 2 3 5 5 3
5 5
Domain ƒ = {2, 3, 5}Range ƒ= {2, 3, 5}
( ∴Range = image)
-
8/18/2019 Lec2byuuryu Compatibility Mode
11/37
•both injective and surjective
-1⇒ inverse
ƒ(ƒ-1 (y)) = y for all y ∈ Y
2
3
2
3
“A onto A”
and“ ”
= 2 2 3 5 5 3
5 5
Domain ƒ=ARange ƒ=A
Domain ƒ = {2, 3, 5}Range ƒ= {2, 3, 5}
-
8/18/2019 Lec2byuuryu Compatibility Mode
12/37
• Predicate: A function P: X→ {true, false} is called a predicate on X.
so
P(true, false, true) = true
,, ¬
when P is a predicate on X, we sometimes say P is a property of X.
• Quantifiers“ ”⇒
∃ ⇒ “there exists”
(∀ x ∈ X) [P(x)] ⇒ every x in X has property P.(∃ x ∈ X) [P(x)] ⇒ there exists at least one x in X that has property P.
(∃ ! x ∈ X) [P(x)] ⇒ there exists exactly one x in X that has property P.∀ x ∈ X P x ⇒ is alwa s true if X is an em t set.
(∃ x ∈ X) [P(x)] ⇒ is always false if X is an empty set.
-
8/18/2019 Lec2byuuryu Compatibility Mode
13/37
Alternation of Quantifiers(∀ n ∈ N) (∃ m ∈ N ) [ m > n ]
For every natural number, there exists another natural number (m) greater than (n).
(∃ m ∈ N) (∀ n ∈ N ) [ m > n ]
There is an integer m that is larger that everyna ura num er nc u ng m se .
It is obviously false
∴the order in which the quantifiers are presented isimportant.
-
8/18/2019 Lec2byuuryu Compatibility Mode
14/37
Sums and ProductsSums )2()1()( +++= f(n)..... f f i f Σ
n
Sum of the values taken b on the first n ositive inte ers
1=i
i = 1
)(i f n
Σ
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/18/2019 Lec2byuuryu Compatibility Mode
15/37
-
8/18/2019 Lec2byuuryu Compatibility Mode
16/37
729log729log)( 39 =i
4log
16log16log)(
2
24 =ii
x y bb
y x
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/18/2019 Lec2byuuryu Compatibility Mode
17/37
• Ceiling of x: If x is a real number, [x] denotest e sma est nteger t at s not sma er t an x.
213= x
13
4
−=
=
x
x
77,85.8,35,414.3
3
=−=−==⇒
−=
Ceilin
x
-
8/18/2019 Lec2byuuryu 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 P
y x + 1
d 1
Repeat d d+1 until d divides y
return d
-
8/18/2019 Lec2byuuryu 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 P
repeat x x + 1 until x is prime
return x
-
8/18/2019 Lec2byuuryu 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= z Let
-
8/18/2019 Lec2byuuryu Compatibility Mode
21/37
By our assumption z is irrational
2 z w Let =
s aga n rra ona y our assump on
but
( )22 2222 =⎟ ⎠
⎜⎝
== ×
z w
( ) 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 is
avoided in the context of algorithmics.
-
8/18/2019 Lec2byuuryu 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) Euler’s Conjecture (1769)
Enuler conjectured that this equation can never besatisfied.
Frye (after two centuries) using computing machines for hundreds of hours found that:
4+ 4+ 4= 4 ( -
-
8/18/2019 Lec2byuuryu Compatibility Mode
23/37
Proof By Mathematical Induction
(ii) Polynomial p(n) = n2 + n +41
0 + 1 + 2 + 3 + 4 + 5 + 6
+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/18/2019 Lec2byuuryu 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/18/2019 Lec2byuuryu 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/18/2019 Lec2byuuryu Compatibility Mode
26/37
Tilin Problem• 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/18/2019 Lec2byuuryu Compatibility Mode
27/37
The tiling problem
(a) Board with special square (c) One tile
(c) Placing the first tile (d) solution
-
8/18/2019 Lec2byuuryu Compatibility Mode
28/37
Proof by Mathematical Indirection
m = 2n where n is an integer
if n=0m=20=1⇒1x1 board1 square is special
Board is tiled by doing nothingif n=1
m=21=2⇒2x2 board
square s spec aBoard is tiled by putting 1 tile
-
8/18/2019 Lec2byuuryu Compatibility Mode
29/37
(ii) Induction Step
•m = 2n
• According to induction hypothesis theorem is true for
2n-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 be
tiled
• us t eorem s or m= , an s nce ts trut or m=n
o owsfrom its assumed truth for m=2n-1 for all n ≥ 1, it follows fromthe principle of mathematical induction that the theorem is
rue or a m prov e m s a power o .
• A suitable algorithm can be obtained to solve tiling problem.
-
8/18/2019 Lec2byuuryu 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/18/2019 Lec2byuuryu Compatibility Mode
31/37
• Format definition
• =
21;0 2110 >=+=== −− nor an nnn
, , , , , , , , , , , , ..
• Constructive induction can be useful in the analysis of algorithms.
function Fibonacci (n)
if n
-
8/18/2019 Lec2byuuryu 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 or
elementary events.
-
8/18/2019 Lec2byuuryu 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/18/2019 Lec2byuuryu 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/18/2019 Lec2byuuryu Compatibility Mode
35/37
Example: To know probability that a random
num er genera or w pro uce a va ue a sprime (range 0……9999)
. , , , , ……,
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/18/2019 Lec2byuuryu 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/18/2019 Lec2byuuryu Compatibility Mode
37/37
3. Assigning Probabilities
W(A) = 50, W(B) =100, W(C) = -30 etc.
P - = Pr +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.