CMSC 603 Notes, 4/9/99

Bianca Benincasa

bbenin1@cs.umbc.edu

CMSC 603 Notes -- April 9, 1999

1. Schedule

April 16th: Self-Modifying Data Structures; Markov Models

April 23rd: Exposition of Research Project in Cryptography

April 30th: Guest Speaker

May 7th: Guest Speaker

May 14th: Student Project Presentations

May 21st: In-Class Final Exam, 3pm

2. Mathematical Modeling

What is a model?

- Objects & Relationships

(must choose what's important)

- Representation of some phenomenon

- Characteristics

robustness

complexity

accuracy

extensibility

flexibility

extent

Why use a model?

- Simulation before implementation

- Predict the future

- Gain understanding

Expert Systems

- Rule-Based

- Model-Based

- Knowledge-Based

This type of system knows what it knows, and can explain the decisions it makes.

3. Difference Equations

Discrete-time analog of differential equations Reference: Mickens textbook

Characteristic equations

Fibonacci numbers: f_n+2 = f_n+1 + f_n; f_0 = 0; f_1 = 1

This is a second-order, linear, homogeneous recurrence

Characteristic equation: Assume f_n is exponential in nature.

Base the equation on the recurrence.

r^2 - r - 1 = 0

Quadratic formula -> r = (1 +/- sqrt(5))/2

r_1 = (1+sqrt(5))/2 r_2 = (1-sqrt(5))/2

f_n = c_1 r_1^n + c_2 r_2^n, a linear combination of powers of the roots of the equation.

To solve for c_i, use the boundary conditions.

f_0 = 0 = c_1 r_1^0 + c_2 r_2^0 = c_1 + c_2;

so c_1 = -c_2

f_1 = 1 = c_1 r_1^1 + c_2 r_2^1 = c_1 r_1 - c_1 r^2

Plugging in r_1 and r_2 yields c_1 = 2/sqrt(5).

So, f_n = (2/sqrt(5)) ((1 + sqrt(5))/2)^n - (2/sqrt(5)) ((1 - sqrt(5))/2)^n .

What if we would have had a repeated root to our equation? Then we could throw in polynomials in the repeated root, of increasing degree.

Example: c_1 r^n + c_2 n r^n + c_3 n^2 r^n .....

Nonhomogeneous Case

f_n+2 = f_n+1 + f_n + g(n); f_0 = 0; f_1 = 1

So, f_n+2 - f_n+1 - f_n = g(n). There is no guaranteed method for arbitrary g(n).

However, we do have a method when g(n) is of the form p(n) b^n, where p(n) is a polynomial in n.

In that case, we try to eliminate g(n) and solve the resulting homogeneous system. From the recurrence, we obtain:

b f_n+2 - b f_n+1 - b f_n = p(n) b^n+1 f_n+3 -f_n+2 - f_n+1 = p(n+1) b^n+1

We still have to match up p(n) and p(n+1) somehow. Then we can combine the above two equations to obtain a third-order, homogenous recurrence. This could be solved by generating functions.

Complex Roots

y_k+2 -2 y_k+1 + 2 y_k = 0

is a second-order, linear, homogeneous recurrence.

We construct its characteristic equation:

r^2 - 2r + 2 = 0, and solve for r using the quadratic formula:

r = 1 +/- i.

We can use these complex roots just as before; the expressions using them will "work out" to be real numbers, since the actual solution is periodic in nature.

Note: e^ix = cos(x) + i sin(x)

So, we let r_1 = 1 + i = sqrt(2) e^(i pi/4),

r_2 = 1 - i = sqrt(2) e^(-i pi/4),

using isosceles triangles, the Pythagorean theorem, and the fact that a + bi = R e^(i*theta).

Thus, y_k = c_1 r_1^k + c_2 r_2^k

= c_1 (sqrt(2) e^(i pi/4))^k + c_2 (sqrt(2) e^(-i pi/4))^k

= d_1 2^(k/2) cos(k pi/4) + d_2 2^(k/2) sin(k pi/4).

We can solve for d_1, d_2 using the boundary conditions of the original recurrence.

An Example Difference Equations Problem

D_k+1 = f*D_k*S_k + B dS_k+1 = S_k - f*D_kS_k

S_k represents the number of people who are susceptible to a certain disease at time k

D_k represents the number of people who are diseased at time k

After a person has the disease for one timestep, they are no longer diseased, although they may become reinfected at the next timestep.

This is a nonhomogeneous, nonlinear recurrence, which we don't have a general method of solving. So, we will approximate with a linear recurrence. To do this, we first identify the fixed points of the recurrence: places where D_k+1 = D_k, S_k+1 = S_k.

Combining the two recurrence relations yields that D_k has a fixed point at B and S_k has a fixed point at 1/f.

Now that we have the fixed points, we will expand the linear approximation around them. (If D_k = D_k+1 and S_k = S_k+1, the recurrence is at least locally linear, so our approximation won't be so bad there.

Let D_k = B + e_k, S_k = 1/f + d_k, where e and d are error terms. Now we will substitute these into the original system of recurrences, and throw out the lower-order nonlinear terms, since e and d should be small in magnitude there. We must obtain recurrences for e and d.

Substituting:

B + e_k+1 = f(B + e_k)(1/f + d_k) = (B + e_k)(1 + f*d_k) = B + Bf(d_k) + e_k +f(e_k)(d_k) ~ B + e_k + Bf(d_k)

delta(S_k) = (B + e_k)(-1 - fd_k) + B ~ -B - e_k - Bf(d_k) + B = -e_k - Bf(d_k)

Since the change in S_k is the change in d_k (around the fixed point), we have that

d_k+1 = d_k - e_k - Bf(d_k)

Now, we know that

fB(d_k) = e_k+1 - e_k from the first of the 3 systems above, and -fB(d_k) = e_k + d_k+1 - d_k from the 2nd.

Add to obtain: e_k+1 = d_k - d_k+1, or

e_k = d_k-1 - d_k.

Now we just substitute this expression for e_k into our e/d recurrences to obtain our final recurrence in d only:

d_k+1 - (2 - Bf)(d_k + d_k-1 = 0

Setting up the corresponding characteristic equation and applying the quadratic formula tells us that the roots (r_1, r_2) are:

((2 - fB) +/- sqrt( (fB - 2)^2 -4 ))/2

The nature of these roots depends on whether the above discriminant is negative, zero, or positive. We can break into each of the 3 cases, and then plug back into our expressions for S_k and D_k to see how the different types of solutions describe different types of systems.