Average Error: 53.4 → 40.2
Time: 7.1s
Precision: binary64
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \leq -1.345236605992239 \cdot 10^{+154}:\\ \;\;\;\;\log \left(\frac{-1}{x}\right)\\ \mathbf{elif}\;x \leq -3.43856601333689 \cdot 10^{-08}:\\ \;\;\;\;\log \left(\frac{-1}{x - \sqrt{x \cdot x + 1}}\right)\\ \mathbf{elif}\;x \leq 1.345072362821146 \cdot 10^{+154}:\\ \;\;\;\;\log \left(x + \left|\sqrt[3]{x \cdot x + 1}\right| \cdot \sqrt{\sqrt[3]{x \cdot x + 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log x\\ \end{array}\]
\log \left(x + \sqrt{x \cdot x + 1}\right)
\begin{array}{l}
\mathbf{if}\;x \leq -1.345236605992239 \cdot 10^{+154}:\\
\;\;\;\;\log \left(\frac{-1}{x}\right)\\

\mathbf{elif}\;x \leq -3.43856601333689 \cdot 10^{-08}:\\
\;\;\;\;\log \left(\frac{-1}{x - \sqrt{x \cdot x + 1}}\right)\\

\mathbf{elif}\;x \leq 1.345072362821146 \cdot 10^{+154}:\\
\;\;\;\;\log \left(x + \left|\sqrt[3]{x \cdot x + 1}\right| \cdot \sqrt{\sqrt[3]{x \cdot x + 1}}\right)\\

\mathbf{else}:\\
\;\;\;\;\log x\\

\end{array}
(FPCore (x) :precision binary64 (log (+ x (sqrt (+ (* x x) 1.0)))))
(FPCore (x)
 :precision binary64
 (if (<= x -1.345236605992239e+154)
   (log (/ -1.0 x))
   (if (<= x -3.43856601333689e-08)
     (log (/ -1.0 (- x (sqrt (+ (* x x) 1.0)))))
     (if (<= x 1.345072362821146e+154)
       (log
        (+ x (* (fabs (cbrt (+ (* x x) 1.0))) (sqrt (cbrt (+ (* x x) 1.0))))))
       (log x)))))
double code(double x) {
	return log(x + sqrt((x * x) + 1.0));
}
double code(double x) {
	double tmp;
	if (x <= -1.345236605992239e+154) {
		tmp = log(-1.0 / x);
	} else if (x <= -3.43856601333689e-08) {
		tmp = log(-1.0 / (x - sqrt((x * x) + 1.0)));
	} else if (x <= 1.345072362821146e+154) {
		tmp = log(x + (fabs(cbrt((x * x) + 1.0)) * sqrt(cbrt((x * x) + 1.0))));
	} else {
		tmp = log(x);
	}
	return tmp;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original53.4
Target45.6
Herbie40.2
\[\begin{array}{l} \mathbf{if}\;x < 0:\\ \;\;\;\;\log \left(\frac{-1}{x - \sqrt{x \cdot x + 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + \sqrt{x \cdot x + 1}\right)\\ \end{array}\]

Derivation

  1. Split input into 4 regimes
  2. if x < -1.345236605992239e154

    1. Initial program 64.0

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Using strategy rm
    3. Applied flip-+_binary6464.0

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

      \[\leadsto \log \left(\frac{\color{blue}{-1}}{x - \sqrt{x \cdot x + 1}}\right)\]
    5. Taylor expanded around 0 42.9

      \[\leadsto \log \left(\frac{-1}{x - \color{blue}{0}}\right)\]

    if -1.345236605992239e154 < x < -3.43856601333689028e-8

    1. Initial program 59.0

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

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

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

    if -3.43856601333689028e-8 < x < 1.3450723628211461e154

    1. Initial program 47.8

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

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

      \[\leadsto \log \left(x + \color{blue}{\sqrt{\sqrt[3]{x \cdot x + 1} \cdot \sqrt[3]{x \cdot x + 1}} \cdot \sqrt{\sqrt[3]{x \cdot x + 1}}}\right)\]
    5. Simplified47.8

      \[\leadsto \log \left(x + \color{blue}{\left|\sqrt[3]{x \cdot x + 1}\right|} \cdot \sqrt{\sqrt[3]{x \cdot x + 1}}\right)\]

    if 1.3450723628211461e154 < x

    1. Initial program 64.0

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

      \[\leadsto \log \left(x + \color{blue}{0}\right)\]
  3. Recombined 4 regimes into one program.
  4. Final simplification40.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \leq -1.345236605992239 \cdot 10^{+154}:\\ \;\;\;\;\log \left(\frac{-1}{x}\right)\\ \mathbf{elif}\;x \leq -3.43856601333689 \cdot 10^{-08}:\\ \;\;\;\;\log \left(\frac{-1}{x - \sqrt{x \cdot x + 1}}\right)\\ \mathbf{elif}\;x \leq 1.345072362821146 \cdot 10^{+154}:\\ \;\;\;\;\log \left(x + \left|\sqrt[3]{x \cdot x + 1}\right| \cdot \sqrt{\sqrt[3]{x \cdot x + 1}}\right)\\ \mathbf{else}:\\ \;\;\;\;\log x\\ \end{array}\]

Reproduce

herbie shell --seed 2020288 
(FPCore (x)
  :name "Hyperbolic arcsine"
  :precision binary64

  :herbie-target
  (if (< x 0.0) (log (/ -1.0 (- x (sqrt (+ (* x x) 1.0))))) (log (+ x (sqrt (+ (* x x) 1.0)))))

  (log (+ x (sqrt (+ (* x x) 1.0)))))