Skip to content

JA2. Functions And Sequences

Question 1

We have a function f: Z → Z defined as f(n) = {n+3 if n is odd or n-5 if n is even}.

Find whether the function is injective and surjective.

Injective function means that every element in the domain has at least one element in the codomain; that’s for every n (from Z), has an image in f (also Z), which is true. Surjective functions means for every image in the codomain has an associated element in the original domain, and we can sww that this is achieved.

What would be the inverse of this function?

As our function both injective and surjective; the function can be inverses and the function definition is f^-1 (n) = {n-3 if n is odd, n+5 if n is even}

Example:

f(0) = 3; f(1) = 4;
f^-1(3) = 3-3 = 0;
f^-1(4) = 4-3 =1;

Question 2

Consider three sets A, B, and C each with three elements, and define a function ‘f’ from set A to B and a function ‘g’ from set B to C with the mapping of the elements you specify. After defining ‘f’ and ‘g’, discuss the composition of functions fog and gof on the sets A, B, and C that you have defined.

let A={1,2,3}, B={4,5,6} and f: A → B = {(1,4), (2,5), (3,6)} let C={7,8,9} and g: B → C = {(4,7), (5,8), (6,9)}.

Can both fog and gof be defined for the sets you have considered? Are they equal? Provide proof to support your answer.

fog = f(g) = f({(1,4), (2,5), (3,6)}) = {(1,7), (2, 8), (3,9)} `gof = g(f) = g((4,7), (5,8), (6,9)) = {(4, null), (5, n ull), (6, null)}

Question 3

There are 5 students; Ani, Leon, Linh, Liam, and Abdul with scores in computer science as 75, 60, 85, 95, and 60 respectively. They are graded by the University as B, C, B+, A, and C respectively. Define the mappings from students to marks and marks to grades explicitly.

let Names={Anu, Leon, Linh, Liam, Abdul} let Grades={75, 60, 85, 95, 60} let GradeLetters={B, C, B+, A, C} let f: Names -> Grades = {(Anu, 75), (Leon, 60), (Linh, 85), (Liam, 95), (Abdul, 60)} let g: Grades -> GradesLetter ={(75, B), (60, C), (85, B+), (95, A), (60, C)}

What are the domains and ranges of the functions?

For function f, the domain is the Names set, and the range rf={75, 60, 85, 95} For function g, the domain is the Grades set, and the range is rg={B, C, B+, A }

Can you make a composite function out of this? If yes, make the composite function and find if the composition of functions is commutative. Explain the reason.

The composite function would be giving each student a letter grade; we are naming it as k: Names -> GradesLetter which is equal to grade letter of the student grade; that is k: Names -> Grades -> GradesLetter = Names -> Grades o Grades -> GradesLetter = f o g = {(Anu, B), (Leon, C), (Linh, 85), (Liam, A), (Abdul, C)}

Question 4

Explain the following concepts using relevant examples: sequence, recursive function, closed formula for the sequence, arithmetic sequence, and geometric sequence. Ensure that you do not take the same examples discussed in the textbooks and online resources.

  • Sequence is an ordered list of objects where duplicates are allowed. Example: S= 1,2,3,4,4,5.
  • Recursive function is a function that calls to itself till it reaches the final answer. Example: Fibonacci numbers as F(n) = n * F(n-1) fro n >1, and F(0) = 1
  • Closed Formula for a sequence is formula that allows to calculate value of a term at index n without knowing -or needing to know- the previous term. Example: 2,4,6,8,10, 12 .... 2n.
  • Arithmetic Sequence is a set of numbers where each number can be extracted from the previous one by adding a specific number. Example: 1,2,3,4,5.... where numbers are increased by 1 each.
  • Geometric Sequence is a set of numbers where each number can be extracted from the previous one by multiplying with a specific number. Example: 2,4,8,16.... where numbers are increased by 1 each.

Question 5

i. The sequence 5, 6, 6, 7, 8, 8, 9, 10, 10, 11, 12, 12...... can be generated by a closed formula. Find the formula and the next four terms of the sequence.

Assuming the first term starts with n, by noticing n=5 we can see that the 4 terms after that are: n, n+1, n+1, n+2, n+3, n+3, and then repeating starting from n+4 as n.

Looking at the sequence which ended with 12, the next 4 terms as 13, 14, 14, 15, 16, 16.

ii. Find the next three terms of the series, provide a closed formula and calculate the sum to the first n terms for the following series: 6+36+216+……………….

Looking at the sequence, the formula is f(x) = 6x where x is the index of term in sequence starting from 1.

To calculate the sum sum(n) = ∑ (6x) for (x from 1 to n)

iii. Find the next three terms of the series, provide a closed formula, and calculate the sum to the first n terms for the following series: 21+24+27+……………….

Looking at the sequence, the formula is f(x) = 21 + 3(x -1) Where x is index of the term starting from 1.

To calculate the sum sum(n) = ∑ (21 + 3(x -1)) for (x from 1 to n)