Average Error: 31.4 → 0.3
Time: 1.9s
Precision: 64
\[\log \left(x + \sqrt{x \cdot x - 1}\right)\]
\[\log \left(x + \left(x - \mathsf{fma}\left(0.5, \frac{1}{x}, 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)\right)\]
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(x + \left(x - \mathsf{fma}\left(0.5, \frac{1}{x}, 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)\right)
double f(double x) {
        double r77869 = x;
        double r77870 = r77869 * r77869;
        double r77871 = 1.0;
        double r77872 = r77870 - r77871;
        double r77873 = sqrt(r77872);
        double r77874 = r77869 + r77873;
        double r77875 = log(r77874);
        return r77875;
}

double f(double x) {
        double r77876 = x;
        double r77877 = 0.5;
        double r77878 = 1.0;
        double r77879 = r77878 / r77876;
        double r77880 = 0.125;
        double r77881 = 3.0;
        double r77882 = pow(r77876, r77881);
        double r77883 = r77878 / r77882;
        double r77884 = r77880 * r77883;
        double r77885 = fma(r77877, r77879, r77884);
        double r77886 = r77876 - r77885;
        double r77887 = r77876 + r77886;
        double r77888 = log(r77887);
        return r77888;
}

Error

Bits error versus x

Derivation

  1. Initial program 31.4

    \[\log \left(x + \sqrt{x \cdot x - 1}\right)\]
  2. Taylor expanded around inf 0.3

    \[\leadsto \log \left(x + \color{blue}{\left(x - \left(0.5 \cdot \frac{1}{x} + 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)}\right)\]
  3. Simplified0.3

    \[\leadsto \log \left(x + \color{blue}{\left(x - \mathsf{fma}\left(0.5, \frac{1}{x}, 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)}\right)\]
  4. Final simplification0.3

    \[\leadsto \log \left(x + \left(x - \mathsf{fma}\left(0.5, \frac{1}{x}, 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)\right)\]

Reproduce

herbie shell --seed 2020024 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic arc-cosine"
  :precision binary64
  (log (+ x (sqrt (- (* x x) 1)))))