2013-04-10 16:57:12 -07:00
|
|
|
def euler(f,y0,a,b,h):
|
|
|
|
|
t,y = a,y0
|
2015-11-18 06:14:39 +00:00
|
|
|
while t <= b:
|
2013-04-10 16:57:12 -07:00
|
|
|
print "%6.3f %6.3f" % (t,y)
|
|
|
|
|
t += h
|
|
|
|
|
y += h * f(t,y)
|
|
|
|
|
|
|
|
|
|
def newtoncooling(time, temp):
|
|
|
|
|
return -0.07 * (temp - 20)
|
|
|
|
|
|
|
|
|
|
euler(newtoncooling,100,0,100,10)
|