# Initial value Problem with difference equation

How to solve the initial value problem with

x(n + 1) + x(n) = n^2;
x(0) = 1


I do know how to solve for initial value theorem in differential equation, but not in difference equation.

Like a linear constant coefficient ODE the general solution can be written as the sum of a particular solution and the general solution of the homogeneous equation $x(n+1)+x(n)=0$.
Because the right hand side is a polynomial we look for a polynomial particular solution, and a bit of experimenting will show this to be a quadratic:$$x_p(n)=n^2/2-n/2$$
Also the general solution to the homogeneous equation is obviously: $x_h(n)=k(-1)^n$, and the solution to your problem is the sum $x_p(n)+x_h(n)$ with $k$ chosen to satisfy the initial condition.