# Difference Equations

Example 1: Solving Difference Equation

Example 2: Solving Difference Equation

Difference Equations with Unilateral Z Transform

Example 3: Solving Difference Equation with Initial Conditions

Example 4: Solving Difference Equation with Initial Conditions

## Introduction

Difference equations are called the equations of which the present value of the discrete output is function of the present and previous values of the discrete input and the previous values of the discrete output. For example a difference equation is:

Generally the difference equations are of the form:

## Solving Difference Equations

Solving the Difference Equations we get a function of the output which allows us to directly compute the value of the output for any discrete value of time, without having to compute all the intermediate values of the output.

For large and complicated equations, solving Difference Equations can become a very difficult task. Also solving systems of Difference Equations is a very difficult task. However, there is a tool that simplifies the calculations to something that can be relatively easy to calculate. This tool is the Z Transform.

The concept is simple. Instead of calculating the solution of a Difference Equation directly by the usual methods, apply Z Transform, convert it to algebraic form, solve it and then inversely convert the solution to the form it should be.

**Figure 1: Solving Difference Equations**

**Example 1: Solving Difference Equation**

Calculating the coefficients:

Substituting the coefficients:

From the previous example we can see that initially we had a difference equation in which, in order to calculate any value of y(n), we had to know the value of the previous output y(n-1). Solving the difference equation supplies us a function which allows us to directly calculate any value of y(n).

**Example 2: Solving Difference Equation**

## Difference Equations with Unilateral Z Transform

There are cases that we know the initial conditions of causal difference equations (for which n>=0). The time delay property of these cases is a little bit different. The transform of the delay for shift m<0 is:

**Specifically for m=1 and m=2 we have:**

Similarly for shift m>0 we can calculate:

**Specifically for m=1 and m=2 we have:**

**Example 3: Solving Difference Equation with Initial Conditions**

The initial conditions for this example are:

So:

Calculating the coefficients:

Substituting the coefficients:

**Example 4: Solving Difference Equation with Initial Conditions**

The initial condition for this example is:

So:

Calculating the coefficients:

Substituting the coefficients: