1# -*- coding: utf-8 -*- 2""" 3Created on Tue Apr 21 18:40:47 2015 4 5@author: Roger 6""" 7 8 9 10 11def dx(t, y): 12 return y 13 14 15def euler(t0, tmax, y0, dx, step=1.): 16 t = t0 17 y = y0 18 while t < tmax: 19 f = dx(t,y) 20 y = y + step*dx(t, y) 21 t +=step 22 23 return y 24 25 26print(euler(0, 4, 1, dx, step=0.25)) 27