Exemplo n.º 1
0
    def search_by_dichotome(self):
        Sven_Method = Find_Interval(self.starting_point, self.delta)
        interval = Sven_Method.finder()
        self.get_atrs()

        new_interval = self.half_interval(interval, Sven_Method)
        return new_interval
Exemplo n.º 2
0
    def golden_cut(self):
        SvenMethod = Find_Interval(self.starting_point, self.delta)
        interval = SvenMethod.finder()
        print('SVEN =', interval)
        self.get_epsilon()

        return self.find_interval(
            interval, SvenMethod,
            math.sqrt((interval[1][0] - interval[0][0])**2 +
                      (interval[1][1] - interval[0][1])**2))
    def golden_cut(self):
        SvenMethod = Find_Interval(self.coeffs, self.starting_point, self.delta)
        # interval = SvenMethod.finder()
        interval = [8.3, 14.6]
        # interval = [-6.3, -4.2]
        self.get_epsilon()

        return self.find_interval(interval, SvenMethod, interval[1] - interval[0])
    def get_answer_by_pauel(self):
        Swen_metod = Find_Interval(self.starting_point, self.delta)
        interval = Swen_metod.finder()

        if self.epsilon_p is None:
            self.get_epsilon_p()

        x2 = [(interval[0][0] + interval[1][0]) / 2, (interval[0][1] + interval[1][1]) / 2]
        f2 = Swen_metod.func(*x2)
        print('1 iter:', interval[0], x2, interval[1])

        x_correction = self.x_correction(interval, Swen_metod)
        f_correction = Swen_metod.func(*x_correction)

        if f2 >= f_correction:
            half_interval = [x2, interval[1]]

        else:
            half_interval = [interval[0], x2]
        return self.half_searching(half_interval, Swen_metod, x_correction, f_correction)
    def get_answer_by_pauel(self):
        Swen_metod = Find_Interval(self.coeffs, self.starting_point,
                                   self.delta)
        interval = Swen_metod.finder()
        interval = [-1.15, 0.3]
        # interval = [-17.3, 0.1]

        if self.epsilon_p is None:
            self.get_epsilon_p()

        x2 = (interval[0] + interval[1]) / 2
        f2 = Swen_metod.func(x2)
        print('1 iter:', interval[0], x2, interval[1])

        x_correction = self.x_correction(interval, Swen_metod)
        f_correction = Swen_metod.func(x_correction)

        if f2 >= f_correction:
            half_interval = (x2, interval[1])

        else:
            half_interval = (interval[0], x2)
        return self.half_searching(half_interval, Swen_metod, x_correction,
                                   f_correction)
Exemplo n.º 6
0
def do_all():
    coeffs = []

    highest_power = int(input('Input the highest power of function:'))

    for i in range(highest_power + 1):
        coeffs.append(
            float(input('Input coef near x^{}: '.format(highest_power - i))))
    starting_point = float(input('Input your starting point:'))
    delta = float(input('Input your step:'))
    eplilon_d = float(input('Enter Epsilon for Dichotomy: '))
    eplilon_g = float(input('Enter Epsilon Golden_cut: '))
    eplilon_p = float(input('Enter Epsilon Pauel: '))
    print('Sven method interval :',
          Find_Interval(coeffs, starting_point, delta).finder())
    print(
        'Dichotomy method     :',
        Dichotomy(coeffs, starting_point, delta,
                  eplilon_d).search_by_dichotome())
    print('Golden cut method    :',
          Golden_cut(coeffs, starting_point, delta, eplilon_g).golden_cut())
    print(
        'Pauel method         :',
        Pauel(coeffs, starting_point, delta, eplilon_p).get_answer_by_pauel())