---
title: "Difference eq y(n+2)+2y(n+1)+y(n)=n"
subject: "Applied Mathematics"
chapter: 2
key: "semester_4/applied_mathematics:difference-eq-forced-n"
source: https://www.bctengineer.com/q/semester_4/applied_mathematics/difference-eq-forced-n
site: BCT Engineering
---

# Difference eq y(n+2)+2y(n+1)+y(n)=n

Applied Mathematics · Chapter 2: The Z-Transform

- Asked in: 2069 Poush
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_4/applied_mathematics/difference-eq-forced-n
- Whole chapter: https://www.bctengineer.com/md/semester_4/applied_mathematics/chapter-2

## Question

Solve the difference equation: y_{n+2} + 2y_{n+1} + y_n = n where y₀ = y₁ = 0, and n = k.

## Short answer

Apply z-transform, get Y(z)=z/[(z-1)^2(z+1)^2]. Partial fractions lead to y(n)=1/4[n-1+(1-n)(-1)^n].

## Answer

**Equation:** y(n + 2) + 2y(n + 1) + y(n) = n, y(0) = y(1) = 0 (n plays the role of k).

**Step 1: z-transform** (Z[n] = z/(z − 1)²). With zero initial values:

```text
(z² + 2z + 1) Y = z/(z − 1)²
Y(z) = z / [(z − 1)²(z + 1)²]
```

**Step 2: partial fractions.**

Y/z = 1/[(z − 1)²(z + 1)²] = A/(z − 1) + B/(z − 1)² + C/(z + 1) + D/(z + 1)²

```text
B = 1/(1 + 1)²  = 1/4
D = 1/(−1 − 1)² = 1/4
A = d/dz (z + 1)⁻² at z = 1 = −2/(z+1)³ = −1/4
C = d/dz (z − 1)⁻² at z = −1 = −2/(z−1)³ = +1/4
```

Y(z) = −¼ z/(z − 1) + ¼ z/(z − 1)² + ¼ z/(z + 1) + ¼ z/(z + 1)²

**Step 3: inverse** using Z⁻¹[z/(z−1)] = 1, Z⁻¹[z/(z−1)²] = n, Z⁻¹[z/(z+1)] = (−1)ⁿ, Z⁻¹[z/(z+1)²] = −n(−1)ⁿ:

y(n) = −¼ + ¼ n + ¼ (−1)ⁿ − ¼ n (−1)ⁿ

**Answer:** y(n) = ¼ [ n − 1 + (1 − n)(−1)ⁿ ].

Check: the formula gives y(0..4) = 0, 0, 0, 1, 0, and the recurrence y(n+2) = n − 2y(n+1) − y(n) gives y(2) = 0, y(3) = 1, y(4) = 2 − 2·1 − 0 = 0 ✓.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Z[n] =
   A. z/(z-1)^2
   B. z/(z-1)
   C. z/(z+1)^2
   D. 1/(z-1)^2
   Answer: A. Ramp. (Key point: Forcing)

2. Y(z) =
   A. z/[(z-1)(z+1)]
   B. z/[(z-1)^2 (z+1)^2]
   C. 1/[(z-1)^2(z+1)^2]
   D. z^2/[(z-1)^2(z+1)^2]
   Answer: B. (z+1)^2 Y = z/(z-1)^2. (Key point: Transform)

3. Both poles are double, so Y/z uses
   A. two terms
   B. three terms
   C. four terms A, B, C, D
   D. six terms
   Answer: C. Two double poles. (Key point: Repeated poles)

4. y(n) =
   A. (1/4)[n + 1 + (n+1)(-1)^n]
   B. n/4
   C. (1/4)[n - 1 - (1-n)(-1)^n]
   D. (1/4)[n - 1 + (1-n)(-1)^n]
   Answer: D. y(0..4) = 0,0,0,1,0. (Key point: Result)

## Related in Applied Mathematics

- [Difference eq x(k+2)+2x(k+1)+3x(k)=0](https://www.bctengineer.com/question.md?key=semester_4%2Fapplied_mathematics%3Adifference-eq-2x1-3x-x0-0-x1-2) — Applied Mathematics, chapter 2, asked 5×
- [Difference eq x(k+2)-4x(k+1)+4x(k)=2^k](https://www.bctengineer.com/question.md?key=semester_4%2Fapplied_mathematics%3Adifference-eq-forced-2k-4) — Applied Mathematics, chapter 2, asked 5×
- [Difference eq x(k+2)+6x(k+1)+9x(k)=2^k](https://www.bctengineer.com/question.md?key=semester_4%2Fapplied_mathematics%3Adifference-eq-forced-2k-9) — Applied Mathematics, chapter 2, asked 5×
- [Difference eq x(k+2)-4x(k+1)+4x(k)=0, x(0)=1](https://www.bctengineer.com/question.md?key=semester_4%2Fapplied_mathematics%3Adifference-eq-4x1-4x-x0-1-x1-0) — Applied Mathematics, chapter 2, asked 3×
- [Difference eq x(k+2)+3x(k+1)+2x(k)=0](https://www.bctengineer.com/question.md?key=semester_4%2Fapplied_mathematics%3Adifference-eq-3x1-2x-x0-0-x1-1) — Applied Mathematics, chapter 2, asked 3×
- [Difference eq x(k+2)-4x(k+1)+4x(k)=0, x(0)=0](https://www.bctengineer.com/question.md?key=semester_4%2Fapplied_mathematics%3Adifference-eq-4x1-4x-x0-0-x1-1) — Applied Mathematics, chapter 2, asked 2×

## Related in other subjects

- [Solve dy/dx − 2y tan x = y² tan x](https://www.bctengineer.com/question.md?key=semester_1%2Fmathematics_i%3Ade-bernoulli-2y-tan-x) — Mathematics I, chapter 4, asked 6×
- [Solve ODE by Laplace transform y''+y'−2y=x](https://www.bctengineer.com/question.md?key=semester_3%2Fmathematics_iii%3Asolve-ode-by-laplace-transform-y-seven) — Mathematics III, chapter 3, asked 5×
- [Solve x²y''−xy'+2y=x log x](https://www.bctengineer.com/question.md?key=semester_1%2Fmathematics_i%3Ade-cauchy-x2y2-minus-xy1-plus-2y-x-log-x) — Mathematics I, chapter 4, asked 4×
- [Solve ODE by Laplace transform y''+3y'+2y=eᵗ](https://www.bctengineer.com/question.md?key=semester_3%2Fmathematics_iii%3Asolve-ode-by-laplace-transform-y-three) — Mathematics III, chapter 3, asked 4×
