# 213 - A6 - Linear Dynamical System

## 358 days ago by Professor213

This worksheet allows the user to input a transition matrix and initial vector and then iterate for any desired number of time steps.

John Travis

Mississippi College

%hide %auto N=2 print pretty_print(html("<font size=+2 color=blue>Enter N below. Click Update when you are finished.</font>")) @interact def _(Size_of_System=[2..10],update=false): global N N = Size_of_System pretty_print(html("<font size=+2 color=blue>The size of your square system will be "+str(N)+"$\\times$"+str(N)+"</font>")) pretty_print(html("<font size=+2 color=blue>Evaluate the cell below and enter the system data.</font>"))

Enter N below. Click Update when you are finished. None
 Size_of_System 2 3 4 5 6 7 8 9 10 update

## Click to the left again to hide and once more to show the dynamic interactive window

%hide %auto print pretty_print(html("<font size=+2 color=blue>Enter the transition matrix for your dynamical system and the starting state below.<p> You can tab to navigate between cells. Click Update when you are finished.</font><p>")) @interact def _(Transition_Matrix=zero_matrix(QQ,N,N),Initial_State=zero_matrix(QQ,N,1),auto_update=False): global A global b A = Transition_Matrix b = Initial_State

Enter the transition matrix for your dynamical system and the starting state below.

You can tab to navigate between cells. Click Update when you are finished.

None

Transition_Matrix
Initial_State

## Click to the left again to hide and once more to show the dynamic interactive window

%auto print 'Using the data' show(A) b0 = copy(b) show(b0)
 Using the data  Using the data 

Assignment: For a given dynamical systems problem (should be stated here):

• Perform one step below to make certain your dynamical system is working properly
• Perform a small number of steps (say 5-10) and notice any drastic changes in any of the various populations
• Perform a large number of steps and notice whether the populations tend to stabilize about a given value.
• Write up your results in a text cell below. Be certain to cut-and-paste the transition matrix and initial values into another cell for me to see what you used. A copy is output below the interactive cell below for you to grab and save.
 [97/100 1/20 1/10] [ 0 9/10 1/20] [ 3/100 1/20 17/20] [97/100 1/20 1/10] [ 0 9/10 1/20] [ 3/100 1/20 17/20]
%auto @interact def _(steps = slider(1,100,1,1)): global A,b b = copy(b0) terms = range(b.nrows()) colors = rainbow(b.nrows()) P = Graphics() for term in terms: P += point2d((0,b[1][0]),color=colors[term]) for k in range(steps): b = A*b for term in terms: P += point2d((k,b[term][0]),color=colors[term],size=30) show(P) print pretty_print(html('Final values:\n'),b.n())

steps

## Click to the left again to hide and once more to show the dynamic interactive window

%auto show(A) show(b0) show(b)
 Traceback (click to the left of this block for traceback) ... NameError: name 'A' is not defined Traceback (most recent call last): File "", line 1, in File "_sage_input_7.py", line 10, in exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" + _support_.preparse_worksheet_cell(base64.b64decode("c2hvdyhBKQpzaG93KGIwKQpzaG93KGIp"),globals())+"\\n"); execfile(os.path.abspath("___code___.py")) File "", line 1, in File "/tmp/tmpDIByEg/___code___.py", line 2, in show(A) NameError: name 'A' is not defined