def solve(self): """ State waarin de oplossing voor de gekozen variabelen wordt gevonden. :return: """ try: print( 'Oplossing bepalen voor f(x) = {} met ({}, {}) en epsilon = {}' .format(self.f, *self.interval, self.epsilon)) self.solution = bisectiemethode.bisection_solver(self.f.f, *self.interval, self.epsilon, verbose=True) return STATE_SOLUTION except Exception as e: print(e) return STATE_SELECT_FUNCTION
def test_solve_sinusoid(self): x0 = bisection_solver(sinusoid.f, a=-0.5, b=1) assert is_within_range(actual=x0, expected=0, error=0.001)
def test_solve_poly1_immediately(self): x0 = bisection_solver(poly1.f, a=0, b=1) assert is_within_range(actual=x0, expected=0.5, error=0.001)
def test_solve_poly1(self): x0 = bisection_solver(poly1.f, a=0.1, b=0.8) assert is_within_range(actual=x0, expected=0.5, error=0.001)
def test_fa_fb_both_same_sign_check(self): try: bisection_solver(sinusoid.f, a=1, b=2) assert False, 'Exception not raised' except ValueError: pass
def test_fx_both_equal_sign_check(self): try: bisection_solver(poly1.f, a=0, b=2.5) assert False, 'Exception not raised' except ValueError: pass
def test_positive_epsilon_check(self): try: bisection_solver(poly1.f, a=0, b=2.5, epsilon=-1) assert False, 'Exception not raised' except ValueError: pass