2023-07-01 11:58:00 -04:00
|
|
|
def euler(f,y0,a,b,h):
|
2026-02-01 16:33:20 -08:00
|
|
|
t,y = a,y0
|
|
|
|
|
while t <= b:
|
|
|
|
|
print "%6.3f %6.3f" % (t,y)
|
|
|
|
|
t += h
|
|
|
|
|
y += h * f(t,y)
|
2023-07-01 11:58:00 -04:00
|
|
|
|
|
|
|
|
def newtoncooling(time, temp):
|
2026-02-01 16:33:20 -08:00
|
|
|
return -0.07 * (temp - 20)
|
2023-07-01 11:58:00 -04:00
|
|
|
|
|
|
|
|
euler(newtoncooling,100,0,100,10)
|