title: Find distance between 2 lat and lon point. I have used the formula but answer is not what you expect
body: <pre><code>public double distance(double x, double y, double x2, double y2) {
      // r is earth’s radius (mean radius = 6,371km)
      double r = 6371e3; 
      double toMile = 0.000621371;
      double latDiff = x2 - x;
      double lonDiff = y2 - y;
  
      // a is the square of half the chord length between the points
      double a = (Math.sin(latDiff/2) * Math.sin(latDiff/2)) + (Math.cos(x) * Math.cos(x2) * Math.sin(lonDiff/2) * Math.sin(lonDiff/2));
  
      // c is the angular distance in radians
      double c = 2 * Math.atan2(Math.sqrt(a), Math.sqrt(1-a));
  
      // d is the distance between to points
      double d = r * c * toMile;
  
      return d;
  }
  
  System.out.println(distance(41.386263640000003, -81.494450689999994, 42.531041999999999, -82.90854831)); 
  </code></pre>
  
  <p>This print statement gives me 4148.871894445495 miles whereas I checked through google map its distance is 193 miles. Can someone explain why is this so.</p>
  
  <p>Thank you.</p>