2.1 Opérations de base en Python
2.2 Exposant
2.3 Racine n-ième
2.4 Reste et quotient de la division
2.5 Fonctions et constantes mathématiques en Python
2.6 Accéder à la documentation d'une fonction
2.7 Parenthèses et priorité des opérations
2.8 Variables et affectation
In [12]:
lage_de_quelqun3 = 3
In [13]:
lage_de_quelqun3 + 1
Out[13]:
In [5]:
x + 2
Out[5]:
2.9 Opérateurs de comparaison et d'égalités
In [15]:
2 + 3 == 5
Out[15]:
In [19]:
2 + 3 <= 5
Out[19]:
In [21]:
4 + 5 >= 3
Out[21]:
In [22]:
23 != 34
Out[22]:
3.1 Nombres rationels
In [24]:
from sympy import Rational
In [26]:
Rational(1324, 1232)
Out[26]:
In [29]:
Rational(1, 124) + 23
Out[29]:
In [30]:
Rational(4,5)
Out[30]:
3.2 Nombres complexes
In [31]:
from sympy import I
In [33]:
I ** 2
Out[33]:
In [36]:
a = 2 + 8*I
In [38]:
a
Out[38]:
In [39]:
a.conjugate()
Out[39]:
In [40]:
abs(a)
Out[40]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
In [ ]:
3.3 Calculer une valeur numérique
In [41]:
from sympy import pi,E
In [48]:
pi.evalf(100)
Out[48]:
In [ ]:
In [ ]:
In [ ]:
3.4 Factoriser un nombre entier
In [49]:
from sympy import factor
In [50]:
factor(3247856343789135)
Out[50]:
In [53]:
?factor(24)
In [54]:
from sympy import factorint
In [57]:
factorint(3247856343789135)
Out[57]:
In [58]:
factorint(3247856343789135,visual=True)
Out[58]:
In [59]:
from sympy import init_printing
init_printing(pretty_print=True)
In [60]:
factorint(3247856343789135,visual=True)
Out[60]:
In [61]:
factorint(3247856343789135)
Out[61]:
In [ ]:
3.5 Accéder à la documentation et au code source d'une fonction
In [62]:
from sympy import simplify
In [63]:
simplify??
In [64]:
from math import sqrt
In [66]:
sqrt(4)
Out[66]:
In [68]:
sqrt(3)
Out[68]:
In [80]:
from sympy import sqrt
init_printing(pretty_print=True)
In [70]:
sqrt(4)
Out[70]:
In [73]:
sqrt(3)
Out[73]:
4.1 Variable symbolique
In [82]:
from sympy import Symbol
a = Symbol('a')
b = Symbol('b')
In [84]:
(a + a + 1) ** (a + b)
Out[84]:
In [85]:
from sympy.abc import a,b
In [86]:
a + b
Out[86]:
In [87]:
from sympy.abc import a,b,delta
In [88]:
delta + a
Out[88]:
In [ ]:
In [ ]:
In [ ]:
4.2 Affichage automatique des résultats en LaTeX
In [ ]:
4.3 Expressions symboliques
In [90]:
from sympy import sin,cos
sin(a)**2 + cos(a)**2
Out[90]:
In [91]:
simplify(_)
Out[91]:
In [92]:
_, __, ___
Out[92]:
In [96]:
Out[90]
Out[96]:
In [98]:
In[90]
Out[98]:
In [99]:
from math import sin
In [100]:
sin(a)
4.4 Représentation interne
4.5 Substitutions
In [101]:
expression = (a+b)**2
In [103]:
expression.subs(a, 8)
Out[103]:
In [104]:
expression.subs({a: 8, b: 34})
Out[104]:
In [ ]:
In [ ]:
In [ ]:
4.6 Constantes symboliques
4.7 Simplifier une expression
4.8 Développer une expression
In [107]:
expression = (a+b)**10
expression
Out[107]:
In [108]:
from sympy import expand
expand(expression)
Out[108]:
In [ ]:
In [ ]:
In [ ]:
4.9 Annuler les facteurs communs d'une fraction
4.10 Factoriser un polynôme
4.11 Rassembler les termes d'une expression
4.12 Réduire au même dénominateur
In [110]:
from sympy.abc import x,y,z
expression = 1/x + (3-x)/z + y/(1-x)
expression
Out[110]:
In [113]:
from sympy import ratsimp,together
In [112]:
ratsimp(expression)
Out[112]:
In [125]:
result = together(expression)
result
Out[125]:
In [ ]:
In [ ]:
4.13 Décomposition en fractions partielles
In [122]:
facile = 1 /( (x-1) * (x-2))
facile
Out[122]:
In [120]:
from sympy import apart
In [123]:
apart(facile)
Out[123]:
In [124]:
apart(result, x)
Out[124]:
5.1 Définir une équation
5.2 Résoudre une équation
5.3 Résoudre un système d'équations
5.4 Syntaxe abrégée
5.5 Trouver les racines d'une fonction
6.1 Dessin 2d
6.2 Dessin 3d
In [ ]: