import math


def _bits_required_to_achieve_accuracy(n, epsilon):
    """
    Compute the number of bits required to achieve given probability and accuracy
    For details, see Eq. (5.35) on Nielsen's book

    Args:
        n (int): the number of bits that we wish our estimation of theta can be accurate
        epsilon (double): probability of success at least 1 - epsilon
    Returns:
        n_updated (int): number of bits required to acchieve the given accuracy and probability
    """
    tmp = math.log((2 + 1/(2*epsilon)), 2)
    tmp = math.ceil(tmp)
    n_updated = int(n + tmp)
    return n_updated