>>> import bolzano >>> import math >>> f = math.sin >>> eps = 1e-5 >>> x = bolzano.bisecció(f, -1, 2, eps) >>> print('{:.6g}'.format(x)) 7.62939e-06 >>> f = math.cos >>> eps = 1e-5 >>> x = bolzano.bisecció(f, -1, 2, eps) >>> print('{:.6g}'.format(x)) 1.5708 >>> f = math.sin >>> eps = 1e-10 >>> x = bolzano.bisecció(f, -1, 2, eps) >>> print('{:.6g}'.format(x)) -5.82077e-11 >>> f = math.cos >>> eps = 1e-10 >>> x = bolzano.bisecció(f, -1, 2, eps) >>> print('{:.6g}'.format(x)) 1.5708 >>> def f(x): ... return x - 1 >>> eps = 1e-5 >>> x = bolzano.bisecció(f, -1, 2, eps) >>> print('{:.6g}'.format(x)) 0.999992 >>> eps = 1e-10 >>> x = bolzano.bisecció(f, -1, 2, eps) >>> print('{:.6g}'.format(x)) 1 >>> def f(x): ... return x**2 - 1 >>> eps = 1e-5 >>> x = bolzano.bisecció(f, 0, 2, eps) >>> print('{:.6g}'.format(x)) 1 >>> eps = 1e-10 >>> x = bolzano.bisecció(f, 0, 2, eps) >>> print('{:.6g}'.format(x)) 1 >>> eps = 1e-5 >>> x = bolzano.bisecció(f, -2, 0, eps) >>> print('{:.6g}'.format(x)) -1 >>> eps = 1e-10 >>> x = bolzano.bisecció(f, -2, 0, eps) >>> print('{:.6g}'.format(x)) -1 >>> eps = 1e-3 >>> x = bolzano.bisecció(f, 0, 1.5, eps) >>> print('{:.6g}'.format(x)) 1.00049 >>> eps = 1e-5 >>> x = bolzano.bisecció(f, -1.5, 0, eps) >>> print('{:.6g}'.format(x)) -0.999996 >>> eps = 1e-5 >>> x = bolzano.bisecció(f, -0.2, 1.8, eps) >>> print('{:.6g}'.format(x)) 0.999997 >>> eps = 1e-5 >>> x = bolzano.bisecció(f, -1.5, 0.8, eps) >>> print('{:.6g}'.format(x)) -0.999998