Recursive Definitions and Finding Closed Forms, Study Guides, Projects, Research of Mathematics

Recursive definitions, their power in revealing patterns, and methods for finding closed forms of recursive numerical functions. It includes examples of recursive definitions for summations and functions, as well as techniques like unrolling and divide and conquer for finding closed forms.

Typology: Study Guides, Projects, Research

2021/2022

Uploaded on 09/12/2022

ekambar
ekambar 🇺🇸

4.8

(25)

264 documents

1 / 9

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Recursive Definition
Margaret M. Fleck
11 October 2011
These notes cover recursive definition, including finding closed forms.
1 Recursive definitions
Thus far, we have defined objects of variable length using semi-formal defi-
nitions involving . . .. For example, we defined the summation Pn
i=1 iby
n
X
i=1
i= 1 + 2 + 3 + ...+ (n1) + n
This method is only ok when the reader can easily see what regular pattern
the ...is trying to express. When precision is essential, e.g. when the pattern
is less obvious, we need to switch to “recursive definitions.”
Recursive function definitions in mathematics are basically similar to re-
cursive procedures in programming languages. A recursive definition defines
an object in terms of smaller objects of the same type. Because this pro-
cess has to end at some point, we need to include explicit definitions for the
smallest objects. So a recursive definition always has two parts:
Base case or cases
Recursive formula
1
pf3
pf4
pf5
pf8
pf9

Partial preview of the text

Download Recursive Definitions and Finding Closed Forms and more Study Guides, Projects, Research Mathematics in PDF only on Docsity!

Recursive Definition

Margaret M. Fleck

11 October 2011

These notes cover recursive definition, including finding closed forms.

1 Recursive definitions

Thus far, we have defined objects of variable length using semi-formal defi- nitions involving.. .. For example, we defined the summation

∑n i=1 i^ by

∑^ n

i=

i = 1 + 2 + 3 +... + (n − 1) + n

This method is only ok when the reader can easily see what regular pattern the... is trying to express. When precision is essential, e.g. when the pattern is less obvious, we need to switch to “recursive definitions.”

Recursive function definitions in mathematics are basically similar to re- cursive procedures in programming languages. A recursive definition defines an object in terms of smaller objects of the same type. Because this pro- cess has to end at some point, we need to include explicit definitions for the smallest objects. So a recursive definition always has two parts:

  • Base case or cases
  • Recursive formula

For example, the summation

∑n i=1 i^ can be defined as:

  • g(1) = 1
  • g(n) = g(n − 1) + n, for all n ≥ 2

Both the base case and the recursive formula must be present to have a complete definition. However, it is traditional not to explicitly label these two pieces. You’re just expected to figure out for yourself which parts are base case(s) and which is the recursive formula. The input values are normally assumed to be integers.

The true power of recursive definition is revealed when the result for n depends on the results for more than one smaller value, as in the strong induction examples. For example, the famous Fibonacci numbers are defined:

• F 0 = 0

• F 1 = 1

  • Fi = Fi− 1 + Fi− 2 , ∀i ≥ 2

So F 2 = 1, F 3 = 2, F 4 = 3, F 5 = 5, F 6 = 8, F 7 = 13, F 8 = 21, F 9 = 34. It isn’t at all obvious how to express this pattern non-recursively.

2 Finding closed forms

Many recursive numerical formulas have a closed form, i.e. an equivalent expression that doesn’t involve recursion (or summation or the like). Some- times you can find the closed form by working out the first few values of the function and then guessing the pattern. More often, you need to use an organized technique. The simplest technique for finding closed forms is called “unrolling.”

For example, suppose we have a function T : N → Z defined by

Now, we need to determine when the input to T will hit the base case. In our example, the input value is n − k and the base case is for an input of 1. So we hit the base case when n − k = 1. i.e. when k = n − 1. Substituting this value for k back into our equation, and using the fact that T (1) = 1, we get

T (n) = 2 kT (n − k) + 3

∑^ k−^1

i=

(2i)

= 2 n−^1 T (1) + 3

n∑− 2

i=

(2i)

= 2 n−^1 + 3

∑^ n−^2

k=

(2k)

= 2 n−^1 + 3(2n−^1 − 1) = 4(2n−^1 ) − 3 = 2n+1^ − 3

