What is the recursive definition of $f(n)=1+(-1)^n$ for $n≥1$? I think it's:

1.6k Views Asked by At

What is the recursive definition of $f(n)=1+(-1)^n$ for $n≥1$? I think it's:

1) $f(1)=0$

2) $f(n)=f(n-1)+2$ if $n$ is even

$f(n)=f(n-1)-2$ if $n$ is odd

Is it correct?

2

There are 2 best solutions below

3
On

Your casewise approach works. Alternatively, you can say $f(1)=0,$ and $$f(n)=f(n-1)-2(-1)^{n-1}$$ for $n\ge 2.$

To come up with that, I started with the explicit formula, so that $$f(n)-f(n-1)=\left(1+(-1)^n\right)-\left(1+(-1)^{n-1}\right),$$ then worked to get it into like terms to simplify: $$f(n)-f(n-1)=1+(-1)^n-1-(-1)^{n-1}$$ $$f(n)-f(n-1)=(-1)^n-(-1)^{n-1}$$ $$f(n)-f(n-1)=-2(-1)^{n-1}.$$

Just as simply, we could have noticed that $-(-1)^{n-1}=(-1)^n,$ leading instead to the formula $$f(n)=f(n-1)+2(-1)^n.$$

1
On

$$f(1) = 0 \\ f(n) = 2 - f(n-1)$$