def METHOD_NAME(a, b, d, fa, fb, fd, count):
    B = safe_div(fb - fa, b - a, float_info_max)
    A = safe_div(fd - fb, d - b, float_info_max)
    A = safe_div(A - B, d - a, 0.0)
    if A == 0:
        return secant_interpolate(a, b, fa, fb)
    if A * fa > 0:
        c = a
    else:
        c = b
    for _ in range(1, count + 1):
        c -= safe_div(
            fa + (B + A * (c - b)) * (c - a), B + A * (2.0 * c - a - b), 1.0 + c - a
        )
    if (c <= a) or (c >= b):
        c = secant_interpolate(a, b, fa, fb)
    return c