def getNode(self): node = notation.Number() if ( self.func[0:2] == "n(" ): node = notation.N() elif ( self.func[0:2] == "r(" ): node = notation.R() elif ( self.func[0:2] == "+(" ): node = notation.Add() elif ( self.func[0:2] == "*(" ): node = notation.Mul() elif ( self.func[0:2] == "-(" ): node = notation.Sub() elif ( self.func[0:2] == "/(" ): node = notation.Div() elif ( self.func[0:2] == "^(" ): node = notation.Pow() elif ( self.func[0:2] == "s(" ): node = notation.S() elif ( self.func[0:2] == "c(" ): node = notation.C() elif ( self.func[0:2] == "e(" ): node = notation.E() elif ( self.func[0:2] == "l(" ): node = notation.Ln() elif ( self.func[0:2] == "!(" ): node = notation.Fac() elif ( self.func[0:1] == "p" ): node = notation.P() elif ( self.func[0:1] == 'x' ): node = notation.X() elif( self.func[0] == ',' or self.func[0] == ')'): node = None return node
def getNode(self): node = notation.Number() # print(':'+self.func+':') if (self.func[0:2] == "n("): node = notation.N() elif (self.func[0:2] == "r("): node = notation.R() elif (self.func[0:2] == "+("): node = notation.Add() elif (self.func[0:2] == "*("): node = notation.Mul() elif (self.func[0:2] == "-("): node = notation.Sub() elif (self.func[0:2] == "/("): node = notation.Div() elif (self.func[0:2] == "^("): node = notation.Pow() elif (self.func[0:2] == "s("): node = notation.S() elif (self.func[0:2] == "c("): node = notation.C() elif (self.func[0:2] == "e("): node = notation.E() elif (self.func[0:2] == "l("): node = notation.Ln() elif (self.func[0:2] == "!("): node = notation.Fac() elif (self.func[0] == 'p'): node = notation.P() elif (self.func[0] == 'x'): node = notation.X() return node
def getMcLaurinVector(self, x, depth=1, method="Newton"): depth += 1 if (method == "Newton"): vector = [] try: vector.append(eval(self.parse.function)) except Exception as ex: messagebox.showerror( "Error!", "Invalid function. Please check your input again!") print(ex) return [] for i in range(1, depth): try: vector.append( self.parse.getDifferenceQuotion(x, depth=i) / numpy.math.factorial(i)) except Exception as ex: messagebox.showerror( "Error!", "Invalid derivative at depth {}. Please try other function!" .format({i})) print(ex) return [] return vector elif (method == "Analytically"): vector = [] derivative = self.parse.root try: vector.append(eval(derivative.toFunction())) except Exception as ex: messagebox.showerror( "Error!", "Invalid function. Please check your input again!") print(ex) return [] for i in range(1, depth): derivative = derivative.getDerivative() derivative = derivative.simplify( ) if derivative != None else notation.Number(data="0") try: vector.append( eval(derivative.toFunction()) / numpy.math.factorial(i)) except Exception as ex: messagebox.showerror( "Error!", "Invalid derivative at depth {}. Please try other function!" .format({i})) print(ex) return [] return vector return []
def getNode(self): node = notation.Number() # print(':'+self.func+':') if (self.func[0:2] == "n("): node = notation.N() elif (self.func[0:2] == "r("): node = notation.R() elif (self.func[0:2] == "+("): node = notation.Add() elif (self.func[0:2] == "*("): node = notation.Mul() elif (self.func[0:2] == "-("): node = notation.Sub() elif (self.func[0:2] == "/("): node = notation.Div() elif (self.func[0:2] == "^("): node = notation.Pow() elif (self.func[0:2] == "s("): node = notation.S() elif (self.func[0:2] == "c("): node = notation.C() elif (self.func[0:2] == "e("): node = notation.E() elif (self.func[0:2] == "l("): node = notation.Ln() elif (self.func[0:2] == "!("): node = notation.Fac() elif (self.func[0:2] == "p("): node = notation.P() elif (self.func[0] == 'x'): node = notation.X() elif (self.func[0] == 'h'): node = notation.H() return node # p = Parse("^(x,2)") # print(p.derivative.toString()) # print(p.differenceQuotion.toString()) # # newroot.toString()