sage: def get_vals(y0,t0,tmax,deltat): ....: soln = {t0:y0} ....: y = y0 ....: t = t0 ....: while t < tmax: ....: dydt = F(y,t) ....: new_y = y + dydt * deltat ....: new_t = t + deltat ....: y = new_y ....: t = new_t ....: soln[t] = y ....: return soln ....: sage: def F(y,t): ....: return t*y**2 / (t**4 + 1) ....: sage: sumval = 0 sage: for i in range(10**5): ....: sumval += i ....: sage: for i in range(10**7): ....: sumval += i ....: sage: for i in range(10**9): ....: sumval += i ....: sage: soln = get_vals(1, 0, 10, 0.001) sage: sorted(list(soln.items()))[:10] [(0, 1), (0.00100000000000000, 1.00000000000000), (0.00200000000000000, 1.00000100000000), (0.00300000000000000, 1.00000300000400), (0.00400000000000000, 1.00000600002200), (0.00500000000000000, 1.00001000007000), (0.00600000000000000, 1.00001500017000), (0.00700000000000000, 1.00002100034999), (0.00800000000000000, 1.00002800064398), (0.00900000000000000, 1.00003600109197)] sage: points(soln.items(), dpi=400, size=1) Launched png viewer for Graphics object consisting of 1 graphics primitive sage: soln_dict = {} sage: y0vals = [1 + i*0.1 for i in range(int(9/0.1))] sage: len(y0vals) 90 sage: soln_dict = {y0: get_vals(y0,0,10,0.001) for y0 in y0vals} sage: show(sum([points([(k,v) for k,v in tmp.items() if abs(v) >= 0], dpi=400, size=1, color=hue(float(3*i)/len(soln_dict))) for i,tmp in enumerate(list(soln_dict.values()))])) /home/blatm/sage/sage-10.1/src/sage/repl/rich_output/display_manager.py:612: RichReprWarning: Exception in _rich_repr_ while displaying object: Axis limits cannot be NaN or Inf warnings.warn( Graphics object consisting of 90 graphics primitives sage: show(sum([points([(k,v) for k,v in tmp.items() if (k in RR) and (v in RR)], dpi=400, size=1, color=hue(float(3*i)/len(soln_dict))) for i,tmp in enumerate(list(soln_dict.values()))])) /home/blatm/sage/sage-10.1/src/sage/repl/rich_output/display_manager.py:612: RichReprWarning: Exception in _rich_repr_ while displaying object: Axis limits cannot be NaN or Inf warnings.warn( Graphics object consisting of 90 graphics primitives sage: show(sum([points([(k,v) for k,v in tmp.items() if (k in RR) and (v in RR) and abs(v) < 100], dpi=400, size=1, color=hue(float(3*i)/len(soln_dict))) for i,tmp in enumerate(list(soln_dict.values()))])) Launched png viewer for Graphics object consisting of 90 graphics primitives sage: def F(y,t): ....: return t*cos(y**2) / (t**4 + y) ....: sage: time soln_dict = {y0: get_vals(y0,0,10,0.001) for y0 in y0vals} CPU times: user 4.37 s, sys: 54 ms, total: 4.42 s Wall time: 4.42 s sage: show(sum([points([(k,v) for k,v in tmp.items() if (k in RR) and (v in RR) and abs(v) < 100], dpi=400, size=1, color=hue(float(3*i)/len(soln_dict))) for i,tmp in enumerate(list(soln_dict.values()))])) Launched png viewer for Graphics object consisting of 90 graphics primitives sage: sage: y0vals = [-4.5 + i*0.1 for i in range(int(9/0.1))] sage: time soln_dict = {y0: get_vals(y0,0,10,0.001) for y0 in y0vals} CPU times: user 4.18 s, sys: 62 ms, total: 4.24 s Wall time: 4.24 s sage: show(sum([points([(k,v) for k,v in tmp.items() if (k in RR) and (v in RR) and abs(v) < 100], dpi=400, size=1, color=hue(float(3*i)/len(soln_dict))) for i,tmp in enumerate(list(soln_dict.values()))])) Launched png viewer for Graphics object consisting of 90 graphics primitives sage: time soln_dict = {y0: get_vals(y0,0,10,0.0001) for y0 in y0vals} CPU times: user 38.8 s, sys: 1.13 s, total: 39.9 s Wall time: 39.9 s sage: show(sum([points([(k,v) for k,v in tmp.items() if (k in RR) and (v in RR) and abs(v) < 100], dpi=400, size=1, color=hue(float(3*i)/len(soln_dict))) for i,tmp in enumerate(list(soln_dict.values()))])) Launched png viewer for Graphics object consisting of 90 graphics primitives sage: