def normal(self, x=smp.Symbol('x')): # self.screen.destroy() v = self.entry.get() l = smp.limit(self.function, x, v) smp.pprint(l) result.configure(text=l) ltx.latex(str(smp.latex(l)))
def taylor_series(x=smp.Symbol("x")): global taylor, g, grade, f, func f = func.get() g = grade.get() try: g = int(g) except: print("Invalid grade value") taylor.destroy() diff = [] taylor_vec = [smp.sympify(f).subs(x, 0)] print(smp.sympify(f).subs(x, 0)) for i in range(1, g+1): print("i:"+str(i)) diff.append(smp.diff(f, x, i)) n = 1 for deriv in diff: term = smp.sympify(deriv).subs(x, 0) print(term) term = (term*(x**n))/math.factorial(n) print(term) taylor_vec.append(term) n += 1 series = 0 for t in taylor_vec: series += t print(series) ltx.latex(smp.latex(series))
def factor(): global func, f, result, calculus_screen f = func.get() try: smp.pprint(smp.factor(f)) print(smp.latex(smp.factor(f))) ltx.latex(smp.latex(smp.factor(f))) except: result.configure(text="Don't write like 2x, but 2*x")
def derivative(x=smp.Symbol('x')): global func, f, result, calculus_screen f = func.get() try: smp.pprint(smp.diff(f, x)) result.configure(text=smp.diff(f, x)) ltx.latex(str(smp.latex(smp.diff(f, x)))) except: result.configure(text="Don't write like 2x, but 2*x")
def laplace_transform(x=smp.Symbol('x'), s=smp.Symbol('s')): global func, f, result, calculus_screen f = func.get() try: laplace = smp.laplace_transform(f, x, s, noconds=True) smp.pprint(laplace) print(smp.latex(laplace)) ltx.latex(str(smp.latex(laplace))) except: result.configure(text="Don't write like 2x, but 2*x")
def indefinite_integral(x=smp.Symbol('x')): global func, f, result, calculus_screen, integral_screen f = func.get() try: smp.pprint(smp.integrate(f, x), use_unicode=True) result.configure(text=str(smp.integrate(f, x))+"+c") ltx.latex(str(smp.latex(smp.integrate(f, x)))) except: result.configure(text="Don't write like 2x, but 2*x") integral_screen.destroy()
def definite_integral(x=smp.Symbol('x')): global d_integral_screen, func, f, result, calculus_screen, low_limit, up_limit, lower_limit, upper_limit f = func.get() low_limit = lower_limit.get() up_limit = upper_limit.get() d_integral_screen.destroy() try: i = smp.integrate(f, (x, low_limit, up_limit)) smp.pprint(i) result.configure(text=i) ltx.latex(str(smp.latex(i))) except: result.configure(text="Invalid Parameters")