Average Error: 31.4 → 0.0
Time: 5.2s
Precision: 64
\[\log \left(x + \sqrt{x \cdot x - 1}\right)\]
\[\log \left(\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(\mathsf{fma}\left(\sqrt{x - \sqrt{1}}, \sqrt{x + \sqrt{1}}, x\right)\right)
double code(double x) {
	return log((x + sqrt(((x * x) - 1.0))));
}
double code(double x) {
	return log(fma(sqrt((x - sqrt(1.0))), sqrt((x + sqrt(1.0))), x));
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Derivation

  1. Initial program 31.4

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

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

    \[\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-log-exp0.1

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

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

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

Reproduce

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