#Sage comme calculatrice 1+1; factorial(50); s = add(1/n for n in (1..30)); s; s.n(); #Python a = -2/3; type(a); dir(a)[140:160]; a.abs(), abs(a); def myfact(n): res = 1 for k in srange(1, n+1): res = res*k return res; myfact(50); #Calcul symbolique à la Maple x, y = var('x', 'y') u = cos(x)*sin(y) u; diff(u, x); u.derivative(y); u.series(x, order=5); u(x=1); u(x=sqrt(2), y=1).n(prec=1000); #Graphiques plot(Bessel(1,'J'), 0, 20); u, v = var('u', 'v') f = sin(pi*u) * cos(pi*v) plot3d(f, (u, -1, 1), (v, -1, 1)); plot_vector_field(f.gradient(), (u,-1,1), (v,-1,1), aspect_ratio=1, plot_points=30); x,y,z=var('x y z') myplot = plot_vector_field3d( (-y, 0, x), (x,-2,2), (y,-2,2), (z,-2,2), colors='black', plot_points=6) show(myplot, viewer="tachyon"); #Éléments et parents type(1); parent(1); ZZ; parent(1) is ZZ; parent(1/1); type(ZZ); type(QQ); ZZ.cardinality(); MyParent = QQ.cartesian_product(ZZ); MyParent; MyParent.is_ring(); MyParent.an_element(); QQ.category(); #Quelques parents Integers(); Rationals(); R = IntegerModRing(10); R; R(8)^2; Reals(); Complexes(); MatrixSpace(RDF, 2, 3); PolynomialRing(QQ, 'x'); PolynomialRing(QQ, 'x, y, z'); MatrixSpace(PolynomialRing(ZZ, 'x'), 2); _.random_element(); #Conversions RDF; RDF(42); RDF(42).parent(); ZZ(1.0); ZZ(1.5); #Coercitions #(= conversions canoniques automatiques) a = 42 a, a.parent(); b = a + 1/2 b, b.parent(); c = b + 1/2 (c, c.parent()); d = ZZ(c) (d, d.parent()); M = MatrixSpace(ZZ, 3); M; obj = M.identity_matrix() + 1/2; obj; obj.parent(); #Changement de parent M = MatrixSpace(RDF, 2); M; mat = M.random_element(); mat; mat.inverse(); MatrixSpace(Reals(100), 2)(mat); mat.change_ring(Reals(100)).inverse(); mat.change_ring(RealIntervalField(100)).inverse(); mat.change_ring(QQ).inverse(); #Flottants, intervalles... RDF; RDF.precision(); x = RDF(1/3); sin(x); x * 2^1024; RR; y = RR(1/3); y * 2^1024; QQ(y); y.exact_rational(); y.sign_mantissa_exponent(); sqrt(-x); sqrt(-x).parent(); sqrt(-y).parent(); Reals(prec=230, rnd='RNDU'); Reals(prec=230, rnd='RNDZ'); RealIntervalField(prec=100); ComplexIntervalField(prec=100); RIF, CIF; 0.42*1/3; 0.4200000000000000000000000000000*1/3; type(0.42); RR(1/3) + RIF(1/3); RLF; mypi = RLF(pi) mypi; mypi.n(200); CLF;