Average Error: 32.1 → 0.0
Time: 10.3s
Precision: 64
\[\log \left(x + \sqrt{x \cdot x - 1}\right)\]
\[\log \left(e^{\log \left(\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)\right)}\right)\]
\log \left(x + \sqrt{x \cdot x - 1}\right)
\log \left(e^{\log \left(\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)\right)}\right)
double f(double x) {
        double r65747 = x;
        double r65748 = r65747 * r65747;
        double r65749 = 1.0;
        double r65750 = r65748 - r65749;
        double r65751 = sqrt(r65750);
        double r65752 = r65747 + r65751;
        double r65753 = log(r65752);
        return r65753;
}

double f(double x) {
        double r65754 = x;
        double r65755 = 1.0;
        double r65756 = sqrt(r65755);
        double r65757 = r65754 - r65756;
        double r65758 = sqrt(r65757);
        double r65759 = r65754 + r65756;
        double r65760 = sqrt(r65759);
        double r65761 = fma(r65758, r65760, r65754);
        double r65762 = log(r65761);
        double r65763 = exp(r65762);
        double r65764 = log(r65763);
        return r65764;
}

Error

Bits error versus x

Derivation

  1. Initial program 32.1

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

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

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

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

    \[\leadsto \log \left(x + \color{blue}{\sqrt{\sqrt{1} + x}} \cdot \sqrt{x - \sqrt{1}}\right)\]
  7. Using strategy rm
  8. Applied add-exp-log0.0

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

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

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

Reproduce

herbie shell --seed 2019195 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic arc-cosine"
  (log (+ x (sqrt (- (* x x) 1.0)))))