# Stuck with difference equations

Hello. I am stuck with linear difference equations and i would like some help.

I was given that y(k) = y(k)homogeneous + y(k)particular and i am asked to solve the linear equation:

y(k+1) + y(k) = k
with initial condition y(0) = 0

the homogeneous solution is
y(k+1) + y(k) = 0
n + 1 = 0
n = 1
y(k)homogeneous = C(-1)^k
y(0) = 0 = C(-1)^0
C = 0
y(k)homogeneous = 0

then the particular solution
y(k)particular = Bv0*(K) + Bv1
then they tell to substitute this particular equation to the original y(k+1) + y(k) = k
and after i do so, i should get
Bv0=1/2 and B1=-1/4

However, no matter how i substitute i can't get the answer.
Maybe i am substituting the wrong thing. Can anyone show me the substitution process which leads to the mentioned result of Bv0 and Bv1?

Thanks.

## Answers and Replies

AKG
Science Advisor
Homework Helper
y(k+1) + y(k) = k
Bv0*(k+1) + Bv1 + Bv0*(k) + Bv1 = k
2Bv0*k + (Bv0 + 2*Bv1) = k
2Bv0 = 1, Bv0 + 2*Bv1 = 0

Solving gives what you're told it should.

I am able to get to this point
2Bv0*k + (Bv0 + 2*Bv1) = k

Then you let k =1
2Bv0 = 1, Bv0 + 2*Bv1 = 0
but why 1? why not another number? how do i know what number should it be?

Also the second part is grouped in parenthesis but is not a root, how come you are allowed to do that?

Sorry if the questions are silly but i am really confused.

Thanks.

uart
Science Advisor
Then you let k =1

No you are totally mis-understanding what's going on.

k is the variable in the equation (like perhaps you may be familar with using say x or t in a continuous system).

So imagine you had to solve the following equation (assummed true for all x) for the unknowns a and b,

$$a x + b = 2x + 5$$

You see how I solve that equation to get a = 2 and b = 5 right. There was no setting x=1 or anything of the sort involved. Your situation involves exactly the same type of thing, can you follow?

Last edited:
HallsofIvy
Science Advisor
Homework Helper
Hello. I am stuck with linear difference equations and i would like some help.

I was given that y(k) = y(k)homogeneous + y(k)particular and i am asked to solve the linear equation:

y(k+1) + y(k) = k
with initial condition y(0) = 0

the homogeneous solution is
y(k+1) + y(k) = 0
n + 1 = 0
n = 1
Typo. You mean n= -1.

y(k)homogeneous = C(-1)^k
y(0) = 0 = C(-1)^0
C = 0
y(k)homogeneous = 0
No. It is not the solution to the associated homogenous equation that is 0 when k= 0, it is the entire solution. Don't solve for C until you have the entire equation.

then the particular solution
y(k)particular = Bv0*(K) + Bv1
then they tell to substitute this particular equation to the original y(k+1) + y(k) = k
and after i do so, i should get
Bv0=1/2 and B1=-1/4
Yes, assuming a solution of the form yk= Ak+ B (I find "Bv0" and "Bv1" confusing and much too much work to type!) then yk+1= A(k+1)+ B= Ak+ A+ b so the equation yk+1+ yk= k becomes (Ak+ A+ B)+ (Ak+ B)= k. Doing the algebra, 2Ak+ A+2B= k. For that to be true for all k, we must have 2A= 1 and A+ 2B= 0. From the first, A= 1/2 and then 1/2+ 2B= 0 so B= -1/4.

However, no matter how i substitute i can't get the answer.
Maybe i am substituting the wrong thing. Can anyone show me the substitution process which leads to the mentioned result of Bv0 and Bv1?

Thanks.
As I said before, don't solve for C until you have the entire solution. The general solution to the equation is yk= C(-1)k+ (1/2)k- 1/4. Now, y0= C(-1)0+ (1/2)(0)- 1/4= C- 1/4= 0 so C= 1/4. The solution to your problem is yk= (1/4)(-1)k+ (1/2)k- 1/4.

Last edited by a moderator:
I see it is solving coefficients. I don't remember being taught that but thanks to clear things out.

Yes, it was (n = -1). My fault.

Sorry about the notations but i was just following the book; and i didn't know you could write superscripts and subscripts in this forum neither.

Anyway, thanks everyone for your help.

Last edited: