String representation of Cubic Polynomial Equation
(self)
| 30 | self.signd = self._checkSign(self.__d) |
| 31 | |
| 32 | def __str__(self): |
| 33 | """ String representation of Cubic Polynomial Equation""" |
| 34 | |
| 35 | try: |
| 36 | self.c1 = Cubic.syntheticDivision(self)[0] |
| 37 | self.c2 = Cubic.syntheticDivision(self)[1] |
| 38 | if self.c1 == float and self.c2 == float: |
| 39 | self.c3 ="-" |
| 40 | self.c4 ="+" |
| 41 | else : |
| 42 | self.c3 = self._checkSign(float(Cubic.syntheticDivision(self)[0])*-1) |
| 43 | self.c4 = self._checkSign(float(Cubic.syntheticDivision(self)[1])*-1) |
| 44 | |
| 45 | |
| 46 | if self.__d == 0: |
| 47 | return "\n<Cubic Equation: p(x) = %sx%s %s %sx%s %s %sx = 0 \n \ |
| 48 | \n<The linear factorization : p(x) = %sx(x%s%s)(x%s%s) \n\ |
| 49 | " % (self.__a,chr(252),self.signb,self.__b,chr(253), |
| 50 | self.signc,self.__c,self.__a,self.c3,-1*float(self.c1), |
| 51 | self.c4,-1*float(self.c2)) |
| 52 | |
| 53 | else : |
| 54 | if self.__a == 1: |
| 55 | for i in Cubic.integerZero(self): |
| 56 | if (((self.__a*(i**3)) + (self.__b*(i**2))+ (self.__c*i )+ self.__d == 0) |
| 57 | and float(i) != float(self.c2) and float(i) != float(self.c1)): |
| 58 | return "\n<Cubic Equation: p(x) = %sx%s %s %sx%s %s %sx %s %s = 0 \ |
| 59 | \n\n<The integers zeros are :\n\n%s\n \ |
| 60 | \n<The linear factorization : p(x) = (x%s%s)(x%s%s)(x%s%s) \n\ |
| 61 | " % (self.__a,chr(252),self.signb,self.__b,chr(253),self.signc, |
| 62 | self.__c,self.signd,self.__d,Cubic.integerZero(self),self.c3, |
| 63 | -1*float(self.c1),self.c4,-1*float(self.c2),(self._checkSign(-1*i)),-1*i) |
| 64 | |
| 65 | return "\n<None of the integers zeros %s \n\n checks p(x) = %sx%s %s %sx%s %s %sx %s %s = 0\n\n " \ |
| 66 | % (Cubic.integerZero(self),self.__a,chr(252),self.signb,self.__b,chr(253),self.signc,self.__c, |
| 67 | self.signd,self.__d) |
| 68 | |
| 69 | else : |
| 70 | for j in Cubic.nonintegersRationalZero(self)[1]: |
| 71 | if ((self.__a*(float(str(j))**3)) + (self.__b*(float(str(j))**2))+ |
| 72 | (self.__c*float(str(j)) )+ self.__d == 0.00): |
| 73 | return "\n<Cubic Equation: p(x) = %sx%s %s %sx%s %s %sx %s %s = 0 \ |
| 74 | \n\n<The integers Zeros are :\n\n %s \ |
| 75 | \n\n<The nonintegers Rational Zeros are :\n\n %s \ |
| 76 | \n<The linear factorization : p(x) = (x%s%s)(x%s%s)(x%s%s) \n\ |
| 77 | " % (self.__a,chr(252),self.signb,self.__b,chr(253),self.signc,self.__c, |
| 78 | self.signd,self.__d,Cubic.integerZero(self),nonintegersRationalZero(self)[0], |
| 79 | self.c3,-1*float(self.c1),self.c4,-1*float(self.c2),(self._checkSign(-1*j)),-1*j) |
| 80 | |
| 81 | return "\n<None of the non integers zeros %s \n\n checks p(x) = %sx%s %s %sx%s %s %sx %s %s = 0\n\n" \ |
| 82 | % (Cubic.nonintegersRationalZero(self)[0],self.__a,chr(252),self.signb,self.__b, |
| 83 | chr(253),self.signc,self.__c,self.signd,self.__d) |
| 84 | except TypeError: |
| 85 | if self.__a == 1: |
| 86 | raise "\n<complex solutions \n\n<The integers zeros are %s " \ |
| 87 | % Cubic.integerZero(self) |
| 88 | else : |
| 89 | raise "\n<complex solutions \n\n<The nonintegers zeros are %s " \ |
nothing calls this directly
no test coverage detected