So the closed form for this function is T (n) = 2n+1^ − 3. The unrolling process isn’t a formal proof that our closed form is correct. However, we’ll see below how to write a formal proof using induction.

3 Divide and conquer

Many important algorithms in computer science involve dividing a big prob- lem of (integer) size n into a sub-problems, each of size n/b. This general method is called “divide and conquer.” Analyzing such algorithms involves recursive definitions that look like:

S(1) = c S(n) = aS(⌈n/b⌉) + f (n), ∀n ≥ 2

The base case takes some constant amount of work c. The term f (n) is the work involved in dividing up the big problem and/or merging together

the solutions for the smaller problems. The call to the ceiling function is required to ensure that the input to S is always an integer.

Handling such definitions in full generality is beyond the scope of this class.^1 So let’s consider a particularly important special case: dividing our problem into two half-size problems, where the dividing/merging takes time proportional to the size of the problem. And let’s also restrict our input n to be a power of two, so that we don’t need to use the ceiling function. We then get a recursive definition that looks like:

S(1) = c S(n) = 2 S(n/2) + n, ∀n ≥ 2 (n a power of 2)

Unrolling this, we get

S(n) = 2 S(n/2) + n = 2(2S(n/4) + n/2) + n = 4 S(n/4) + n + n = 8 S(n/8) + n + n + n

... = 2 iS(

n 2 i^

) + in

We hit the base case when 2 ni = 1 i.e. when i = log n (i.e. log base 2, which is the normal convention for algorithms applications). Substituting in this value for i and the base case value S(1) = c, we get

S(n) = 2iS(

n 2 i^

) + in = 2log^ nc + n log n = cn + n log n

So the closed form for S(n) is cn + n log n. In real applications, our input n might not be a power of 2, so our actual recurrence might look like:

(^1) See any algorithms text for more details.

corresponds to the value of one coordinate. The edges connect nodes that differ in exactly one coordinate.

Qn^ has 2n^ nodes. To compute the number of edges, we set up the following recursive definition for the number of edges E(n) in the Qn:

1. E(0) = 0

  1. E(n) = 2E(n − 1) + 2n−^1 , for all n ≥ 1

The 2n−^1 term is the number of nodes in each copy of Qn−^1 , i.e. the number of edges required to join corresponding nodes. We’ll leave it as an exercise to find a closed form for this recursive definition.

5 Proofs with recursive definitions

Recursive definitions are ideally suited to inductive proofs. The main out- line of the proof often mirrors the structure of the recursive definition. For example, let’s prove the following claim about the Fibonacci numbers:

Claim 1 For any n ≥ 0 , F 3 n is even.

Let’s check some concrete values: F 0 = 0, F 3 = 2, F 6 = 8, F 9 = 34. All are even. Claim looks good. So, let’s build an inductive proof:

Proof: by induction on n. Base: F 0 = 0, which is even. Induction: Suppose that F 3 k is even. We need to show that that F3(k+1) is even.

F3(k+1) = F 3 k+3 = F 3 k+2 + F 3 k+ But F 3 k+2 = F 3 k+1+F 3 k. So, substituting into the above equation, we get: F3(k+1) = (F 3 k+1 + F 3 k) + F 3 k+1 = 2F 3 k+1 + F 3 k By the inductive hypothesis F 3 k is even. 2F 3 k+1 is even because it’s 2 times an integer. So their sum must be even. So F3(k+1) is even, which is what we needed to show.

Some people feel a bit uncertain if the base case is a special case like zero. It’s ok to also include a second base case. For this proof, you would check the case for n = 1 i.e. verify that F 3 is even. The extra base case isn’t necessary for a complete proof, but it doesn’t cause any harm and may help the reader.

6 Inductive definition and strong induction

Claims involving recursive definitions often require proofs using strong in- duction. For example, suppose that the function f : N → Z is defined by

f (0) = 2

f (1) = 3

∀n ≥ 1, f (n + 1) = 3f (n) − 2 f (n − 1)

I claim that:

Claim 2 ∀n ∈ N, f (n) = 2n^ + 1

We can prove this claim as follows:

Proof: by induction on n. Base: f (0) is defined to be 2. 2^0 +1 = 1+1 = 2. So f (n) = 2n^ + when n = 0. f (1) is defined to be 3. 21 + 1 = 2 + 1 = 3. So f (n) = 2n^ + 1 when n = 1.