Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Project: LS 30A-1 W19
Views: 443

Homework Problems

Extra Exercise 1.4.9

The pier in Santa Monica, CA, is a popular destination for both tourists and locals. Visitors ride the Ferris wheel (F), eat ice cream (C), or just walk around on the pier(W). Write a dynamical model for the numbers of people engaged in these activities given the following assumptions. (Hint: Start by drawing a diagram of this system and labeling the stocks and flows.)

  • People entering the pier always start by just walking around.

  • E people enter the pier each minute.

  • Visitors leave at a constant per capita rate d. They can leave only when they are walking around.

  • Due to fear of nausea, people do not go directly from eating ice cream to riding the Ferris wheel.

  • Visitors prefer to go on the Ferris wheel with friends. Thus, the probability that any one individual will go on the Ferris wheel is proportional to the number of people walking around, with proportionality constant b.

  • Riders leave the Ferris wheel at per capita rate n.

  • When visitors leave the Ferris wheel, a fraction z of them go directly to eating ice cream. The others walk around.

  • Visitors who are walking around prefer to avoid long lines for ice cream. Thus, the per capita rate at which they get ice cream is proportional to the inverse of the number of people already doing so, with proportionality constant m.

  • People who are eating ice cream stop doing so at a constant per capita rate k.

Review Terminology

Review

List

Plot and List_plot

listVar = [] listVar.append(1) listVar.append(2) listVar.append(3) listVar
[1, 2, 3]
p = list_plot(listVar,plotjoined=True) show(p)

If we have our own x axis data

xData= [2,1,3] newList= zip(xData,listVar) p = list_plot(newList,plotjoined=True) show(p)

Euler's Method

What it is?

How to do this in SAGE?

We need:

  • Initial point

  • How it changes

Get:

  • Next point

(This is not the real code, it just illustrate the idea)

f(x) = X' x_0 = 'start point/ initial point or value'

We have to simulate how x changes!!!

delta_x_0 = f(x_0)*step_size x_1 = x_0+delta_x_0

Only one time?

for i in srange('How many time I want to do it'): x_new = x_old+delta_x_old

How to storage it?

Append it to a list!

xData.append(x_new)

Put comment in your code if it is more than 4 lines long!!

xData=[5] vData=[0] tData=[0] k = 5 m=5 k_f=1 v_prime(x,v)=-k/m*x-k_f/m*v total_time=100 step_size=0.01 for i in range(total_time/step_size+1): delta_x = vData[i]*step_size delta_v = v_prime(xData[i],vData[i])*step_size xData.append(xData[i]+delta_x) vData.append(vData[i]+delta_v) tData.append(tData[i]+step_size) xPlot = list_plot(zip(tData,xData),axes_labels=['time (sec)','position(m)']) show(xPlot) vPlot = list_plot(zip(tData,vData),axes_labels=['time (sec)','velcity(m/s)']) show(vPlot)