In [1]:
a = 3
In [2]:
a = 2
In [3]:
a
Out[3]:
2
In [4]:
# Je calcule une somme

2 + 2 + 3
Out[4]:
7

Je peux taper du texte

Ceci est un titre

ceci est un sous-titre

J'écris du gras et de l'italique ou encore du code.

Mais surtout, je tape du LaTeX: $\int_0^\pi \sin x\, dx$.

In [5]:
print(2+2)
4
In [6]:
2+2
Out[6]:
4
In [7]:
print(2+2)
print(3+3)
4
6
In [8]:
2+2
3+3
Out[8]:
6
In [9]:
for i in range(10):
    print(i)
0
1
2
3
4
5
6
7
8
9
In [10]:
Out[8]
Out[10]:
6
In [11]:
a = 3/4
In [12]:
type(a)
Out[12]:
<type 'sage.rings.rational.Rational'>
In [13]:
parent(a)
Out[13]:
Rational Field
In [14]:
%display latex
In [15]:
a
Out[15]:
In [16]:
parent(a)
Out[16]:
In [17]:
%display plain
In [18]:
parent(a)
Out[18]:
Rational Field
In [19]:
_
Out[19]:
Rational Field
In [20]:
2+2
Out[20]:
4
In [21]:
_
Out[21]:
4
In [22]:
_ + _
Out[22]:
8
In [23]:
_
Out[23]:
8
In [24]:
QQ
Out[24]:
Rational Field
In [25]:
parent(a) is QQ
Out[25]:
True
In [26]:
QQ.an_element()
Out[26]:
1/2
In [27]:
a.gcd(1/3)
Out[27]:
1/12
In [28]:
a.gcd??

Structures mathématiques

In [29]:
ZZ
Out[29]:
Integer Ring
In [30]:
RR
Out[30]:
Real Field with 53 bits of precision
In [31]:
CC
Out[31]:
Complex Field with 53 bits of precision
In [32]:
pi
Out[32]:
pi
In [33]:
pi.n()
Out[33]:
3.14159265358979
In [34]:
sin(pi)
Out[34]:
0
In [35]:
GF(7)
Out[35]:
Finite Field of size 7
In [36]:
GF(49, "z")
Out[36]:
Finite Field in z of size 7^2
In [37]:
QQ['X']
Out[37]:
Univariate Polynomial Ring in X over Rational Field
In [38]:
QQ['X', 'Y']
Out[38]:
Multivariate Polynomial Ring in X, Y over Rational Field
In [39]:
QQ['X,Y']
Out[39]:
Multivariate Polynomial Ring in X, Y over Rational Field
In [40]:
FractionField(_)
Out[40]:
Fraction Field of Multivariate Polynomial Ring in X, Y over Rational Field
In [41]:
A = QQ['X']
A
Out[41]:
Univariate Polynomial Ring in X over Rational Field
In [42]:
X
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-42-253bcac7dd80> in <module>()
----> 1 X

NameError: name 'X' is not defined
In [43]:
A.<X> = QQ[]
In [44]:
A
Out[44]:
Univariate Polynomial Ring in X over Rational Field
In [45]:
X
Out[45]:
X
In [46]:
parent(X)
Out[46]:
Univariate Polynomial Ring in X over Rational Field
In [47]:
(X^2 + 1)^3
Out[47]:
X^6 + 3*X^4 + 3*X^2 + 1
In [48]:
B.<XX> = FractionField(A)
In [49]:
(XX^2 + 1) / (X + 3)
Out[49]:
(X^2 + 1)/(X + 3)
In [50]:
parent(XX), parent(X)
Out[50]:
(Fraction Field of Univariate Polynomial Ring in X over Rational Field,
 Univariate Polynomial Ring in X over Rational Field)
In [51]:
x
Out[51]:
x
In [52]:
x^2 + 1
Out[52]:
x^2 + 1
In [53]:
(x^2 + 1)^3
Out[53]:
(x^2 + 1)^3
In [54]:
parent(x)
Out[54]:
Symbolic Ring
In [55]:
parent(pi) == parent(x) == parent(sin(pi))
Out[55]:
True
In [56]:
((x^2 + 1)^3).expand()
Out[56]:
x^6 + 3*x^4 + 3*x^2 + 1
In [57]:
y = SR.var('y')
In [58]:
y
Out[58]:
y
In [59]:
x + y
Out[59]:
x + y
In [ ]: