Average Error: 32.7 → 0.2
Time: 2.9s
Precision: 64
\[\log \left(x + \sqrt{x \cdot x - 1}\right)\]
\[\log \left(\mathsf{fma}\left(2, 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(\mathsf{fma}\left(2, x, -\mathsf{fma}\left(0.5, \frac{1}{x}, 0.125 \cdot \frac{1}{{x}^{3}}\right)\right)\right)
double f(double x) {
        double r39029 = x;
        double r39030 = r39029 * r39029;
        double r39031 = 1.0;
        double r39032 = r39030 - r39031;
        double r39033 = sqrt(r39032);
        double r39034 = r39029 + r39033;
        double r39035 = log(r39034);
        return r39035;
}

double f(double x) {
        double r39036 = 2.0;
        double r39037 = x;
        double r39038 = 0.5;
        double r39039 = 1.0;
        double r39040 = r39039 / r39037;
        double r39041 = 0.125;
        double r39042 = 3.0;
        double r39043 = pow(r39037, r39042);
        double r39044 = r39039 / r39043;
        double r39045 = r39041 * r39044;
        double r39046 = fma(r39038, r39040, r39045);
        double r39047 = -r39046;
        double r39048 = fma(r39036, r39037, r39047);
        double r39049 = log(r39048);
        return r39049;
}

Error

Bits error versus x

Derivation

  1. Initial program 32.7

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

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

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

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

Reproduce

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