Discrete Mathematics with Applications MATH236 Dr. Hung P. Tong-Viet School of Mathematics, Statistics and Computer Science University of KwaZulu-Natal Pietermaritzburg Campus Semester 1, 2013 Tong-Viet (UKZN) MATH236 Semester 1, 2013 1 / 16
Table of contents Recursion 1 Solving linear recurrence relations 2 Tong-Viet (UKZN) MATH236 Semester 1, 2013 2 / 16
Recursion Recursion Sometimes, it is difficult to define an object explicitly. It may be easy to define this object in terms of itself Tong-Viet (UKZN) MATH236 Semester 1, 2013 3 / 16
Recursion Recursion Sometimes, it is difficult to define an object explicitly. It may be easy to define this object in terms of itself This process is called recursion Tong-Viet (UKZN) MATH236 Semester 1, 2013 3 / 16
Recursion Recursion Sometimes, it is difficult to define an object explicitly. It may be easy to define this object in terms of itself This process is called recursion We can use resursion to define sequences, functions and sets Tong-Viet (UKZN) MATH236 Semester 1, 2013 3 / 16
Recursion Recursion Sometimes, it is difficult to define an object explicitly. It may be easy to define this object in terms of itself This process is called recursion We can use resursion to define sequences, functions and sets When define a set recursively, we specify some initial elements in a basis step and provide a rule for constructing new elements from those we already have in the recursive step Tong-Viet (UKZN) MATH236 Semester 1, 2013 3 / 16
Recursion Recursion Sometimes, it is difficult to define an object explicitly. It may be easy to define this object in terms of itself This process is called recursion We can use resursion to define sequences, functions and sets When define a set recursively, we specify some initial elements in a basis step and provide a rule for constructing new elements from those we already have in the recursive step Tong-Viet (UKZN) MATH236 Semester 1, 2013 3 / 16
Recursion Recursively defined functions We use two steps to define a function with the set of nonnegative integers as its domain: Basis Step: Specify the value of the function at zero 1 Tong-Viet (UKZN) MATH236 Semester 1, 2013 4 / 16
Recursion Recursively defined functions We use two steps to define a function with the set of nonnegative integers as its domain: Basis Step: Specify the value of the function at zero 1 Recursive Step: Give a rule for finding its value at an integer from its 2 values at smaller integers Tong-Viet (UKZN) MATH236 Semester 1, 2013 4 / 16
Recursion Recursively defined functions We use two steps to define a function with the set of nonnegative integers as its domain: Basis Step: Specify the value of the function at zero 1 Recursive Step: Give a rule for finding its value at an integer from its 2 values at smaller integers Such a definition is called a recursive or inductive definition Tong-Viet (UKZN) MATH236 Semester 1, 2013 4 / 16
Recursion Recursively defined functions We use two steps to define a function with the set of nonnegative integers as its domain: Basis Step: Specify the value of the function at zero 1 Recursive Step: Give a rule for finding its value at an integer from its 2 values at smaller integers Such a definition is called a recursive or inductive definition For example, the function f is defined recursively by f (0) = 3 and f ( n + 1) = 2 f ( n ) + 2 Tong-Viet (UKZN) MATH236 Semester 1, 2013 4 / 16
Recursion Recursively defined functions We use two steps to define a function with the set of nonnegative integers as its domain: Basis Step: Specify the value of the function at zero 1 Recursive Step: Give a rule for finding its value at an integer from its 2 values at smaller integers Such a definition is called a recursive or inductive definition For example, the function f is defined recursively by f (0) = 3 and f ( n + 1) = 2 f ( n ) + 2 The Fibonacci numbers, f 0 , f 1 , · · · , are defined by the equations f 0 = f 1 = 1 and f n = f n − 1 + f n − 2 Tong-Viet (UKZN) MATH236 Semester 1, 2013 4 / 16
Recursion Recursively defined functions We use two steps to define a function with the set of nonnegative integers as its domain: Basis Step: Specify the value of the function at zero 1 Recursive Step: Give a rule for finding its value at an integer from its 2 values at smaller integers Such a definition is called a recursive or inductive definition For example, the function f is defined recursively by f (0) = 3 and f ( n + 1) = 2 f ( n ) + 2 The Fibonacci numbers, f 0 , f 1 , · · · , are defined by the equations f 0 = f 1 = 1 and f n = f n − 1 + f n − 2 n ! is defined recursively. Tong-Viet (UKZN) MATH236 Semester 1, 2013 4 / 16
Recursion Recursively defined functions We use two steps to define a function with the set of nonnegative integers as its domain: Basis Step: Specify the value of the function at zero 1 Recursive Step: Give a rule for finding its value at an integer from its 2 values at smaller integers Such a definition is called a recursive or inductive definition For example, the function f is defined recursively by f (0) = 3 and f ( n + 1) = 2 f ( n ) + 2 The Fibonacci numbers, f 0 , f 1 , · · · , are defined by the equations f 0 = f 1 = 1 and f n = f n − 1 + f n − 2 n ! is defined recursively. Tong-Viet (UKZN) MATH236 Semester 1, 2013 4 / 16
Recursion Modeling with recurrence relation Example Suppose that a newly-born pair of rabbits, (one male and one female), are put in a field. Rabbits are able to mate at the age of one month so that at the end of the second month, a female can produce another pair of rabbits. Tong-Viet (UKZN) MATH236 Semester 1, 2013 5 / 16
Recursion Modeling with recurrence relation Example Suppose that a newly-born pair of rabbits, (one male and one female), are put in a field. Rabbits are able to mate at the age of one month so that at the end of the second month, a female can produce another pair of rabbits. Suppose that our rabbits never die and that the female always produces one new pair (one male, one female) every month from the second month on. Tong-Viet (UKZN) MATH236 Semester 1, 2013 5 / 16
Recursion Modeling with recurrence relation Example Suppose that a newly-born pair of rabbits, (one male and one female), are put in a field. Rabbits are able to mate at the age of one month so that at the end of the second month, a female can produce another pair of rabbits. Suppose that our rabbits never die and that the female always produces one new pair (one male, one female) every month from the second month on. How many pairs will there be in one year? Tong-Viet (UKZN) MATH236 Semester 1, 2013 5 / 16
Recursion Modeling with recurrence relation Example Suppose that a newly-born pair of rabbits, (one male and one female), are put in a field. Rabbits are able to mate at the age of one month so that at the end of the second month, a female can produce another pair of rabbits. Suppose that our rabbits never die and that the female always produces one new pair (one male, one female) every month from the second month on. How many pairs will there be in one year? Tong-Viet (UKZN) MATH236 Semester 1, 2013 5 / 16
Recursion Fibonacci numbers 1 At the end of the first month, they mate, but there is still one only pair 2 At the end of the second month, the female produces a new pair, so now there are 2 pairs of rabbits in the field Tong-Viet (UKZN) MATH236 Semester 1, 2013 6 / 16
Recursion Fibonacci numbers 1 At the end of the first month, they mate, but there is still one only pair 2 At the end of the second month, the female produces a new pair, so now there are 2 pairs of rabbits in the field 3 At the end of the third month, the original female produces a second pair, making 3 pairs in all in the field. Tong-Viet (UKZN) MATH236 Semester 1, 2013 6 / 16
Recursion Fibonacci numbers 1 At the end of the first month, they mate, but there is still one only pair 2 At the end of the second month, the female produces a new pair, so now there are 2 pairs of rabbits in the field 3 At the end of the third month, the original female produces a second pair, making 3 pairs in all in the field. 4 At the end of the fourth month, the original female has produced yet another new pair, the female born two months ago produces her first pair also, making 5 pairs Tong-Viet (UKZN) MATH236 Semester 1, 2013 6 / 16
Recursion Fibonacci numbers 1 At the end of the first month, they mate, but there is still one only pair 2 At the end of the second month, the female produces a new pair, so now there are 2 pairs of rabbits in the field 3 At the end of the third month, the original female produces a second pair, making 3 pairs in all in the field. 4 At the end of the fourth month, the original female has produced yet another new pair, the female born two months ago produces her first pair also, making 5 pairs 5 The number of pairs of rabbits in the field at the start of each month is 1, 1, 2, 3, 5, 8, 13, 21, 34, ... Tong-Viet (UKZN) MATH236 Semester 1, 2013 6 / 16
Recommend
More recommend