### 4. Given recurrence relation
\[
a_n = -a_{n-1} + n
\]
with initial condition
\[
a_0 = 2
\]
---
### (a) Associated homogeneous recurrence relation
**Solution:**
\[
a_n = -a_{n-1}
\]
---
### (b) General solution to the homogeneous recurrence \((a_n^{(h)})\)
**Solution:**
The characteristic equation has a single root \(-1\), so the general solution is
\[
a_n^{(h)} = \alpha(-1)^n
\]
---
### (c) Particular solution \((a_n^{(p)})\)
**Solution:**
Since the non-homogeneous part is \(n\), assume a particular solution of the form
\[
a_n^{(p)} = cn + d
\]
Substitute into the recurrence relation:
\[
cn + d = -\big(c(n-1) + d\big) + n
\]
\[
= -cn + c - d + n
\]
Rearranging:
\[
2cn - c + 2d - n = 0
\]
\[
n(2c - 1) + (2d - c) = 0
\]
Set each coefficient equal to zero:
\[
2c - 1 = 0 \Rightarrow c = \frac{1}{2}
\]
\[
2d - \frac{1}{2} = 0 \Rightarrow d = \frac{1}{4}
\]
Therefore, the particular solution is
\[
a_n^{(p)} = \frac{1}{2}n + \frac{1}{4}
\]