Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
10 views

Math Assignment Unit 4

Uploaded by

shahmeer malik
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
10 views

Math Assignment Unit 4

Uploaded by

shahmeer malik
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Recursive Function Explanation with Examples:

A recursive function is a function that calls itself during its execution. This technique is often
used to solve problems by breaking them down into smaller instances of the same problem.
Each recursive call works on a smaller piece of the problem until a base case is reached,
stopping the recursion.

Example 1: Factorial of a Number (n!)

Consider the factorial function, denoted as n !, which is the product of all positive integers up
to n . The recursive definition is as follows:

- Base case: factorial ( 0 )=1


- Recursive case: factorial ( n )=n ×factorial ( n−1 ) for n> 0

For instance, factorial ( 4 ) can be calculated as 4 ×3 ×2 ×1=24 using the recursive approach.

Example 2: Fibonacci Sequence

The Fibonacci sequence is a series where each number is the sum of the two preceding ones.
The recursive definition is:

- Base cases: fib ( 0 )=0 , fib (1 )=1


- Recursive case: fib ( n )=fib ( n−1 ) + fib ( n−2 ) for n>1

For example, fib (5 ) is calculated as 0 , 1 ,1 , 2 ,3 , 5, where fib (5 )=fib ( 4 )+ fib ( 3 )=3+2=5.

2. Washing Machine Mania: A Case Study in Recursion


a) Setting up a Recurrence Relation
Let's denote the number of machines produced in the nth month as M n, and the total number
of machines produced up to the nth month as T n.
For the first month n = 1, 1 machine is produced, and for the second month n = 2, 2 machines
are produced. From the third month onwards, the number of machines produced each month
is equal to the month number ( n ) . So, we can express M n as:
M n=n
The total number of machines produced up to the nth month can be expressed as the sum of
machines produced in all months up to that month:
T n=M 1+ M 2+ …+ M n

This can be simplified to a recurrence relation for T n as:


T n=T n−1+ n
Where, T 1=1 (base case, since in the first month, 1 machine is produced).
b) Machines Produced in the First Year
To find the total number of washing machines produced in the first year, we need to calculate
T 12, as there are 12 months in a year.
T 12=1+ 2+ 3+…+12
To find out how many machines are produced in the first year (12 months), substitute n=12
into the formula:
n ( n+1 )
T n=
2
This is a sum of the first 12 positive integers:
12 × ( 12+1 ) 12× 13
T 12= = =78
2 2
Therefore, the company produces 78 washing machines in the first year.
c) Explicit Formula
Example:
Suppose we want to find out how many washing machines are produced in the 8th month n =
8 using the explicit formula:
n ( n+1 )
T n=
2
Substitute n = 8 into the formula:
8 × ( 8+1 ) 8 ×9 72
T 8= = = =36
2 2 2
Therefore, according to the explicit formula, the company produces 36 washing machines in
the 8th month.

Reference:

Levin, O. (2021). Discrete mathematics: An open

introduction (3rd ed.). https://discrete.openmathbooks.org/dmoi3/frontmatter.html license

d under CC 4.0

 Section 2.4 – Solving Recurrence Relations of Chapter 2

Doerr, A., & Levasseur, K. (2022). Applied discrete structures (3rd ed.). licensed under

CC BY-NC-SA
 Chapter 8 - Recursion and Recurrence Relations, sections 8.1 (The Many Faces of

Recursion) and 8.3 (Recurrence Relations)

You might also like