From 02214b0f8253f91d41fff66903b1dcf79382e6b7 Mon Sep 17 00:00:00 2001 From: Bertrand Benjamin Date: Wed, 17 Jul 2019 09:55:32 +0200 Subject: [PATCH] Feat: no more round in quadratic roots --- mapytex/calculus/API/tokens/polynomial.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/mapytex/calculus/API/tokens/polynomial.py b/mapytex/calculus/API/tokens/polynomial.py index 09af32c..c58a90a 100644 --- a/mapytex/calculus/API/tokens/polynomial.py +++ b/mapytex/calculus/API/tokens/polynomial.py @@ -95,7 +95,7 @@ class Polynomial(Token): 17 """ return Expression(self._mo.tree)(value) - + def differentiate(self): """ Differentiate a polynome @@ -284,17 +284,19 @@ class Quadratic(Polynomial): if self.delta._mo < 0: return [] elif self.delta._mo == 0: - #return [Expression.from_str(f"-{self.b}/(2*{self.a})").simplify()] + # return [Expression.from_str(f"-{self.b}/(2*{self.a})").simplify()] return [round(eval(f"-{self.b}/(2*{self.a})"), 2)] else: from math import sqrt + roots = [ - round(eval(f"(-{self.b}-sqrt({self.delta}))/(2*{self.a})"), 2), - round(eval(f"(-{self.b}+sqrt({self.delta}))/(2*{self.a})"), 2), + str(eval(f"(-{self.b}-sqrt({self.delta}))/(2*{self.a})")), + str(eval(f"(-{self.b}+sqrt({self.delta}))/(2*{self.a})")), ] roots.sort() return roots + # ----------------------------- # Reglages pour 'vim' # vim:set autoindent expandtab tabstop=4 shiftwidth=4: