import math


def predict_prob(diameter=1.0, gap_width=1.0):
    """
    For the variables passed into the simulation,
    predict the probability that the needle will hit
    at least one of the two parallel lines.

    diameter and gap_width can be scalars or arrays.
    """
    R = diameter / 2
    D = gap_width

    if D >= 2 * R:
        return (
            math.pi *
            (R / D) ** 2
        )
    elif D > R * math.sqrt(2):
        return (
            math.sqrt(
                4 *
                (R / D) ** 2
                - 1
            ) +
            (R / D) ** 2 *
            (math.pi - 4 * math.acos(D / (2*R)))
        )
    else:
        return 1