cs275 discrete mathematics - gb-liang.com

Post on 10-Jan-2022

2 Views

Category:

Documents

0 Downloads

Preview:

Click to see full reader

TRANSCRIPT

CS275 Discrete Mathematics

Gongbo “Tony” LiangFourth year PhD student in CSgb.liang@uky.eduliang@cs.uky.edu

8.2 Solving Linear Recurrence Relations

Find the solution to an = 7an−2 + 6an−3 with a0 = 9, a1 =10,and a2 =32.

● Step 1. Find the characteristic equation○ an = r3, an-1 = r2, an-2 = r, an-3 = 1

○ The characteristic equation:

r3 = 0• r2 + 7 r + 6•1

r3 – 7r -6 = 0

● Step 2. Solve the characteristic equation

r3 – 7r -6 = 0

(r+1)(r2-r-6) = 0(r+1)(r+2)(r-3) = 0

r = -1, -2, 3

Find the solution to an = 7an−2 + 6an−3 with a0 = 9, a1 =10,and a2 =32.

● Step 3. Solve the recurrence relation an = !1(-1)n+ !2(-2)n+ !3•3n

○ Substitute n=0■ 9 = !1 + !2 + !3 (1)

○ Substitute n=1

■ 10 = !1(-1)+ !2(-2)+ !3•3

■ 10 = −!1 - 2!2 + 3!3 (2)○ Substitute n=2

■ 32 = !1(-1)2+ !2(-2)2+ !3•32

■ 32 = !1 + 4!2 + 9!3 (3)○ (1) + (2)

■ - !2 + 4!3 = 19 (4)

○ (2) + (3)■ 2!2 + 12!3 = 42 (5)

Find the solution to an = 7an−2 + 6an−3 with a0 = 9, a1 =10,and a2 =32.

● Step 3. Solve the recurrence relation (continue)○ (4)x2 + (5)

■ 20!3 = 80

■ !3 = 4

○ Substitute !3 = 4 in (4)

■ !2 = -3○ Substitute !2 = -3, !3 = 4 in (1)

■ !1 = 8

○ !1 = 8○ !1 = 8, !2 = -3, !3 = 4 in an = !1(-1)n+ !2(-2)n+ !3•3n

■ an = 8(-1)n -3(-2)n+ 4•3n

What is the general form of the solutions of a linear homogeneous recurrence relation if its characteristic equation has roots 1,1,1,1,−2,−2,−2,3,3,−4?

What is the general form of the solutions of a linear homogeneous recurrence relation if its characteristic equation has roots 1,1,1,1,−2,−2,−2,3,3,−4?

● The characteristic equation has roots: 1, -2, 3, -4● The multiplies are: 4, 3, 2, 1

● The solution of the recurrence relation is:

Consider the nonhomogeneous linear recurrence relation an=3an−1 +2n.

● A) Show that an = −2n+1 is a solution of this recurrence relation.○ Since an = −2n+1, an-1 = −2n

○ Substitute an-1 = −2n in an=3an−1 +2n

■ an = 3(−2n) + 2n

=-3 • 2n + 2n

= 2n •(-3+1)

= 2n •(-2)= −2n+1

Consider the nonhomogeneous linear recurrence relation an=3an−1 +2n.

● B) Use Theorem 5 to find all solutions of this recurrence relation

Consider the nonhomogeneous linear recurrence relation an=3an−1 +2n.

● B) Use Theorem 5 to find all solutions of this recurrence relation○ Step 1: Find the characteristic equation of the associated homogeneous

recurrence relation, an=3an−1

■ an= r, an−1 = 1

■ r = 3

■ the characteristic equation: an = !3n

Consider the nonhomogeneous linear recurrence relation an=3an−1 +2n.

● B) Use Theorem 5 to find all solutions of this recurrence relation○ Step 2:

■ Assume an(p)=A2n is a particular solution, A is a constant

■ Substitute an(p)=A2n in an=3an−1 +2n

A2n=3(A2n-1)+2n

A2n=(3/2) A2n+2n

A = -2■ The particular solution an

(p)=(-2)•2n=-2n+1

○ The general solution of an=3an−1 +2n is■ an = !3n- 2n+1

