Feat: Polynomial are displayed in nicer order!

This commit is contained in:
2019-10-30 21:12:58 +01:00
parent e596c1af60
commit d72a2be175
7 changed files with 61 additions and 33 deletions

View File

@@ -104,12 +104,12 @@ class Polynomial(Token):
>>> P
<Polynomial 3x^2 + 2x + 1>
>>> P.differentiate()
<Linear 2 + 6x>
<Linear 6x + 2>
>>> for s in P.differentiate().explain():
... print(s)
0 + 2 + 3 * 2x
2 + 3 * 2 * x
2 + 6x
6x + 2
"""
return Expression(self._mo.differentiate()).simplify()
@@ -212,7 +212,7 @@ class Quadratic(Polynomial):
4 - 12
- 8
>>> P.differentiate()
<Linear 2 + 6x>
<Linear 6x + 2>
>>> P.roots
[]

View File

@@ -174,7 +174,7 @@ class Token(object):
>>> a = Integer(3)
>>> c = a - "x"
>>> c
<Linear 3 - x>
<Linear - x + 3>
"""
return self._operate(other, "-")