Commit 898bafbb authored by Matthieu Schaller's avatar Matthieu Schaller

Document the accuracy achieved by the new approximation

parent fedce813
......@@ -86,7 +86,10 @@ kernel_long_grav_derivatives(const float r, const float r_s_inv,
const float e = expf(-u2);
/* Compute erfcf(u) using eq. 7.1.25 of
Abramowitz & Stegun, 1972. */
* Abramowitz & Stegun, 1972.
*
* This has a *relative* error of less than 4e-3 over
* the range of interest (0 < u < 5) */
const float t = 1.f / (1.f + 0.47047f * u);
......
......@@ -37,8 +37,10 @@ const int num_tests = 1 << 10;
void check_value(double a, double b, const char* s, const double tol,
const double r, const double r_s) {
if (fabs(a - b) / fabs(a + b) > tol)
error("Values are inconsistent: %12.15e %12.15e rel=%e (%s for r_s=%e r/r_s=%e)!",
a, b, fabs(a - b) / fabs(a + b), s, r_s, r / r_s);
error(
"Values are inconsistent: %12.15e %12.15e rel=%e (%s for r_s=%e "
"r/r_s=%e)!",
a, b, fabs(a - b) / fabs(a + b), s, r_s, r / r_s);
}
int main(int argc, char* argv[]) {
......@@ -92,7 +94,7 @@ int main(int argc, char* argv[]) {
(12. * pow(r_s, 4.) - 12. * r_s * r_s * r * r + pow(r, 4.)) *
pow(r_s, -9.);
check_value(chi_swift.chi_0, chi_0, "chi_0", 4e-3, r, r_s);
check_value(chi_swift.chi_0, chi_0, "chi_0", 3.4e-3, r, r_s);
check_value(chi_swift.chi_1, chi_1, "chi_1", 1e-5, r, r_s);
check_value(chi_swift.chi_2, chi_2, "chi_2", 1e-5, r, r_s);
check_value(chi_swift.chi_3, chi_3, "chi_3", 1e-4, r, r_s);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment