# Lab 5: Using Poincare Plots and Linear Algebra Part I # Name: Dean Neutel # I worked on this code with: Han Wang # Please do all of your work for this week's lab in this worksheet. If # you wish to create other worksheets for scratch work, you can, but # this is the one that will be graded. You do not need to do anything # to turn in your lab. It will be collected by your TA at the beginning # of (or right before) next week’s lab. # Be sure to put each exercise in a new cell with an exercise number at the top. # Use enough comments that you and the grader can understand your code. # Label axes on all graphs.

#1 Data1 = [1,24,339,42,449,11,183,236,138,351,37,424,15,237,136,354,35,416,16,255,112,420,15,246,124,388,23,327,49,471,8,144,334,45,460,9,163,285,80,484,7,123,390,23,324,51,476,8,137,354,35,417,16,253,114,415,17,260,106,434,13,214,174,258,108,429,14,226,153,310,60,490,6,116,409,18,273,92,466,9,153,311,59,489,6,117,407,18,278,86,475,8,137,352,36,422,15,241,131,370,29,376,27,360,33,402,20,293,73,491,6,115,412,17,266,99,450,11,181,241,131,369,29,379,26,352,36,422,15,241,131,370,29,377,26,357,34,409,18,274,90,468,8,148,322,52,478,7,132,365,31,390,23,324,50,476,8,137,353,35,418,16,252,116,409,18,273,91,467,9,151,316,56,485,7,123,392,22,319,54,482,7,127,380,26,351,36,424,15,238,135,358,34,408,18,277,87,474,8,139] Data2 = [172,295,338,174,46,223,490,114,111,359,43,478,203,146,115,422,276,477,381,451,375,212,257,394,359,173,327,474,373,368,303,353,106,121,184,180,58,467,467,476,62,261,57,96,384,484,78,172,57,125,306,314,67,444,42,284,363,256,332,238,24,194,42,453,403,396,286,132,299,364,135,296,421,336,334,343,56,349,242,203,389,399,489,283,42,55,173,355,269,492,52,435,316,213,166,408,291,95,41,277,105,111,189,386,333,95,63,461,84,141,317,118,85,71,81,320,158,325,286,225,128,155,48,44,462,47,481,451,136,28,475,79,131,312,128,6,137,325,276,159,27,187,192,448,276,260,310,239,500,7,300,142,177,140,7,57,19,275,456,137,222,206,170,56,225,322,477,7,116,420,93,119,431,400,171,124,77,325,115,198,436,126,45,167,242,239,5,201,343,490,211,324,254,88,343,263,350,306,377,310]

#2 list_plot(zip(srange(0,200,1),Data1),plotjoined=True,axes_labels=("Time Intervals","Data1"))

#For this time series, we see a very random and aperiodic graph in which there doesn't seem to be much order. We can't tell if this chaotic or random since the data here is a time series. We would have to convert this data to a Poincare plot in order to see if the system truely is chaotic.

#3 list_plot(zip(srange(0,200,1),Data2),plotjoined=True,axes_labels=("Time Intervals","Data2"))

#Again, for this time series, we see a very random and aperiodic graph in which there doesn't seem to be much order, in fact it is even more disordered in this graph than the last one. However, we still can't tell if this chaotic or random since the data here is a time series. We would have to convert this data to a Poincare plot in order to see if the system truely is chaotic.

#4 Poincare = [] for i in srange(0,len(Data1)-1): a = Data1[i+1] Poincare.append(a) list_plot(zip(Data1,Poincare), axes_labels=("Xn","Xn+1"))

#Since this plot displays an ordered form, this system isn't random.

#5 Poincare = [] for i in srange(0,len(Data2)-1): a = Data2[i+1] Poincare.append(a) list_plot(zip(Data2,Poincare), axes_labels=("Xn","Xn+1"))

#Since this graph displays a cloud of points that have no visible form, this plot depitcs random or chaotic behavior.

#6 var("Xn") r=3 k=200 X_new = Xn*(e^(r*((1-Xn)/k))) plot(X_new, (x,0,500), axes_labels=("Xn", "Xn+1"))

Xn

#This plot looks similar to the Poincare plot of Data1. This is in agreement with problem 4 and 5 since it shows us that Data1 wasn't random but came from the Ricker model and that Data2 is random since it just came from a random number generator.

#Linear Algebra Section #1 vector([3,10])

(3, 10)

#2 v = vector([-2,7,5])

type(v)

<type 'sage.modules.vector_integer_dense.Vector_integer_dense'>

