Can anyone please explain the meaning of the cos((y1+y2)/2) in this formula please?
Note: the constant 6371 is the earth's radius
Can anyone please explain the meaning of the cos((y1+y2)/2) in this formula please?
Note: the constant 6371 is the earth's radius
Copyright © 2021 JogjaFile Inc.

Here's a picture of the earth with the top sliced off at latitude $\theta$:
The circle around the earth at latitude $\theta$ has radius $R \cos(\theta)$ where $R$ is the radius of the earth. Just as its radius is multiplied by $\cos(\theta)$ compared to the equator, its circumference is multiplied by $\cos(\theta)$. The difference between longitudes of points at a given latitude tells us what fraction of the circle at that latitude lies between the points. So the distance between points at longitudes $longitudeA$ and $longitudeB$ and the same latitude $\theta$ is $\cos(\theta)$ times what that distance would be if the points were at the equator.
It's more complicated if the points are at different latitudes as well as different longitudes, but as an approximation the "x" part of the distance can be taken to be what the distance would be if we took the latitude to be the average of the latitudes of the two points.