Ticket #10983: graphique_1_fixed.py

File graphique_1_fixed.py, 1.8 KB (added by casamayou, 9 years ago)
Line
1r"""
2sage: g = plot(x * sin(1/x), x, -2, 2, plot_points=500)
3sage: def p(x, n): return(taylor(sin(x), x, 0, n))
4sage: xmax = 15 ; n = 15
5sage: g = plot(sin(x), x, -xmax, xmax)
6sage: for d in range(n):
7...     g += plot(p(x, 2 * d + 1), x, -xmax, xmax,\
8...       color=(1.7*d/(2*n), 1.5*d/(2*n), 1-3*d/(4*n)))
9sage: # g.show(ymin=-2, ymax=2)
10"""
11
12r"""
13sage: a = animate([[sin(x), taylor(sin(x), x, 0, 2*k+1)]\
14...          for k in range(0, 14)], xmin=-14, xmax=14,\
15...          ymin=-3, ymax=3, figsize=[8, 4])
16sage: # a.show()
17"""
18
19r"""
20sage: f2(x) = 1; f1(x) = -1
21sage: f = Piecewise([[(-pi,0),f1],[(0,pi),f2]])
22sage: S = f.fourier_series_partial_sum(20,pi); S
234/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
24sage: g = plot(S, x, -8, 8, color='blue')
25sage: scie(x) = x - 2 * pi * floor((x + pi) / (2 * pi))
26sage: g += plot(scie(x) / abs(scie(x)), x, -8, 8, color='red')
27"""
28
29r"""
30sage: t = var('t')
31sage: x = cos(t) + cos(7*t)/2 + sin(17*t)/3
32sage: y = sin(t) + sin(7*t)/2 + cos(17*t)/3
33sage: g = parametric_plot( (x, y), (t, 0, 2*pi))
34sage: # g.show(aspect_ratio=1)
35"""
36
37r"""
38sage: t = var('t'); e, n = 2, 20/19
39sage: g1 = polar_plot(1+e*cos(n*t),(t,0,n*38*pi),plot_points=5000)
40sage: e, n = 1/3, 20/19
41sage: g2 = polar_plot(1+e*cos(n*t),(t,0,n*38*pi),plot_points=5000)
42sage: # g1.show(aspect_ratio=1); g2.show(aspect_ratio=1)
43"""
44
45r"""
46sage: z = var('z'); g1 = complex_plot(abs(cos(z^4)) - 1,\
47...             (-3, 3), (-3, 3), plot_points=400)
48sage: f = lambda x, y : (abs(cos((x + I * y) ** 4)) - 1)
49sage: g2 = implicit_plot(f, (-3, 3), (-3, 3), plot_points=400) # long time (~300 seconds)
50sage: # g1.show(aspect_ratio=1); g2.show(aspect_ratio=1)
51sage: f(z) = z^5 + z - 1 + 1/z
52sage: g = complex_plot(f, (-3, 3), (-3, 3)) # long time
53
54"""