56 lines
1.0 KiB
Markdown
56 lines
1.0 KiB
Markdown
# Les polynômes
|
|
|
|
|
|
## Créer des polynômes
|
|
|
|
### Générer un polynôme "fixe"
|
|
|
|
### Générer un polynôme aléatoirement
|
|
|
|
>>> P = Polynom.random(["{b}", "{a}"]) # Polynom du type ax + b
|
|
>>> print(P)
|
|
- 8 x - 3
|
|
>>> P = Polynom.random(degree = 2)
|
|
>>> print(P)
|
|
5 x^{ 2 } + 4 x - 7
|
|
|
|
## Manipuler des polynômes
|
|
|
|
### Les représentations des polynômes
|
|
|
|
>>> P = Polynom([1, 2, 3])
|
|
>>> print(P)
|
|
|
|
### Évaluer des polynômes
|
|
|
|
>>> type(P(3))
|
|
pymath.expression.Expression
|
|
>>> for i in P(3).simplify():
|
|
print(i)
|
|
3 \times 3^{ 2 } + 2 \times 3 + 1
|
|
3 \times 9 + 6 + 1
|
|
27 + 6 + 1
|
|
33 + 1
|
|
34
|
|
>>> P(3).simplified()
|
|
34
|
|
|
|
|
|
### Opération et polynômes
|
|
|
|
>>> type(P + 1)
|
|
list
|
|
>>> for i in (P+1):
|
|
print(i)
|
|
3 x^{ 2 } + 2 x + 1 + 1
|
|
3 x^{ 2 } + 2 x + 1 + 1
|
|
3 x^{ 2 } + 2 x + 2
|
|
>>> Q = Polynom([4, 5, 6])
|
|
>>> for i in (P+Q):
|
|
print(i)
|
|
3 x ^ 2 + 6 x ^ 2 + 2 x + 5 x + 1 + 4
|
|
( 3 + 6 ) x ^ 2 + ( 2 + 5 ) x + 1 + 4
|
|
9 x ^ 2 + 7 x + 5
|
|
|
|
|