def dekker(
    t: float,
    x1: float,
    y1: float,
    x2: float,
    y2: float,
    x3: float,
    y3: float,
    x4: float,
    y4: float,
) -> float:
    """
    Estimates the root using Dekker's method.

    Uses a secant line from (x2, y2) to either (x1, y1) or (x3, y3), depending on
    which point is closest.

    Note
    ----
    If x3 is closer to x2 but using it does not result in a value
    between x1 and x2, then it is rejected and bisection is used.
    Division by 0 is checked here, and the solver checks if 0 < t < 1
    before defaulting to bisection.
    """
    # If x2 is closer to x1, then use (x1, y1).
    if abs(x2 - x1) <= abs(x2 - x3):
        return y2 / (y2 - y1)
    # If division by 0, then use bisection.
    elif y2 == y3:
        return 0.5
    # If x2 is closer to x3 and using (x3, y3) does
    # not result in division by 0, then use (x3, y3).
    else:
        return y2 * (x3 - x2) / ((y2 - y3) * (x1 - x3))