






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

from .haversine_distance import haversine_distance

UpperCamelCase        =				6_378_137.0
UpperCamelCase        =				6_356_752.314_245
UpperCamelCase        =				6_378_137




def 				A		(					lowercase__  :  float ,		lowercase__  :  float ,		lowercase__  :  float ,		lowercase__  :  float  )		-> float:
	UpperCamelCase__ :List[str]						=      (AXIS_A - AXIS_B) / AXIS_A
	# Parametric latitudes
	# https://en.wikipedia.org/wiki/Latitude#Parametric_(or_reduced)_latitude
	UpperCamelCase__ :str						=      atan((1 - flattening) * tan(radians(lowercase__  )  )  )
	UpperCamelCase__ :Dict						=      atan((1 - flattening) * tan(radians(lowercase__  )  )  )

	# Compute central angle between two points
	# using haversine theta. sigma =  haversine_distance / equatorial radius
	UpperCamelCase__ :int						=      haversine_distance(lowercase__ ,		lowercase__ ,		lowercase__ ,		lowercase__  ) / EQUATORIAL_RADIUS

	# Intermediate P and Q values
	UpperCamelCase__ :str						=      (b_lata + b_lata) / 2
	UpperCamelCase__ :List[str]						=      (b_lata - b_lata) / 2

	# Intermediate X value
	# X = (sigma - sin(sigma)) * sin^2Pcos^2Q / cos^2(sigma/2)
	UpperCamelCase__ :str						=      (sin(lowercase__  ) ** 2) * (cos(lowercase__  ) ** 2)
	UpperCamelCase__ :Union[str, Any]						=      cos(sigma / 2  ) ** 2
	UpperCamelCase__ :Tuple						=      (sigma - sin(lowercase__  )) * (x_numerator / x_demonimator)

	# Intermediate Y value
	# Y = (sigma + sin(sigma)) * cos^2Psin^2Q / sin^2(sigma/2)
	UpperCamelCase__ :Optional[int]						=      (cos(lowercase__  ) ** 2) * (sin(lowercase__  ) ** 2)
	UpperCamelCase__ :Optional[Any]						=      sin(sigma / 2  ) ** 2
	UpperCamelCase__ :List[str]						=      (sigma + sin(lowercase__  )) * (y_numerator / y_denominator)

	return EQUATORIAL_RADIUS * (sigma - ((flattening / 2) * (x_value + y_value)))


if __name__ == "__main__":
							import doctest

							doctest.testmod()
'''simple docstring'''




def __lowerCAmelCase					(				UpperCamelCase__							)      ->       float:
    __lowerCamelCase            =    0
    while len(UpperCamelCase__							) > 1:
        __lowerCamelCase            =    0
        # Consider two files with minimum cost to be merged
        for _ in range(2							):
            __lowerCamelCase            =    files.index(min(UpperCamelCase__							)							)
            temp += files[min_index]
            files.pop(UpperCamelCase__							)
        files.append(UpperCamelCase__							)
        optimal_merge_cost += temp
    return optimal_merge_cost


if __name__ == "__main__":
  import doctest

  doctest.testmod()
