def calc_delta(a, max_val):
    """
    Calculates ideal Delta value for an A value < 1 and for a desired absoulte
    max value of the integrator

    Parameters
    ----------
    a : float
        'A' decay cte value, where 0 < A < 1
    max_val : Desired absolute max value that the integrator can have

    Returns
    -------
    integer
        Delta value archieve the desired constrain of keeping the integrator
        absolute value below of max_val

    """
    if a <= 0 or a >= 1:
        raise Exception('Invalid A value %f. Must be 0 < A < 1.' % a, a)
    if max_val <= 0:
        raise Exception('Invalid max_val value %d. Must be > 0' % max_val,
            max_val)
    return max_val * (1 - a)
