I'm trying to calculate the distance between two geodetic points in two different ways. The points are:
A:(41.466138, 15.547839)
B:(41.467216, 15.547025)
The distance between the two points is pretty small (about 130/140 meters)
1) I have used the Haversine forumla that using this site gives me the following result:

So the mesured distance using the Haversine formula is 137,7 meters.
2) I have tried to calculate the distance transformating the geodetic coordinates (latitude, longitude) in cartesian coordinates (x, y). I have calculated the (x,y) coordinates for A and B:
R = 6371; //radius of the earth
X = R * Math.cos(lat) * Math.cos(lon); // lon and lat are in radiants (which is not the same as provided above, must multiply by Pi / 180)
Y = R * Math.cos(lat) * Math.sin(lon);
So I obtained:
A: (4599,392641683213, 1279,6610297820203)
B: (4599,334350798723, 1279,574411410788)
NOTE: It assumes that the altitude is negligible in A and B.
Now that I have the cartesian coordinates I can calculate the distance using Pitagora's theorem, so:
|Xb - Xa| = 4599,392641683213 - 4599,334350798723 = 0,05829 Km
|Yb - Ya| = 1279,6610297820203 - 1279,574411410788 = 0,08662 Km
distanceAB = sqrt(0,05829^2 + 0,08662^2) = 0,1044 Km = 104,4 m
As you can see the distance calculated with the above methods generate different values:
137,7 m for with the former, 104,4 m with the latter.
Why this happen?