|
Édition du: 06/01/2026 |
|
INDEX |
Python –
Comment se lancer et initiation |
||
Faites un double-clic pour un retour en haut de page
![]()
|
PROGRAMMATION PYTHON – Algèbre Quelles sont les
principales choses à savoir ou à avoir sous la main lorsqu'on s'intéresse à l'algèbre:
développement, simplification, factorisation |
||
|
|
Sommaire de cette page >>> Fonctions mathématiques >>> Manipulations d'expressions (développement,
simplification, factorisation) >>> Équations – Résolution >>> Trigonométrie |
Débutants Glossaire |
Rappel: comment implanter numpy
et sympy dans votre logiciel Python >>>
|
Appel des fonctions mathématiques |
|
|
|
|
Importer toutes les fonctions
mathématiques |
|
|
|
|
Valeur numérique |
|||
|
Valeur numérique d'une expression |
from sympy import symbols n = symbols('n') E = n**2 + 2*n N = E.subs(n, 5) print(N) |
35 |
|
|
Évaluation d'une expression |
from sympy import symbols x = symbols('x') print(int((2*x + 5).subs(x, 10).evalf())) |
25 |
|
|
Idem via définition d'un polynôme |
from sympy import symbols, Poly x = symbols('x') p = Poly(x**3 + 2*x**2 - x + 1) print(p.eval(x, 5)) |
171 |
|
|
Simplification et évaluation |
from sympy import symbols, simplify n = symbols('n') E = n*(n + 1)/2 + (n + 1)*(n + 2)/2 EF = simplify(E) print("E =",E, "simplifié en:", EF) nb = 100 V = int(EF.subs(n,nb)) print("Avec n =", nb,": E = ",V) |
E = n*(n + 1)/2 + (n + 1)*(n + 2)/2
simplifié en: (n + 1)**2 Avec n = 100 : E =
10201 |
|
|
Simplifier Factoriser Développer |
from sympy import symbols, simplify, expand, factor x = symbols('x') E = x**2 + 2*x + 4 + 2*x print("expression",E) print("simplifiée",simplify(E)) F = factor(E) print("factorisée",F) print("développeée",expand(F)) |
expression x**2 + 4*x + 4 simplifiée x**2 + 4*x + 4 factorisée (x + 2)**2 développée x**2 + 4*x + 4 |
|
|
Avec solve |
from sympy import symbols, solve x = symbols('x') eq = x**2 + 4*x + 4 racines = solve(eq, x) print(racines) |
[-2] |
|
|
Avec Polynôme |
from sympy import symbols, Poly x = symbols('x') p = Poly(x**3 + 2*x**2 - x + 1) print(p.degree()) print(p.all_coeffs()) print(p.eval(x, 5)) |
3 [1, 2, -1, 1] 171 |
|
|
Variante avec module numpy |
import numpy as np coeffs = [1, 4, 4] # x² + 4x + 4 racines = np.roots(coeffs) print(racines) |
[-2. -2.] |
|
|
Autre exemple 3e degré |
from sympy import symbols, Eq, solve x = symbols('x') equation = Eq(x**3 + 2*x**2 - 5*x, 0) solutions = solve(equation, x) print("Solutions:", solutions) |
|
|
Solutions: [0, -1 + sqrt(6), -sqrt(6)
- 1] Soit:
|
||
|
Calcul d'un angle Connaissant son sinus |
import math x = 0.5 angle_rad = math.asin(x) angle_deg = math.degrees(angle_rad) print(f"arcsin({x}) = {angle_rad:.6f} radians") print(f"arcsin({x}) = {angle_deg:.2f}°") |
||
|
arcsin(0.5) = 0.523599 radians arcsin(0.5) = 30.00° |
|||
Haut de page (ou
double-clic)
![]()
|
Retour |
|
|
Suite |
|
|
Voir |
|
|
Sites |
|
|
Cette page |