CoCalc Public Filestmp / 2017-02-08-225525.sagewsOpen in with one click!
Author: William A. Stein
############################## # Import the method from sage.calculus.desolvers import eulers_method # What are our variables x,y = PolynomialRing(RR,2,"xy").gens() # And run the method. Here is where you can play with the parameters. f = 5*x+y-5 x0=0 y0=1 h=0.5 xlast=3 eulers_method(f,x0,y0,h,xlast); ##############################
x y h*f(x,y) 0 1 -2.00000000000000 0.500000000000000 -1.00000000000000 -1.75000000000000 1.00000000000000 -2.75000000000000 -1.37500000000000 1.50000000000000 -4.12500000000000 -0.812500000000000 2.00000000000000 -4.93750000000000 0.0312500000000000 2.50000000000000 -4.90625000000000 1.29687500000000 3.00000000000000 -3.60937500000000 3.19531250000000
2+3
5
%time 2 + 3
5 CPU time: 0.00 s, Wall time: 0.00 s
%time plot(sin)
CPU time: 1.04 s, Wall time: 1.07 s
%timeit plot(sin)
125 loops, best of 3: 1.8 ms per loop
%timeit 2+3
625 loops, best of 3: 299 ns per loop