from math import sin, cos, sqrt, atan, radians


def calc_distance(position_start: tuple, position_end: tuple) -> float:
    """Calculates the distance between two positions in format (lat, lon)
    """
    f = 1 / 298.257223563
    a = 6378173
    F = radians((position_start[0] + position_end[0]) / 2.0)
    G = radians((position_start[0] - position_end[0]) / 2.0)
    l = radians((position_start[1] - position_end[1]) / 2.0)
    S = sin(G) ** 2 * cos(l) ** 2 + cos(F) ** 2 * sin(l) ** 2
    C = cos(G) ** 2 * cos(l) ** 2 + sin(F) ** 2 * sin(l) ** 2
    w = atan(sqrt(S / C))
    if float(w) == 0.0:
        return 0.0
    D = 2 * w * a
    T = sqrt(S * C) / w
    H_1 = (3 * T - 1) / (2 * C)
    H_2 = (3 * T + 1) / (2 * S)
    return D * (1 + f * H_1 * sin(F) ** 2 * cos(G) ** 2 - f * H_2 * cos(F) ** 2 * sin(G) ** 2)