def resolve(self): '''Вычисление интеграла методом правых прямоугольников.''' super().resolve() a, b = self.range n = 0 s = 0 s1 = self.error * 10 split_count = 10 # Кол-во разбиений while abs(s - s1) >= self.error: n += 1 s1 = copy.deepcopy(s) s = 0 h = (b - a) / split_count x_boof = a for i in range(1, split_count + 1): x = x_boof + i * h s += self.f(x) s *= h split_count *= 2 if self.debug: print('{0}: {1}'.format(n, s)) return resolving.from_dict({ 'steps': n, 'value': s, 'method_name': self.method_name })
def resolve(self): '''Вычисление интеграла методом парабол.''' super().resolve() a, b = self.range n = 0 s = 0 s1 = self.error * 10 split_count = 10 # Кол-во разбиений while abs(s - s1) >= self.error: n += 1 s1 = copy.deepcopy(s) s = 0 h = (b - a) / split_count x_boof = copy.deepcopy(a) s = self.f(a) + self.f(b) for i in range(1, split_count): x = x_boof + i * h if (i % 2 == 0): s += 2 * self.f(x) else: s += 4 * self.f(x) s *= h / 3 split_count *= 2 if self.debug: print('{0}: {1}'.format(n, s)) return resolving.from_dict({ 'steps': n, 'value': s, 'method_name': self.method_name })