Ticket #10983: graphique_1.py

File graphique_1.py, 1.9 KB (added by casamayou, 6 years ago)

updated file

Line 
1r"""
2
3sage: g = plot(x * sin(1/x), x, -2, 2, plot_points=500)
4sage: def p(x, n): return(taylor(sin(x), x, 0, n))
5sage: xmax = 15 ; n = 15
6sage: g = plot(sin(x), x, -xmax, xmax)
7sage: for d in range(n):
8...     g += plot(p(x, 2 * d + 1), x, -xmax, xmax,\
9...       color=(1.7*d/(2*n), 1.5*d/(2*n), 1-3*d/(4*n)))
10sage: # g.show(ymin=-2, ymax=2)
11
12"""
13
14
15r"""
16
17sage: a = animate([[sin(x), taylor(sin(x), x, 0, 2*k+1)]\
18...          for k in range(0, 14)], xmin=-14, xmax=14,\
19...          ymin=-3, ymax=3, figsize=[8, 4])
20sage: # a.show()
21
22"""
23
24
25r"""
26
27sage: f2(x) = 1; f1(x) = -1
28sage: f = Piecewise([[(-pi,0),f1],[(0,pi),f2]])
29sage: S = f.fourier_series_partial_sum(20,pi); S
304/3*sin(3*x)/pi + 4/5*sin(5*x)/pi + 4/7*sin(7*x)/pi + 4/9*sin(9*x)/pi + 4/11*sin(11*x)/pi + 4/13*sin(13*x)/pi + 4/15*sin(15*x)/pi + 4/17*sin(17*x)/pi + 4/19*sin(19*x)/pi + 4*sin(x)/pi
31sage: g = plot(S, x, -8, 8, color='blue')
32sage: scie(x) = x - 2 * pi * floor((x + pi) / (2 * pi))
33sage: g += plot(scie(x) / abs(scie(x)), x, -8, 8, color='red')
34
35"""
36
37
38r"""
39
40sage: t = var('t')
41sage: x = cos(t) + cos(7*t)/2 + sin(17*t)/3
42sage: y = sin(t) + sin(7*t)/2 + cos(17*t)/3
43sage: g = parametric_plot( (x, y), (t, 0, 2*pi))
44sage: # g.show(aspect_ratio=1)
45
46"""
47
48
49r"""
50
51sage: t = var('t'); e, n = 2, 20/19
52sage: g1 = polar_plot(1+e*cos(n*t),(t,0,n*38*pi),plot_points=5000)
53sage: e, n = 1/3, 20/19
54sage: g2 = polar_plot(1+e*cos(n*t),(t,0,n*38*pi),plot_points=5000)
55sage: # g1.show(aspect_ratio=1); g2.show(aspect_ratio=1)
56
57"""
58
59
60r"""
61
62sage: z = var('z'); g1 = complex_plot(abs(cos(z^4)) - 1,\
63...             (-3, 3), (-3, 3), plot_points=400)
64sage: f = lambda x, y : (abs(cos((x + I * y) ** 4)) - 1)
65sage: g2 = implicit_plot(f, (-3, 3), (-3, 3), plot_points=400) # long time (~300 seconds)
66sage: # g1.show(aspect_ratio=1); g2.show(aspect_ratio=1)
67sage: f(z) = z^5 + z - 1 + 1/z
68sage: g = complex_plot(f, (-3, 3), (-3, 3)) # long time
69
70
71"""
72