# Recursive functions in discrete mathematics

A recursive function is a function that its value at any point can be calculated from the values of the function at some previous points. For example, suppose a function f(k) = f(k-2) + f(k-3) which is defined over non negative integer. If we have the value of the function at k = 0 and k = 2, we can also find its value at any other non-negative integer. In other words, we can say that a recursive function refers to a function that uses its own previous points to determine subsequent terms and thus forms a terms sequence. In this article, we will learn about recursive functions along with certain examples.

## What is Recursion?

Recursion refers to a process in which a recursive process repeats itself. Recursive is a kind of function of one and more variables, usually specified by a certain process that produces values of that function by continuously implementing a particular relation to known values of the function.

Here, we will understand the recursion with the help of an example.

Suppose you are going to take a stair to reach the first floor from the ground floor. So, to do this, you have to take one by one steps. There is only a way to go to the second step that is to the steeped first step. Suppose you want to go to the third step; you need to take the second step first. Here, you can clearly see the repetition process. Here, you can see that with each next step, you are adding the previous step like a repeated sequence with the same difference between each step. This is the actual concept behind the recursive function.

Step 2: Step 1 + lowest step.

Step 3: Step 2 + Step 1 + lowest step.

Step 4: Step 3 + step 2 + step 1+ lowest step, and so on.

A set of natural numbers is the basic example of the recursive functions that start from one goes till infinity, 1,2,3,4,5,6,7,8, 9,…….infinitive. Therefore, the set of natural numbers shows a recursive function because you can see a common difference between each term as 1; it shows each time the next term repeated itself by the previous term.

### What is a recursively defined function?

The recursively defined functions comprise of two parts. The first part deals with the smallest argument definition, and on the other hand, the second part deals with the nth term definition. The smallest argument is denoted by f (0) or f (1), whereas the nth argument is denoted by f (n).

Suppose a sequence be 4,6,8,10

The explicit formula for the above sequence is f (n)= 2n + 2

The explicit formula for the above sequence is given by

f (0) = 2

f(n) = f (n-1) + 2

Now, we can get the sequence terms applying the recursive formula as follows f(2 ) f (1) + 2

f(2) = 6

f (0) = 2

f(1) = f(0) + 2

f (1) = 2 + 2 = 4

f(2 ) = f (1) + 2

f(2) = 4 + 2 = 6

f(3 ) = f (2) + 2

f(3 ) = 6 + 2 = 8

With the help of the above recursive function formula, we can determine the next term.

### What makes the function recursive?

Making any function recursive needs its own term to calculate the next term in the sequence. For example, if you want to calculate the nth term of the given sequence, you first need to know the previous term and the term before the previous term. Hence, you need to know the previous term to find whether the sequence is recursive or not recursive. So we can conclude that if the function needs the previous term to determine the next term in the sequence, the function is considered a recursive function.

### The formula of the Recursive function

If a1, a2, a3, a4, a5, a6, ……..an,……is many sets or a sequence, then a recursive formula will need to compute all the terms which are existed previously to calculate the value of an

an = an-1 + a1

The above formula can also be defined as Arithmetic Sequence Recursive Formula. You can see clearly in the sequence mentioned above that it is an arithmetic sequence, which comprises the first term followed by the other terms and a common difference between each term. The common difference refers to a number that you add or subtract to them.

A recursive function can also be defined as the geometric sequence, where the number sets or a sequence have a common factor or common ratio between them. The formula for the geometric sequence is given as

an = an-1 * r

Usually, the recursive function is defined in two parts. The first one is the statement of the first term along with the formula, and another is the statement of the first term along with the rule related to the successive terms.

### How to write a Recursive formula for arithmetic sequence

To write the Recursive formula for arithmetic sequence formula, follow the given steps

Step 1:

In the first step, you need to ensure whether the given sequence is arithmetic or not (for this, you need to add or subtract two successive terms). If you get the same output, then the sequence is taken as an arithmetic sequence.

Step 2:

Now, you need to find the common difference for the given sequence.

Step 3:

Formulate the recursive formula using the first term and then create the formula by using the previous term and common difference; thus you will get the given result

an = an-1 + d

now, we understand the given formula with the help of an example

suppose 3,5,7,9,11 is a given sequence

In the above example, you can easily find it is the arithmetic sequence because each term in the sequence is increases by 2. So, the common difference between two terms is 2. We know the formula of recursive sequence

an = an-1 + d

Given,

d = 2

a1 = 3

so,

a2 = a(2-1) + 2 = a1 + 2 = 3+2 = 5

a3 = a(3-1) + 2 = a2+ 2 = 5+2 = 7

a4 = a(4-1) + 2 = a3 + 2 = 7+2 = 9

a5 = a(5-1) + 2 = a + 2 = 9+2 = 11, and the process continues.

### How to write a Recursive formula for Geometric sequence?

To write the Recursive formula for Geometric sequence formula, follow the given steps:

Step 1

In the first step, you need to ensure whether the given sequence is geometric or not (for this, you need to multiply or divide each term by a number). If you get the same output from one term to the next term, the sequence is taken as a geometric sequence.

Step 2

Now, you need to find the common ratio for the given sequence.

Step 3

Formulate the recursive formula using the first term and then create the formula by using the previous term and common ratio; thus you will get the given result

an = r * an-1\

Now, we understand the given formula with the help of an example

suppose 2,8,32, 128,.is a given sequence

In the above example, you can easily find it is the geometric sequence because the successive term in the sequence is obtained by multiplying 4 to the previous term. So, the common ratio between two terms is 4. We know the formula of recursive sequence

an = r * an-1\

an = 4

an-1 = ?

Given,

r = 4

a1 = 2

so,

a2 = a (2-1) * 4 = a1 + * 4 = 2* 4 = 8

a3 = a (3-1) * 4 = a2* 4 = 8 * 4 = 32

a4 = a (4-1) * 4 = a3 * 4 = 32* 4 = 128, and the process continues.

### Example of recursive function

Example 1:

Determine the recursive formula for the sequence 4,8,16,32,64, 128,….?

Solution:

Given sequence 4,8,16,32,64,128,…..

The given sequence is geometric because if we multiply the preceding term, we get the successive terms.

To determine the recursive formula for the given sequence, we need to write it in the tabular form

Term Numbers Sequence Term Function Notation Subscript Notation
1 4 f(1) a1
2 8 f(2) a2
3 16 f(3) a3
4 32 f(4) a4
5 64 f(5) a5
6 128 f(6) a6
n . f(n) an

Hence, the recursive formula in function notion is given by

f(1) = 4, f(n) . f(n- 1)

In subscript notation, the recursive formula is given by

a1 = 4, an = 2. an-1

### Feedback   