How do give the recursive form for a certain function?

In summary, the recursive form of a function is a way of expressing a mathematical relationship or algorithm in terms of itself, using a base case and recursive calls. Recursive functions can be identified by their base case and changing parameters, and have advantages in solving repetitive or complex problems. While any function can be written in recursive form, it is important to consider efficiency and avoid common mistakes such as not defining a base case or updating parameters correctly.
  • #1
thename1000
18
0
I only have the explanation for linear homogeneous ones. I don't know how to do these:

Give a recursive form (including bases) for the following functions:
a. f(n) = 2 + (-1)^n
b. f(n) = n(n+1)
c. f(n) = 2n - 2
d. f(n) = n^2 – n
e. f(n) = 3^n + n⋅3^n

If someone could explain one or two it would help alot.

Thanks
 
Physics news on Phys.org
  • #2
Maybe someone could help if you gave more information. What are the domains and codomains supposed to be? What counts as a recursive form (what examples do you have)?

Without more info, my best guess is something like this. For (a), assuming n ranges over N, when n is odd, f(n) = 1; when n is even, f(n) = 3. So you could take n = 1 as your base:
f(1) = 1​
and then use the fact that oddness and evenness alternate in N:
if f(n-1) = 1, then f(n) = 3; otherwise, f(n) = 1​
But there are several ways that you could express that, and your teacher or book might want something else.

(b) can be expressed as the product of 2 and the sum of 1 to n:
f(1) = 2(1) = 2
f(2) = 2(1 + 2) = 6
f(3) = 2(1 + 2 + 3) = 12
...​
So this definition involves another recursive function.
 
  • #3
thename1000 said:
I only have the explanation for linear homogeneous ones. I don't know how to do these:

Give a recursive form (including bases) for the following functions:
a. f(n) = 2 + (-1)^n
b. f(n) = n(n+1)
c. f(n) = 2n - 2
d. f(n) = n^2 – n
e. f(n) = 3^n + n⋅3^n

If someone could explain one or two it would help alot.

Thanks
Step one, compute a few of the values to get a handle on exactly what it is.
for (a), f(1)= 2- 1= 1, f(2)= 2+ 1= 3, f(3)= 2-1= 1, etc. In other words, f(n)= 1 if n is odd, 3, if n is even.

Step two, try to find a relation between f(n) and f(n+1).
f(n+1)- f(n)= 2+ (-1)^(n+1)- 2- (-1)^n= (-1)(-1)^n- (-1)^n= (-2)(-1)^n.

Step three, check that this recursive formula gives the same thing you got in step one to reassure yourself.

f(n+1)= f(n)+ (-2)(-1)^n. That, together with f(1)= 1, is a recursive formula for this sequence.
Note that, according to this, f(2)= f(1)+ (-2)(-1)^1= 1+ 2= 3, f(3)= f(2)+ (-2)(-1)^2= 3- 2= 1, etc.

For b, f(n)= n(n+1), f(1)= 1(2)= 2, f(2)= 2(3)= 6, f(3)= 3(4)= 12, etc. f(n+1)- f(n)= (n+1)(n+2)- n(n+1). Factoring out (n+1), f(n+1)- f(n)= (n+1)(n+2-n)= 2(n+1). f(n+1)= f(n)+ 2(n+1), and f(1)= 2.

By that formula f(2)= f(1)+ 2(2)= 2+ 4= 6, f(3)= f(2)+ 2(3)= 6+ 6= 12, etc.

For (2), since there is no addition or subtraction (addition does not work well together with multiplication!), you could also consider the relation between f(n+1) and f(n) by dividing: f(n+1)/f(n)= (n+1)(n+2)/n(n+1)= (n+2)/n. f(n+1)= [(n+2)/n]f(n) with f(1)= 2, is another recurvsive formula for the same sequence. f(2)= [(1+2)/1]f(1)= 3(2)= 6, f(3)= [(2+2)/2]f(2)= 2(6)= 12, etc.
 
Last edited by a moderator:

FAQ: How do give the recursive form for a certain function?

What is the recursive form of a function?

The recursive form of a function is a way of expressing a mathematical relationship or algorithm in terms of itself. It involves defining a base case or starting point, and then using that base case to recursively calculate the value of the function at each step.

How do I identify a recursive function?

A recursive function will typically have a base case that returns a specific value, and then a recursive call to itself. It may also have one or more parameters that change with each recursive call.

What are the advantages of using a recursive function?

Recursive functions can be particularly useful for solving problems that involve repetitive calculations or algorithms. They can also be used to break down complex problems into simpler steps, making them easier to understand and solve.

Can any function be written in recursive form?

Yes, any function can be written in recursive form. However, some functions may be more easily expressed in recursive form than others. It is important to consider the efficiency and readability of a recursive function before using it.

What are some common mistakes when writing a recursive function?

Some common mistakes when writing a recursive function include not defining a base case, causing the function to run infinitely, and not updating the parameters correctly in each recursive call. It is important to carefully plan and debug a recursive function to avoid these errors.

Similar threads

Replies
4
Views
944
Replies
16
Views
3K
Replies
18
Views
2K
Replies
5
Views
3K
Replies
6
Views
2K
Replies
2
Views
3K
Replies
11
Views
887
Back
Top