From Asbjørn, 7 Years ago, written in C++.
Embed
  1. #include <boost/multiprecision/cpp_dec_float.hpp>
  2. #include <iostream>
  3.  
  4. int main()
  5. {
  6.         using namespace boost::multiprecision;
  7.  
  8.         typedef number<cpp_dec_float<10000> > number_t;
  9.  
  10.         number_t earth_age = 6000; // years
  11.         number_t T = earth_age * 31557600; // seconds per Julian year
  12.         number_t g = 9.81; // m/s^2
  13.         number_t c = 299792458; // m/s
  14.  
  15.         number_t phi = (g * T) / c;
  16.         number_t beta = tanh(phi);
  17.         number_t inv_gamma = sqrt(1.0 - (beta*beta));
  18.  
  19.         std::cout << std::setprecision(std::numeric_limits<number_t>::max_digits10);
  20.         std::cout << "beta = " << beta << std::endl << std::endl;
  21.         std::cout << "inv_gamma = " << inv_gamma << std::endl << std::endl;
  22.  
  23.         number_t earth_radius = 6371 * 1000; // meters
  24.         number_t flat_earth = 2 * earth_radius * inv_gamma;
  25.  
  26.         std::cout << std::setprecision(10);
  27.         std::cout << "flat earth thickness = " << flat_earth << " meters" << std::endl << std::endl;
  28.  
  29.  
  30.         return 0;
  31. }
  32.  
  33.