5
MAT 202, Lab #7, Summer 2016 Name _____________________________________________ Directions: The labs for this course will require the use of MatLab. Instructions on how to access MatLab can be found under a separate document posted in the course. Use the listed example code to complete the following exercises. Print the resulting MatLab worksheet. Circle and number the solutions to the problems on the printout. Or, copy and paste the contents of the MatLab worksheet into a file, note the problem numbers in the code, to submit the problems electronically. Example Code File: 202lab_ex7.pdf In this lab we will look at several applications of linear algebra involving eigenvalues and eigenvectors. We start with a discrete dynamical system given by x n+1 = [ .2 .5 .5 1.3 ] x n . This system models the interaction of two populations (a predator population and a prey population) over time in discrete time steps. We will start with an initial population of x 0 = [ 20 5 ] . The code enters the matrix and the initial state vector into memory, and then computes several values of the system as time passes. After calculating a series of values, the population values are collected in a matrix and plotted as two separate lines on a graph. This kind of graph has it’s advantages and disadvantages. If one calculates enough of these values, it’s possible to see how the populations stabilize over time (if that’s what they do), but the horizontal axis represents the columns of the population model matrix. Initially, this is off of our state vectors by one, but when we start skipping steps, jumping to n=10 or n=20, the graph does not display that leap.

betsymccall.netbetsymccall.net/prof/courses/summer16/aacc/202lab7.docx · Web viewIn this lab we will look at several applications of linear algebra involving eigenvalues and eigenvectors

  • Upload
    others

  • View
    0

  • Download
    0

Embed Size (px)

Citation preview

Page 1: betsymccall.netbetsymccall.net/prof/courses/summer16/aacc/202lab7.docx · Web viewIn this lab we will look at several applications of linear algebra involving eigenvalues and eigenvectors

MAT 202, Lab #7, Summer 2016 Name _____________________________________________

Directions: The labs for this course will require the use of MatLab. Instructions on how to access MatLab can be found under a separate document posted in the course. Use the listed example code to complete the following exercises. Print the resulting MatLab worksheet. Circle and number the solutions to the problems on the printout. Or, copy and paste the contents of the MatLab worksheet into a file, note the problem numbers in the code, to submit the problems electronically.

Example Code File: 202lab_ex7.pdf

In this lab we will look at several applications of linear algebra involving eigenvalues and eigenvectors.

We start with a discrete dynamical system given by x⃗n+1=[ .2 .5−.5 1.3 ] x⃗n. This system models the

interaction of two populations (a predator population and a prey population) over time in discrete time

steps. We will start with an initial population of x⃗0=[205 ].The code enters the matrix and the initial state vector into memory, and then computes several values of the system as time passes.

After calculating a series of values, the population values are collected in a matrix and plotted as two separate lines on a graph. This kind of graph has it’s advantages and disadvantages. If one calculates enough of these values, it’s possible to see how the populations stabilize over time (if that’s what they do), but the horizontal axis represents the columns of the population model matrix. Initially, this is off of our state vectors by one, but when we start skipping steps, jumping to n=10 or n=20, the graph does not display that leap.

Alternatively, we can plot these population values against each other. The code shows you how to pull out the first row of the population matrix for the x-values and the second row for the y-values, and then plot the resulting pairs of points.

This the sort of graph we would expect to obtain if we plotted graphs of trajectories using eigenvalues and eigenvectors.

To add the eigenvalues and eigenvectors to the graph, we first solve for these values as we did in the last lab.

Then we use that information to find equations of the lines for

the eigenvectors. Recall the if a vector is given by u⃗=[ab], then the slope of the line defined by the

vector is m=ba . Our eigenvectors go through the origin, so the equation of the lines we need is of the

Page 2: betsymccall.netbetsymccall.net/prof/courses/summer16/aacc/202lab7.docx · Web viewIn this lab we will look at several applications of linear algebra involving eigenvalues and eigenvectors

form y=bax. We will use the eigenvectors to find these lines. The sample code provides instructions of

how to graph the equations.After adding the lines representing the eigenvectors, we can see how the population over time falls into the path of the eigenvector. The point where the two new lines cross is the origin. In this example, the origin is attracting the population.

The second version of the plotting commands show you how to change the color of the lines to make it easier to see the population path vs. the eigenvalues and eigenvectors.

