def cont(x, D, mixed=False):
    """Generate fraction representation using Aberth method"""
    B = abs(x)
    P_2, P_1, P, Q_2, Q_1, Q = 0, 1, 0, 1, 0, 0
    while Q_1 < D:
        A = int(B)
        P = A * P_1 + P_2
        Q = A * Q_1 + Q_2
        if B - A < 5e-08:
            break
        B = 1.0 / (B - A)
        P_2, P_1 = P_1, P
        Q_2, Q_1 = Q_1, Q
    if Q > D:
        if Q_1 <= D:
            P, Q = P_1, Q_1
        else:
            P, Q = P_2, Q_2
    sgn = -1 if x < 0 else 1
    if not mixed:
        return [0, sgn * P, Q]
    q = divmod(sgn * P, Q)
    return [q[0], q[1], Q]
