Ticket #10983: sol_graphiques_2.py

File sol_graphiques_2.py, 804 bytes (added by casamayou, 5 years ago)

updated file

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