1. For each of the dynamical systems below, calculate 10-15 steps of the population (they need not be consecutive) and plot the population on each of the graph types as shown. On the second graph, be sure to add the eigenvalues and eigenvectors to the graph. Determine from the eigenvalues whether the origin attracts, repels or is a saddle point. Does your graph support your conclusion? If no initial population is selected, choose your own.

a. A=[1.71 −0.7071 0 ] , x⃗0=[1113]

b.

c.

A special type of discrete dynamical system is a stochastic matrix, also known as a Markov chain.

2. Follow the steps above for the Markov chain defined by P=[ .99 .08.01 .92]. Confirm your results

with the process described below.

Markov chains can be solved through the eigenvalue and eigenvector process since they are a type of discrete dynamical system (with one eigenvalue equal to one), but, because they are a special, they can be solved by other means. The code shows an example of the numerical approach. Raise the matrix to a large power until all the columns of the matrix are identical. This represents the equilibrium vector, and should be a scalar multiple of the eigenvector associated with λ=1.

3. For each stochastic matrix below, find the equilibrium vector. Discuss the communication between states in the system.

a. P=[ .9 .002 .12.099 .95 .004.001 .048 .876]

Page 3: betsymccall.netbetsymccall.net/prof/courses/summer16/aacc/202lab7.docx · Web viewIn this lab we will look at several applications of linear algebra involving eigenvalues and eigenvectors

b. P=[ .7 00 .5

0 .4.2 0

0 .5.3 0

.8 00 .6 ]

c. P=[ .7 0.2 .5

0 .4.1 0

0 .5.1 0

.1 0

.8 .6 ]d. P=[ .36 .09

.2 .50 .4.2 .13

.25 .4

.19 .01.8 00 .47 ]

The code first declares variables x , y , x1 , x2 , t , λ , L.

Suppose that we would like to solve the system x⃗ '=(1 26 5) x⃗, we can follow the methods of lab #9 to

find the eigenvalues of the system and write the solution. We obtain the solution

x⃗ (t )=(x1x2)=c1( 1−1)e−t+c2(13)e7 t. Here, I have used constant multiples of vectors in the code to

eliminate fractions and leading negatives to make them easier to work with.

As discussed in class, we need to perform some algebra on complex solutions to obtain solutions that are only real expressions.

To obtain solutions for repeated eigenvalues, the code first calculates the single eigenvector, and then

obtains the vector η needed for the second solution for the system x⃗ '=(3 −41 −1) x⃗ .

This code results in the solution x⃗ (t )=c1(21)e t+c2[(21) t e t+(10)e t]. The solution is not unique, and

multiples will also satisfy.

We can also use dsolve to solve systems, with or without initial conditions.

We would also like to be able to plot trajectories of systems and observe the behavior for multiple sets

of initial conditions. The code then goes through some examples for x⃗ '=(−3 2−1 0) x⃗ , x⃗ (0 )=(10), and for

x⃗ '=( 1 −2−1 0 ) x⃗ , x⃗ (0 )=(ab), and x⃗ '=( 1 2

−1 0) x⃗ , x⃗ (0 )=(a0). These yield the following graphs.

Page 4: betsymccall.netbetsymccall.net/prof/courses/summer16/aacc/202lab7.docx · Web viewIn this lab we will look at several applications of linear algebra involving eigenvalues and eigenvectors

4. Use these models to solve the following systems. For the second order systems, you’ll need to convert them to first order systems, and then pull out the solutions to the two original variables and proceed from there to construct graphs. For each problem, find the general solution, and plot sample trajectories if unknowns are used as initial conditions, or if the initial condition is known, just the particular solution.

a. x⃗ '=(1 23 2) x⃗ , x⃗ (0 )=(ab)

b. x⃗ '=( 4 7−2 −5) x⃗ , x⃗ (0 )=(ab)

c. x⃗ '=( 2 0−1 −5) x⃗ , x⃗ (0 )=(61)

d. x⃗ '=[2 −13 −2] x⃗ , x⃗ (0)=[ab]

e. x⃗ '=[ 4 −38 −6] x⃗ , x⃗ (0 )=[ 2−5]

Collect all your graphs and code, along with any answers to other questions into a single Word or pdf file for submission. Do no submit matlab files.