#3 a = vector([4,2]) b = vector([-1,5]) a+b #1 6*a #2 (4*a)+(3*b) #3 -b #4 (-a)+b #5 pi*a #6

(3, 7)
(24, 12)
(13, 23)
(1, -5)
(-5, 3)
(4*pi, 2*pi)

#4 plot(vector([1,2,4]), thickness=4, axes_labels=("x", "y","z"))

3D rendering not yet implemented

#5 plot(a, thickness=4)+plot(b, thickness=4, color="red")+plot(a+b, thickness=4, color="turquoise") plot(a, thickness=4)+plot(b, thickness=4, color="red")+plot(6*a, thickness=4, color="turquoise") plot(a, thickness=4)+plot(b, thickness=4, color="red")+plot((4*a)+(3*b), thickness=4, color="turquoise") plot(a, thickness=4)+plot(b, thickness=4, color="red")+plot(-b, thickness=4, color="turquoise") plot(a, thickness=4)+plot(b, thickness=4, color="red")+plot((-a)+b, thickness=4, color="turquoise") plot(a, thickness=4)+plot(b, thickness=4, color="red")+plot(pi*a, thickness=4, color="turquoise")

#6 def Test_Function(function): var("a") f = function if f(a*x) == a*f(x) and f(x+a) == f(x) + f(a): print "Linear Function" else: print "Not Linear Function"

#7 def Test_Function(function): var("a") f = function if f(a*x) == a*f(x) and f(x+a) == f(x) + f(a): print "Linear Function" else: print "Not Linear Function" Test_Function(2*x);Test_Function(x^2);Test_Function(1/x)

Linear Function
Not Linear Function
Not Linear Function

#8 def Component(v): l1 = [4*v[0]+2*v[1], 3*v[0]+v[1]] v1 = vector(l1) return(v1) Component(vector([1,2]))

(8, 5)

#9 def Linear(v): linear = 3*v return(plot(linear)+plot(v, color="orange")) Linear(vector([2,3]));Linear(vector([4,5]));Linear(vector([-1,1]))

#10 def Linear(v): linear = 3*v v1 = vector(linear) return(v1) Linear(vector([2,3,1]));Linear(vector([4,5,0]));Linear(vector([-1,1,5]))

(6, 9, 3)
(12, 15, 0)
(-3, 3, 15)

#11 def Black_Bear(v): l1 = [0.57*v[0]+0.5025*v[1], 0.33*v[0]+0.917*v[1]] v_new = vector(l1) return(v_new)

#12 def Black_Bear(v): l1 = [0.57*v[0]+0.5025*v[1], 0.33*v[0]+0.917*v[1]] v_new = vector(l1) return(v_new) Black_Bear(vector([13,20]))

(17.4600000000000, 22.6300000000000)

#13 def Black_Bear(v): l1 = [0.57*v[0]+0.5025*v[1], 0.33*v[0]+0.917*v[1]] v_new = vector(l1) return(plot(v_new, aspect_ratio=1, axes_labels=("Juveniles", "Adults"))+plot(v, color="red", aspect_ratio=1)) Black_Bear(vector([1,0]));Black_Bear(vector([0,1]))

#14 a = 13*vector([1,0]) b = 20*vector([0,1]) plot(a, aspect_ratio=1, axes_labels=("x", "y"))+plot(vector([1,0]),color="red") plot(b, aspect_ratio=1, axes_labels=("x", "y"))+plot(vector([0,1]),color="red")

#15 a = 13*vector([2,3]) b = 20*vector([1,1]) plot(a, aspect_ratio=1, axes_labels=("x", "y"))+plot(vector([1,0]), aspect_ratio=1, color="red") plot(b, aspect_ratio=1, axes_labels=("x", "y"))+plot(vector([0,1]), aspect_ratio=1, color="red")

#16 a = 3*vector([2,3]) b = -2*vector([1,1]) plot(a, aspect_ratio=1, axes_labels=("x", "y"))+plot(vector([1,0]), aspect_ratio=1, color="red") plot(b, aspect_ratio=1, axes_labels=("x", "y"))+plot(vector([0,1]), aspect_ratio=1, color="red")

#17 def Black_Bear(v): l1 = [0.57*v[0]+0.5025*v[1], 0.33*v[0]+0.917*v[1]] v1 = vector(l1) return(v1) c = Black_Bear(vector([1,0])) d = Black_Bear(vector([0,1]))

#18 v1 = c v2 = d m = column_matrix([v1,v2]) m

[0.570000000000000 0.502500000000000]
[0.330000000000000 0.917000000000000]