# Solving a recurrence equation

Hi, I'm trying to solve this recurrence equation.

1. Homework Statement
Solve $$y[k+2]+y[k]=sin(k)$$.
$$y[k]=c_1sin(\frac{\pi}{2}k) + c_2cos(\frac{\pi}{2}k) + \frac{sin(k)+sin(k-2)}{2(1+cos(2))}$$

2. Homework Equations

3. The Attempt at a Solution
First I solve the homogeneous equation.
$$y[k+2]+y[k]=0$$.
The characteristic function is
$$r^2+1=0$$
This has two complex roots $$r=i$$ and $$r=-i$$.
Thus the general solution is
$$y[k]=c_1(i)^k+c_2(-i)^k$$
If you change the notation for the complex numbers, then it gives
$$y[k]=c_1(cos(\frac{\pi}{2}k)+isin(\frac{\pi}{2}k)) + c_2(cos(\frac{-\pi}{2}k)+isin(\frac{-\pi}{2}k))$$
After grouping together it gives
$$(c_1+c_2)cos(\frac{\pi}{2}k) + (c_1-c_2)isin(\frac{\pi}{2}k)$$
Apparently, the answer is without complex numbers so I guess they only keep the real part. Then it must be so that
$$c_1-c_2=0\Leftrightarrow c_1=c_2$$
Then I get as solution
$$y[k]=2c_1cos(\frac{\pi}{2}k)$$
which is not the same solution as the general solution in the answer. What did I do wrong?

I also tried to find a particular solution for the non-homogeneous equation. I tried as a solution
$$y[k]=\alpha sin(k)$$
with $$\alpha$$ the parameter to determine. I don't this is the right solution. Can anyone help me with this problem?

Thanks,

Yoran

## Answers and Replies

Related Calculus and Beyond Homework Help News on Phys.org
They don't "only keep the real part". Plug the solution back into the homogeneous equation; the sine part falls out without imposing any constraint on c1 and c2.

Hi,

Thanks for your quick reply. I tried to do what you told me but when I plug it into the homogeneous equation, everything cancels out! I get 0=0. This is what I did:
We have that
$$y[k]=(c_1+c_2)cos(\frac{\pi}{2}k)+(c_1-c_2)isin(\frac{\pi}{2}k)$$
I plug it into
$$y[k+2]+y[k]=0$$
I get
$$(c_1+c_2)cos(\frac{\pi}{2}(k+2))+(c_1-c_2)isin(\frac{\pi}{2}(k+2))+(c_1+c_2)cos(\frac{\pi}{2}k)+(c_1-c_2)isin(\frac{\pi}{2}k)=0$$
Because
$$cos(\theta + \pi)=-cos(\theta)$$ and
$$sin(\theta + \pi)=-sin(\theta)$$
I get that
$$-(c_1+c_2)cos(\frac{\pi}{2}k)-(c_1-c_2)isin(\frac{\pi}{2}k)+(c_1+c_2)cos(\frac{\pi}{2}k)+(c_1-c_2)isin(\frac{\pi}{2}k)=0$$
which makes
$$0=0$$
How come?

Actually, you are correct. That was a silly suggestion of me, because 0=0 simply confirms your solution satisfies the equation from which you derived the solution. I will edit this post if I come up with something.

Edit: Wow I had been reading it wrong for a good 45 minutes, sorry! Consider complex coefficients and make the substitution d1=c1+c2 and d2=i(c1-c2).

Can you find the particular solution from here?

Last edited:
Hi,

Yeah of course... just give different names as they are just parameters... Thanks a lot.
I tried the substitution $$\alpha sin(k)$$ because there is $$sin(k)$$ on the right side of the equation. However, I can't find the right answer. This is what I have done:
Try
$$y[k]=\alpha sin(k)$$
Plug it into the equation:
$$\alpha sin(k+2) + \alpha sin(k) = sin(k)$$
Then we get
$$\alpha = \frac{sin (k)}{2sin(k+1)cos(1)}$$
by using the identity
$$sin(\theta) + sin(\alpha) = 2sin(\frac{\theta + \alpha}{2})cos(\frac{\theta - \alpha}{2})$$
The answer for $$\alpha$$ is obviously not the right answer.
Did I make the wrong substitution?

Anyone?

tiny-tim
Homework Helper
Try
$$y[k]=\alpha sin(k)$$
Hi yoran!

Try $$y[k]=\alpha\,sin(k\,-\,1)$$ .

Ok, I tried
$$y[k]=\alpha \sin(k-1)$$.
Then I get that
$$\alpha = \frac{1}{2\cos 1}$$
So given the solution for the homogeneous equation and this solution, I have that
$$y[k]=c_1\sin{\frac{\pi}{2}k} + c_2\cos{\frac{\pi}{2}k} + \frac{1}{2\cos{1}}\sin{k-1}$$
But the answer should be
$$y[k]=c_1\sin{\frac{\pi}{2}k} + c_2\cos{\frac{\pi}{2}k} + \frac{\sin{k}+\sin(k-2)}{2(1+\cos{2})}$$
Where does it go wrong in my solution?

tiny-tim
Homework Helper
Hi yoran!
…I have that
$$y[k]=c_1\sin{\frac{\pi}{2}k} + c_2\cos{\frac{\pi}{2}k} + \frac{1}{2\cos{1}}\sin{k-1}$$
But the answer should be
$$y[k]=c_1\sin{\frac{\pi}{2}k} + c_2\cos{\frac{\pi}{2}k} + \frac{\sin{k}+\sin(k-2)}{2(1+\cos{2})}$$
Where does it go wrong in my solution?
:rofl: But they're the same! :rofl:​

Standard trig equation: 1 + cos(2) = 2cos²(1).

So $$\frac{\sin{k}+\sin(k-2)}{2(1+\cos{2})}$$ = … ?

Hehe, of course... Thanks a lot!
$$\frac{\sin{k}+\sin(k-2)}{2(1+\cos{2})}=\frac{2\sin(k-1)\cos(1)}{4\cos^2(1)}=\frac{\sin(k-1)}{2\cos 1}$$