Ticket #10983: graphique_2_fixed.py

File graphique_2_fixed.py, 1.8 KB (added by casamayou, 6 years ago)
Line 
1r"""
2sage: g = bar_chart([randrange(15) for i in range(20)], color='red')
3sage: g = bar_chart([x^2 for x in range(1,20)], width=0.2)
4sage: liste = [10 + floor(10*sin(i)) for i in range(100)]
5sage: g = bar_chart(liste)
6sage: g = finance.TimeSeries(liste).plot_histogram(bins=20)
7"""
8
9r"""
10sage: from random import *
11sage: n, l, x, y = 10000, 1, 0, 0; p = [[0, 0]]
12sage: for k in range(n):
13...    theta = (2 * pi * random()).n(digits=5)
14...    x, y = x + l * cos(theta), y + l * sin(theta)
15...    p.append([x, y])
16sage: g1 = line([p[n], [0, 0]], color='red', thickness=2)
17sage: g1 += line(p, thickness=.4); # g1.show(aspect_ratio=1)
18"""
19
20r"""
21sage: length = 200; n = var('n')
22sage: u(n) = n * sqrt(2)
23sage: z(n) = exp(2 * I * pi * u(n))
24sage: vertices = [CC(0, 0)]
25sage: for n in range(1, length):
26...    vertices.append(vertices[n - 1] + CC(z(n)))
27sage: g = line(vertices); # g.show(aspect_ratio=1)
28"""
29
30r"""
31sage: x = var('x'); y = function('y',x)
32sage: DE = x*diff(y, x) == 2*y + x^3
33sage: desolve(DE, [y,x])
34(c + x)*x^2
35sage: sol = []
36sage: for i in srange(-2, 2, 0.2):
37...    sol.append(desolve(DE, [y, x], ics=[1, i]))
38...    sol.append(desolve(DE, [y, x], ics=[-1, i]))
39sage: g = plot(sol, x, -2, 2)
40sage: y = var('y')
41sage: g += plot_vector_field((x, 2*y+x^3), (x, -2, 2), (y, -1, 1))
42sage: # g.show(ymin=-1, ymax=1)
43"""
44
45r"""
46sage: x = var('x'); y = function('y',x)
47sage: DE = x*diff(y, x) == 2*y + x^3
48sage: g = Graphics()
49sage: for i in srange(-1, 1, 0.1):
50...       g += line(desolve_rk4(DE, y, ics=[1, i],\
51...                         step=0.05, end_points=[0,2]))
52...       g += line(desolve_rk4(DE, y, ics=[-1, i],\
53...                         step=0.05, end_points=[-2,0]))
54sage: y = var('y')
55sage: g = plot_vector_field((x, 2*y + x^3), (x,-2,2), (y,-1,1))
56sage: # g.show(ymin=-1, ymax=1)
57"""