File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ # coding: utf-8
2+
3+ """This is a simple demonstration library"""
4+
5+ __authors__ = ["Pierre Knobel" , "Jerome Kieffer" , "Pierre Palero" ,
6+ "Henri Payno" , "Armando Sole" , "Valentin Valls" ,
7+ "Thomas Vincent" ]
8+ __date__ = "01/04/2019"
9+ __license__ = "MIT"
10+
11+
12+ from . import mathutil
13+
14+
15+ def polynom (a , b , c ):
16+ """Solve the polygon of order two.
17+
18+ .. math:: a\cdotx^2 + b\cdotx + c = 0
19+
20+ :param float a: a value of the polynom
21+ :param float b: b value of the polynom
22+ :param float c: c value of the polynom
23+ :rtype: List[float]
24+ """
25+ if a == 0 :
26+ # Not a polynom
27+ raise ValueError ("Not a quadratic equation (a==0)" )
28+ delta = mathutil .pow2 (b ) - 4.0 * a * c
29+ solutions = []
30+ if delta > 0 :
31+ solutions .append ((- b + mathutil .sqrt (delta )) / (2.0 * a ))
32+ solutions .append ((- b - mathutil .sqrt (delta )) / (2.0 * a ))
33+ elif delta == 0 :
34+ solutions .append (- b / (2.0 * a ))
35+ return solutions
You can’t perform that action at this time.
0 commit comments