Consider the nonhomogeneous linear recurrence relation an=3an−1 +2n.

● C) Find the solution with a0 = 1

○ Apply a0 = 1 to an = !3n- 2n+1

■ A0 = !30- 20+1

■ 1 = !-2

■ ! = 3

○ The solution with a0 = 1 is an = 3•3n- 2n+1 = 3n+1- 2n+1

What is the general form of the particular solution guaranteed to exist by Theorem 6 of the linear nonhomogeneous recurrence relation an = 8an−2 − 16an−4 + F (n) if F(n) = n3

What is the general form of the particular solution guaranteed to exist by Theorem 6 of the linear nonhomogeneous recurrence relation an = 8an−2 − 16an−4 + F (n) if F(n) = n3

● Step 1, solve the characteristic equation of the associated homogeneous recurrence relation

○ The associated homogeneous recurrence relation, an = 8an−2 − 16an−4

○ The characteristic equation of an = 8an−2 − 16an−4 ■ r4 - 8r2 + 16 = 0

■ r = 2, -2 or multiplicity 2

● Step 2, find s in F(n) = (btnt + bt-1nt-1 +…+b1n1 + b0)sn

○ In our case, t=3, s=1■ F(n) = (b3n3)1n

● Step 3, apply Theorem 6,○ s=1, is NOT a root of the associated characteristic equation○ According to Theorem 6

■ There is a particular solution of the form (p3n3+p2n2+p1n1+p0)x1n = p3n3+p2n2+p1n1+p0

What is the general form of the particular solution guaranteed to exist by Theorem 6 of the linear nonhomogeneous recurrence relation an = 8an−2 − 16an−4 + F (n) if F(n) = (-2)n

● Step 1, solve the characteristic equation of the associated homogeneous recurrence relation

○ The associated homogeneous recurrence relation, an = 8an−2 − 16an−4

○ The characteristic equation of an = 8an−2 − 16an−4 ■ r4 - 8r2 + 16 = 0

■ r = 2, -2 or multiplicity 2

● Step 2, find s in F(n) = (btnt + bt-1nt-1 +…+b1n1 + b0)sn

○ In our case, t=0, s=-2

■ F(n) = (b0n0)(-2)n

○ s=-2, is a root of the associated characteristic equation○ According to Theorem 6

■ There is a particular solution of the form n2(p0n0)x(-2)n = n2p0(-2)n

8.5 Inclusion-exclusion principle

There are 2504 computer science students at a school. Of these,

1876 have taken a course in Java, 999 have taken a course in Linux,

and 345 have taken a course in C. Further, 876 have taken courses

in both Java and Linux, 231 have taken courses in both Linux and C,

and 290 have taken courses in both Java and C. If 189 of these

students have taken courses in Linux, Java, and C, how many of

these 2504 students have not taken a course in any of these three

programming languages?

● Solution:○ We know:

■ |J| = 1876, |L| = 999, |C| = 345

■ |J∩L| = 876, |J∩C| = 290, |L∩C| = 231,

■ |J∩L∩C| = 189○ According to Inclusion-exclusion principle

■ |J∪L∪C| = |J|+|L|+|C|- |J∩L| - |J∩C| - |L∩C| + |J∩L∩C| = 2012

○ Thus, 2504-2012 = 492 students have not taken a course in any of the three.

How many elements are in the union of four sets if the sets have 50,

60, 70, and 80 elements, respectively, each pair of the sets has 5

elements in common, each triple of the sets has 1 common

element, and no element is in all four sets?

● Solution:○ We have four sets A1, A2, A3, A4,

■ |A1| = 50, |A2| = 60, |A3| = 70, |A4| = 80

■ Assume 1≤i<j<k≤4

● |Ai∩Aj| = 5, |Ai∩Aj∩Ak | = 1, |A1∩A2∩A3 ∩A4 | = 0,

○ According to Inclusion-exclusion principle|A1∪A2∪A3∪A4 |

= ∑$%&%' |)&| −∑$%&+,%' |)& ∩ ),| +∑$%&+,+.%' |)& ∩ ), ∩ ).| − |)$ ∩ )/ ∩ )0 ∩ )'|= 50+60+70+80 – 6(5)+4(1)-0 = 234

top related