# Time invariance and linearity of recursive system

I am confused about the definition of linearity and time invariance of recursive system

Given $$y[n] = y[n-1] - y[n-2] - x[n]$$

To test time invariance, we shift the input $$x[n]$$ for shifting and see if the output $$y[n]$$.

Now, does shifting the input include the recursive terms?

That is if we shift the input by k, then we get
$$y[n-1+k] - y[n-2+k] - x[n+k]$$

and when the output is shifted we get

$$y[n+k] = y[n-1+k] - y[n-2+k] - x[n+k]$$

and thus the system is time-invariant?

I have the same question with regard to linearity.

The system is both linear and time-invariant.

Theory says linearity means that for an input $$ax_1[n] + bx_2[n]$$ your output would be $$ay_1[n] + by_2[n]$$ where $$y_1[n], y_2[n]$$ are the outputs of $$x_1[n], x_2[n]$$, respectively.

In your case, an input $$x_1[n]$$ gives output $$y_1[n] = y_1[n-1] - y_1[n-2] - x_1[n]$$ same for an input $$x_2[n]$$, thus $$y_2[n] = y_2[n-1] - y_2[n-2] - x_2[n]$$

Multiplying the first equation by $$a$$ and the second by $$b$$ we get $$ay_1[n] = ay_1[n-1] - ay_1[n-2] - ax_1[n]$$ and $$by_2[n] = by_2[n-1] - by_2[n-2] - bx_2[n]$$

Adding together, we get \begin{align} ay_1[n] + by_2[n] &= ay_1[n-1] - ay_1[n-2] - ax_1[n] + by_2[n-1] - by_2[n-2] - bx_2[n] \\ ay_1[n] + by_2[n] &= ay_1[n-1] + by_2[n-1] - ay_1[n-2] - by_2[n-2] - ax_1[n] - bx_2[n]) \end{align} which is the given system with $$x[n] = ax_1[n] + bx_2[n]$$ and $$y[n] = ay_1[n] + by_2[n]$$. So it's linear.

For time-invariance, we first delay the input by $$k$$, thus we get $$y[n] = y[n-1] - y[n-2] - x[n-k]$$

Can you show that for a delayed output (with same delay $$k$$), the same result is obtained?