Ticket #10983: sol_graphiques_2_fixed.py

File sol_graphiques_2_fixed.py, 802 bytes (added by casamayou, 6 years ago)
Line 
1r"""
2sage: import scipy
3sage: from scipy import integrate
4sage: t = srange(0, 40, 0.1)
5sage: n = 35
6sage: CI_cart = [[4, .2 * i] for i in range(n)]
7sage: CI = map(lambda x:[sqrt(x[0]**2+x[1]**2),\
8...        pi - arctan(x[1] / x[0])], CI_cart)
9sage: alpha = [0.1, 0.5, 1, 1.25]
10sage: for a in alpha:                                      # long time
11...       dX_dt = lambda X, t=0: [cos(X[1])*(1-1/X[0]^2), \
12...               -sin(X[1]) * (1/X[0]+1/X[0]^3) + 2*a/X[0]^2]
13...       q = circle((0, 0), 1, fill=True, rgbcolor='purple')
14...       for j in range(n):
15...           X = integrate.odeint(dX_dt, CI[j], t)
16...           Y = [[u[0] * cos(u[1]), u[0] * sin(u[1])] for u in X]
17...           q += line(Y, xmin = -4, xmax = 4, color='blue')
18...       q.show(aspect_ratio = 1, axes = False)
19...
20"""