Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download

All published worksheets from http://sagenb.org

Views: 168754
Image: ubuntu2004
# # Euler's method # from pylab import * # time step h = 0.05 # initial condition x0 = 2.0 y0 = 4.0 # final point xn = 2.5 # function (DE) def fn(x, y): return 0.1 * sqrt(y) + 0.4 * x * x; # algorithm y = y0 print "xn yn" for x in arange(x0,xn+(h/2),h): print "%.2lf" % x, "%.4lf" % y y = y + h * fn(x, y)
xn yn 2.00 4.0000 2.05 4.0900 2.10 4.1842 2.15 4.2826 2.20 4.3854 2.25 4.4927 2.30 4.6045 2.35 4.7210 2.40 4.8423 2.45 4.9686 2.50 5.0997