def __init__(self, observer, eq_str, start_str, tolerance, maxItr, *args, **kwargs): super().__init__() self.observer = observer self.eq_str = eq_str diff = Differentiator(eq_str) if (tolerance == ""): tolerance = "0.0001" if (maxItr == ""): maxItr = "50" birgeVieta = birgeVietaer(diff.get_function(), float(tolerance), int(maxItr)) data = birgeVieta.do(float(start_str)) xs, ys = birgeVieta.get_plot() '''xl = [] xu = [] xr = [] Fxl = [] Fxu = [] for i in data: xl.append(i[1]) xu.append(i[3]) xr.append(i[5]) Fxl.append((i[2])) Fxu.append(i[4])''' lastIterationData = data[len(data) - 1] solution = lastIterationData[4] iterations = lastIterationData[0] error = lastIterationData[-1] self.fig = NormalFunction(xs, ys) self.result = Result(solution=str(solution), status="done", figure=self.fig, iterations=iterations, message="We are groot", data=data, headers=birgeVietaer.get_headers(),error=error)
def __init__(self, method, observer, numberOfPoints, xInput, yInput, queryPoints): super().__init__() self.observer = observer if xInput[0] == '[': x = xInput[1:len(xInput)-1].split(',') y = yInput[1:len(yInput) -1].split(',') else: x = xInput.split(',') y = yInput.split(',') values = [] for i in range(0,len(x)): x[i] = float(x[i]) values.append(x) for i in range(0,len(y)): y[i] = float(y[i]) values.append(y) grange = LaGrange(values, int(numberOfPoints)) if queryPoints[0] == '[': points = queryPoints[1:len(queryPoints) - 1].split(',') else: points = queryPoints.split(',') for i in range(0,len(points)): points[i] = float(points[i]) results = [] xs = np.arange(x[0],x[-1],0.1) ys = [] for i in xs: ys.append(grange.do(i)) for i in points: results.append(grange.do(i)) self.fig = NormalFunction(xs, ys) self.result = Result(solution=results, status="I am status Groot",figure = self.fig, message="We are groot")
def __init__(self, observer, eq_str, start_str, end_str, tolerance, maxItr, *args, **kwargs): super().__init__() self.observer = observer self.eq_str = eq_str diff = Differentiator(eq_str) if (tolerance == ""): tolerance = 0.0001 if (maxItr == ""): maxItr = 50.0 bis = bisector(diff.get_function(), float(tolerance), int(maxItr)) start = float(start_str) end = float(end_str) data = bis.do(start, end) xs, ys = bis.get_plot() xl = [] xu = [] xr = [] for i in data: xl.append(i[1]) xu.append(i[3]) xr.append(i[5]) lastIterationData = data[len(data) - 1] solution = lastIterationData[5] iterations = lastIterationData[0] error = lastIterationData[-1] self.fig = BisectionPlot(xs, ys, xr, xl, xu, *args, **kwargs) self.result = Result(solution=str(solution), status="done", figure=self.fig, iterations=iterations, message="We are groot", data=data, headers=bisector.get_headers(), error= error)
def __init__(self, observer, eq_str, start_str, end_str, tolerance, maxItr, *args, **kwargs): super().__init__() self.observer = observer self.eq_str = eq_str diff = Differentiator(eq_str) if (tolerance == ""): tolerance = "0.0001" if (maxItr == ""): maxItr = "50" sec = secant(diff.get_function(), float(tolerance), int(maxItr)) data = sec.do(float(start_str), float(end_str)) xs, ys = sec.get_plot() xr = [] xl = [] fxl = [] xbl = [] fxbl = [] for i in data: xr.append(float(i[5])) xl.append(float(i[1])) fxl.append(float(i[2])) xbl.append(float(i[3])) fxbl.append(float(i[4])) lastIterationData = data[len(data) - 1] solution = lastIterationData[5] iterations = lastIterationData[0] error = lastIterationData[-1] self.fig = SecantPlot(xs, ys, xr, xl, fxl, xbl, fxbl, *args, **kwargs) self.result = Result(solution=str(solution), status="done", figure=self.fig, iterations=iterations, message="We are groot", data=data, headers=secant.get_headers(),error=error)
def __init__(self, observer, eq_str, start_str, tolerance, maxItr, *args, **kwargs): super().__init__() self.observer = observer self.eq_str = eq_str diff = Differentiator(eq_str) if (tolerance == ""): tolerance = "0.0001" if (maxItr == ""): maxItr = "50" newton = newKg(diff.get_function(), diff.get_first_derivative(), error=float(tolerance), max_iterations=int(maxItr)) data = newton.do(float(start_str)) xs, ys = newton.get_plot() xr = [] x = [] fx = [] for i in data: xr.append(float(i[4])) x.append(float(i[1])) fx.append(float(i[2])) lastIterationData = data[len(data) - 1] solution = lastIterationData[4] iterations = lastIterationData[0] error = lastIterationData[-1] self.fig = NewtonRaphsonPlot(xs, ys, xr, x, fx, *args, **kwargs) self.result = Result(solution=str(solution), status="done", figure=self.fig, iterations=iterations, message="We are groot", data=data, headers=newKg.get_headers(),error=error)
def __init__(self, observer, eq_str): super().__init__() self.observer = observer self.eq_str = eq_str values = [] print(len(values)) data = eq_str.splitlines() for i in range(0, len(data)): data[i] = data[i].split() for j in range(0, len(data[i])): data[i][j] = float(data[i][j]) values = np.asarray(data) gauss = GaussJordan(values) roots = gauss.solve() self.result = Result(solution=roots, status="I am status Groot", message="We are groot")
def __init__(self, observer, eq_str, start_str, end_str, tolerance, numOFRoots, *args, **kwargs): super().__init__() self.observer = observer self.eq_str = eq_str diff = Differentiator(eq_str) if (tolerance == ""): tolerance = "0.0001" finder = RootFinder(diff.get_function(), float(start_str), float(end_str), int(numOFRoots), float(tolerance)) roots = finder.get_roots() solution = "" errors = "" for i in roots: l = i[-1] err = l[-1] l = l[5] errors = errors + str(err) + "\n" solution = solution + str(l) + "\n" xs, ys = finder.get_plot() self.fig = NormalFunction(xs, ys) self.result = Result(solution=solution, status="done", figure=self.fig, message="We are groot",error = errors)
def __init__(self, observer, eq_str, start_str, tolerance, maxItr, *args, **kwargs): super().__init__() self.observer = observer self.eq_str = eq_str diff = Differentiator(eq_str) if (tolerance == ""): tolerance = "0.0001" if (maxItr == ""): maxItr = "50" fixPoint = fixedPointer(diff.get_function(), diff.get_first_derivative(), float(tolerance), int(maxItr)) data = fixPoint.do(float(start_str)) xs, ys = fixPoint.get_plot() xi = [] gx = [] for i in data: xi.append(i[1]) gx.append(i[2]) lastIterationData = data[len(data) - 1] solution = lastIterationData[3] iterations = lastIterationData[0] error = lastIterationData[-1] self.fig = FixedPointPlot(xs, ys, gx, xi, *args, **kwargs) self.result = Result(solution=str(solution), status="done", figure=self.fig, iterations=iterations, message="We are groot", data=data,headers= fixedPointer.get_headers(),error=error)