diff --git a/bisection.py b/bisection.py index 26c2ae7..a3edf30 100644 --- a/bisection.py +++ b/bisection.py @@ -57,20 +57,21 @@ def logs(self, item): print("{:>4} | {:^8.4f} | {:^8.4f} | {:^8.4f} | {:_>8.4f} | {:^8.4f}". format(self.iter_n, self.xinf, self.xsup, self.xmed, self.err_rel, self.ymed)) if item == 'results': - if not (self.err_rel > self.err_obj): print("Finish by eps: {:.4e}".format(self.err_rel)) - if not (self.iter_n < self.max_iter): print("Finish by iter: {}".format(self.iter_n)) + if self.err_rel <= self.err_obj: print("Finish by eps: {:.4e}".format(self.err_rel)) + if self.iter_n >= self.max_iter: print("Finish by iter: {}".format(self.iter_n)) print("Xroot: {0}".format(self.xmed)) if item == 'exact': print ("Exact root found: {}".format(self.xmed)) -def function(tInt_perc): - frec, ampl = 1, 1 - rms_unit = (np.sqrt(2) / 2) * ampl - rms_dimmer = fun_rms_simbolic(tInt_perc, frec=frec, amp=ampl) / rms_unit - return rms_dimmer +# TEST +# def function(tInt_perc): +# frec, ampl = 1, 1 +# rms_unit = (np.sqrt(2) / 2) * ampl +# rms_dimmer = fun_rms_simbolic(tInt_perc, frec=frec, amp=ampl) / rms_unit +# return rms_dimmer -solver = bisector(function, xinf=0, xsup=100, bias=0.1, err_obj=1e-5, verbose=False) -sol = solver.run() -print("rms({:.4f}) = {:.4f}".format(sol, function(sol))) \ No newline at end of file +# solver = bisector(function, xinf=0, xsup=100, bias=0.1, err_obj=1e-5, verbose=False) +# sol = solver.run() +# print("rms({:.4f}) = {:.4f}".format(sol, function(sol))) \ No newline at end of file