Example #1
0
    def rect_init(self):
        try:
            a = float(self.rect_left.text())
            b = float(self.rect_right.text())
            acc = float(self.rect_accuracy.text())
            min_intervals = float(self.rect_min.text())
            max_intervals = float(self.rect_max.text())

            if not validate_params(a, b, min_intervals, max_intervals):
                raise ValueError
            self.error.setText('')
            delta = abs(b - a)
            self.update_graph(a - delta * 0.1, b + delta * 0.1)
            if self.rect_type.currentIndex() == 0:
                data = imath.rectangles_left(self.function, a, b, acc,
                                             min_intervals, max_intervals)
            elif self.rect_type.currentIndex() == 1:
                data = imath.rectangles_right(self.function, a, b, acc,
                                              min_intervals, max_intervals)
            elif self.rect_type.currentIndex() == 2:
                data = imath.rectangles_middle(self.function, a, b, acc,
                                               min_intervals, max_intervals)
            self.data = data
            model = tablemodel.TableModel(data, ["Sum", "N"])
            self.table.setModel(model)
            self.table.update()
        except ValueError:
            self.error.setText('Invalid params')
        except imath.RequirementException:
            self.error.setText("Convergence requirements faild")
        except imath.BadParamsExceptions:
            self.error.setText('Invalid params')
Example #2
0
 def HordesInit(self):
     try:
         a = float(self.left.text())
         b = float(self.right.text())
         acc = float(self.accuracyhords.text())
         if not self.validateParams(a, b, a):
             raise ValueError
         self.error.setText('')
         delta = abs( b - a )
         self.updateGraph( a - delta * 0.1, b + delta * 0.1 )
         data = numath.Hordes(self.function, a, b, acc)
         self.data = data
         model = tablemodel.TableModel(data, ["a", "b", "x", "F(a)", "F(b)", "F(x)", "|x_(i+1) - x_i"])
         self.table.setModel(model)
         self.table.update()
     except ValueError:
         self.error.setText('Invalid params')
     except numath.RequirementException:
         self.error.setText("Convergence requirements faild")
Example #3
0
 def NewtonInit(self):
     try:
         a = float(self.leftNewtone.text())
         b = float(self.rightNewtone.text())
         approx = float(self.approxNewton.text())
         acc = float(self.accuracyNewton.text())
         if not self.validateParams(a, b, approx):
             raise ValueError
         self.error.setText('')
         delta = abs( b - a )
         self.updateGraph( a - delta * 0.1, b + delta * 0.1 )
         data = numath.Newton(self.function, a, b, approx, acc)
         self.data = data
         model = tablemodel.TableModel(data, ["x", "f(x)", "f'(x)", "x_(n+1)", "|x_(n+1) - x_n|"])
         self.table.setModel(model)
         self.table.update()
     except ValueError:
         self.error.setText('Invalid params')
     except numath.RequirementException:
         self.error.setText("Convergence requirements faild")
Example #4
0
 def IterationInit(self):
     try:
         a = float(self.leftIter.text())
         b = float(self.rightIter.text())
         approx = float(self.approx_Iter.text())
         acc = float(self.approx_Iter.text())
         if not self.validateParams(a, b, approx):
             raise ValueError
         self.error.setText('')
         delta = abs( b - a )
         self.updateGraph( a - delta * 0.1, b + delta * 0.1 )
         data = numath.Iteration(self.function, a, b, approx, acc)
         self.data = data
         model = tablemodel.TableModel(data, ["x_i", "x_(i+1)", "phi(x)", "f(x)", "|x_(i+1) - x_i|"])
         self.table.setModel(model)
         self.table.update()
     except ValueError:
         self.error.setText("Invalid Params")
     except numath.RequirementException:
         self.error.setText("Convergence requirements faild")
     except numath.RootOutOfRange:
         self.error.setText("Root out of range")
Example #5
0
 def trapeze_init(self):
     try:
         a = float(self.trapeze_left.text())
         b = float(self.trapeze_right.text())
         acc = float(self.trapeze_accuracy.text())
         min_intervals = float(self.trapeze_min.text())
         max_intervals = float(self.trapeze_max.text())
         if not validate_params(a, b, min_intervals, max_intervals):
             raise ValueError
         self.error.setText('')
         delta = abs(b - a)
         self.update_graph(a - delta * 0.1, b + delta * 0.1)
         data = imath.trapeze(self.function, a, b, acc, min_intervals,
                              max_intervals)
         self.data = data
         model = tablemodel.TableModel(data, ["Sum", "N"])
         self.table.setModel(model)
         self.table.update()
     except ValueError:
         self.error.setText("Invalid Params")
     except imath.RequirementException:
         self.error.setText("Convergence requirements faild")
     except imath.BadParamsExceptions:
         self.error.setText('Invalid params')