| | |
| | | self.ui.plotBtn.clicked.connect(self._update_plot) |
| | | self.ui.breakMethod.buttonClicked.connect(self._activate_break_rule) |
| | | self.ui.numberOfSectionsMethod.click() |
| | | self.ui.plotBtn.click() |
| | | |
| | | def _update_plot(self): |
| | | fn_expr = self.ui.function.text() |
| | |
| | | self.ui.espilon.setText(f"{eps}") |
| | | print(f"plot f(x) = {fn_expr}, {a}, {b}, epsilon = {eps}") |
| | | (self.x, self.y, self.left, self.right, self.num_of_iterations, *_) = numint_epsilon(f, a, b, eps) |
| | | self._update_plot_eps() |
| | | self._plot_canvas() |
| | | elif method_id == self.ui.breakMethod.id(self.ui.numberOfSectionsMethod): |
| | | section = self.ui.section.text() |
| | | sec = int(abs(parse_value(section))) |
| | | self.ui.section.setText(f"{sec}") |
| | | print(f"plot f(x) = {fn_expr}, {a}, {b}, section = {sec}") |
| | | (self.x, self.y, self.left, self.right, self.num_of_iterations, *_) = numint_section(f, a, b, sec) |
| | | self._update_plot_eps() |
| | | self._plot_canvas() |
| | | except Exception as ex: |
| | | print(ex) |
| | | pass |
| | | |
| | | def _update_plot_eps(self): |
| | | def _plot_canvas(self): |
| | | self.canvas.axes.cla() # Clear the canvas. |
| | | # self.canvas.axes.stairs(self.y[1:], self.x, baseline=0, fill=True, alpha=0.5, label=self.fn_expr) |
| | | # self.canvas.axes.stairs(self.y[0:-1], self.x, baseline=0, fill=True, alpha=0.5, label=self.fn_expr) |
| | | self.canvas.axes.step(self.x, self.y, color="blue", where="pre", label="right") |
| | | self.canvas.axes.step(self.x, self.y, color="orange", where="post", label="left") |
| | | |
| | | self.canvas.axes.plot(self.x, self.y, color="black", label=self.fn_expr) |
| | | self.canvas.axes.plot(self.x, self.y, color="black", label=self.fn_expr, linewidth=0.75) |
| | | self.canvas.draw() |
| | | |
| | | self.ui.leftSum.setText(f"{self.left}") |
| | |
| | | from typing import Callable |
| | | |
| | | |
| | | def split(iteration=8): |
| | | (a, b) = (0, 8) |
| | | def split(a:float=0, b: float=8, iteration=8): |
| | | x = [a, b] |
| | | parts = 1 |
| | | dx = (b - a) |