-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathTuesday Feb 17 2015.py
More file actions
109 lines (64 loc) · 1.13 KB
/
Tuesday Feb 17 2015.py
File metadata and controls
109 lines (64 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
# -*- coding: utf-8 -*-
# <nbformat>3.0</nbformat>
# <codecell>
from science import *
# <codecell>
pwd
# <codecell>
data=pandas.read_excel('data/s009.xls',skiprows=[0,1])
# <codecell>
data
# <codecell>
t_data=data['day']
y_data=data['height (cm)']
plot(t_data,y_data,'o')
# <markdowncell>
# ## Linear growth example
#
# $y' = {\rm constant}$
# <codecell>
y=2
t=0
constant=10
dt=0.01
# <codecell>
reset()
store(t,y)
for i in range(9000):
dy=constant*dt
y=y+dy
t=t+dt
if i%100 == 0 : # if the remainder with i/100 = 0 (i.e. i is divisible by 100)
store(t,y)
# <codecell>
t,y=recall()
# <codecell>
plot(t,y)
plot(t_data,y_data,'o')
# <markdowncell>
# ## Exponential Growth
#
# $y'=my$ where $m$ is a growth constant
# <codecell>
y=.1
t=0
constant=.2
dt=0.01
# <codecell>
reset()
store(t,y)
for i in range(4000):
dy=constant*y*dt
y=y+dy
t=t+dt
if i%100 == 0 : # if the remainder with i/100 = 0 (i.e. i is divisible by 100)
store(t,y)
# <codecell>
t,y=recall()
# <codecell>
plot(t,y)
plot(t_data,y_data,'o')
# <codecell>
y
# <codecell>
# <codecell>