Average Error: 32.5 → 0.1
Time: 17.2s
Precision: 64
\[\log \left(x + \sqrt{x \cdot x - 1}\right)\]
\[\log \left(\sqrt{\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)}\right) + \log \left(\sqrt{\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)}\right)\]
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(\sqrt{\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)}\right) + \log \left(\sqrt{\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)}\right)
double f(double x) {
        double r96654 = x;
        double r96655 = r96654 * r96654;
        double r96656 = 1.0;
        double r96657 = r96655 - r96656;
        double r96658 = sqrt(r96657);
        double r96659 = r96654 + r96658;
        double r96660 = log(r96659);
        return r96660;
}

double f(double x) {
        double r96661 = x;
        double r96662 = 1.0;
        double r96663 = sqrt(r96662);
        double r96664 = r96661 - r96663;
        double r96665 = sqrt(r96664);
        double r96666 = r96661 + r96663;
        double r96667 = sqrt(r96666);
        double r96668 = fma(r96665, r96667, r96661);
        double r96669 = sqrt(r96668);
        double r96670 = log(r96669);
        double r96671 = r96670 + r96670;
        return r96671;
}

Error

Bits error versus x

Derivation

  1. Initial program 32.5

    \[\log \left(x + \sqrt{x \cdot x - 1}\right)\]
  2. Using strategy rm
  3. Applied add-sqr-sqrt32.5

    \[\leadsto \log \left(x + \sqrt{x \cdot x - \color{blue}{\sqrt{1} \cdot \sqrt{1}}}\right)\]
  4. Applied difference-of-squares32.5

    \[\leadsto \log \left(x + \sqrt{\color{blue}{\left(x + \sqrt{1}\right) \cdot \left(x - \sqrt{1}\right)}}\right)\]
  5. Applied sqrt-prod0.1

    \[\leadsto \log \left(x + \color{blue}{\sqrt{x + \sqrt{1}} \cdot \sqrt{x - \sqrt{1}}}\right)\]
  6. Using strategy rm
  7. Applied add-sqr-sqrt0.1

    \[\leadsto \log \color{blue}{\left(\sqrt{x + \sqrt{x + \sqrt{1}} \cdot \sqrt{x - \sqrt{1}}} \cdot \sqrt{x + \sqrt{x + \sqrt{1}} \cdot \sqrt{x - \sqrt{1}}}\right)}\]
  8. Applied log-prod0.1

    \[\leadsto \color{blue}{\log \left(\sqrt{x + \sqrt{x + \sqrt{1}} \cdot \sqrt{x - \sqrt{1}}}\right) + \log \left(\sqrt{x + \sqrt{x + \sqrt{1}} \cdot \sqrt{x - \sqrt{1}}}\right)}\]
  9. Simplified0.1

    \[\leadsto \color{blue}{\log \left(\sqrt{\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)}\right)} + \log \left(\sqrt{x + \sqrt{x + \sqrt{1}} \cdot \sqrt{x - \sqrt{1}}}\right)\]
  10. Simplified0.1

    \[\leadsto \log \left(\sqrt{\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)}\right) + \color{blue}{\log \left(\sqrt{\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)}\right)}\]
  11. Final simplification0.1

    \[\leadsto \log \left(\sqrt{\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)}\right) + \log \left(\sqrt{\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)}\right)\]

Reproduce

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