Average Error: 53.5 → 0.2
Time: 6.5s
Precision: 64
\[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le -1.01029387074236721:\\ \;\;\;\;\log \left(1 \cdot \left(\frac{\left(1 \cdot 1\right) \cdot \frac{1}{8}}{{x}^{3}} - \left(\frac{1}{16} \cdot \frac{{\left(\sqrt{1}\right)}^{6}}{{x}^{5}} - \left(-\frac{1}{2}\right) \cdot \frac{1}{x}\right)\right)\right)\\ \mathbf{elif}\;x \le 9.17194589536015031 \cdot 10^{-4}:\\ \;\;\;\;\left(\log \left(\sqrt{1}\right) + \frac{x}{\sqrt{1}}\right) - \frac{1}{6} \cdot \frac{{x}^{3}}{{\left(\sqrt{1}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 \cdot \left(\mathsf{hypot}\left(x, \sqrt{1}\right) + x\right)\right)\\ \end{array}\]
\log \left(x + \sqrt{x \cdot x + 1}\right)
\begin{array}{l}
\mathbf{if}\;x \le -1.01029387074236721:\\
\;\;\;\;\log \left(1 \cdot \left(\frac{\left(1 \cdot 1\right) \cdot \frac{1}{8}}{{x}^{3}} - \left(\frac{1}{16} \cdot \frac{{\left(\sqrt{1}\right)}^{6}}{{x}^{5}} - \left(-\frac{1}{2}\right) \cdot \frac{1}{x}\right)\right)\right)\\

\mathbf{elif}\;x \le 9.17194589536015031 \cdot 10^{-4}:\\
\;\;\;\;\left(\log \left(\sqrt{1}\right) + \frac{x}{\sqrt{1}}\right) - \frac{1}{6} \cdot \frac{{x}^{3}}{{\left(\sqrt{1}\right)}^{3}}\\

\mathbf{else}:\\
\;\;\;\;\log \left(1 \cdot \left(\mathsf{hypot}\left(x, \sqrt{1}\right) + x\right)\right)\\

\end{array}
double f(double x) {
        double r201673 = x;
        double r201674 = r201673 * r201673;
        double r201675 = 1.0;
        double r201676 = r201674 + r201675;
        double r201677 = sqrt(r201676);
        double r201678 = r201673 + r201677;
        double r201679 = log(r201678);
        return r201679;
}

double f(double x) {
        double r201680 = x;
        double r201681 = -1.0102938707423672;
        bool r201682 = r201680 <= r201681;
        double r201683 = 1.0;
        double r201684 = 1.0;
        double r201685 = r201684 * r201684;
        double r201686 = 0.125;
        double r201687 = r201685 * r201686;
        double r201688 = 3.0;
        double r201689 = pow(r201680, r201688);
        double r201690 = r201687 / r201689;
        double r201691 = 0.0625;
        double r201692 = sqrt(r201684);
        double r201693 = 6.0;
        double r201694 = pow(r201692, r201693);
        double r201695 = 5.0;
        double r201696 = pow(r201680, r201695);
        double r201697 = r201694 / r201696;
        double r201698 = r201691 * r201697;
        double r201699 = 0.5;
        double r201700 = -r201699;
        double r201701 = r201684 / r201680;
        double r201702 = r201700 * r201701;
        double r201703 = r201698 - r201702;
        double r201704 = r201690 - r201703;
        double r201705 = r201683 * r201704;
        double r201706 = log(r201705);
        double r201707 = 0.000917194589536015;
        bool r201708 = r201680 <= r201707;
        double r201709 = log(r201692);
        double r201710 = r201680 / r201692;
        double r201711 = r201709 + r201710;
        double r201712 = 0.16666666666666666;
        double r201713 = pow(r201692, r201688);
        double r201714 = r201689 / r201713;
        double r201715 = r201712 * r201714;
        double r201716 = r201711 - r201715;
        double r201717 = hypot(r201680, r201692);
        double r201718 = r201717 + r201680;
        double r201719 = r201683 * r201718;
        double r201720 = log(r201719);
        double r201721 = r201708 ? r201716 : r201720;
        double r201722 = r201682 ? r201706 : r201721;
        return r201722;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original53.5
Target45.6
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;x \lt 0.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 3 regimes
  2. if x < -1.0102938707423672

    1. Initial program 62.7

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Using strategy rm
    3. Applied *-un-lft-identity62.7

      \[\leadsto \log \left(x + \color{blue}{1 \cdot \sqrt{x \cdot x + 1}}\right)\]
    4. Applied *-un-lft-identity62.7

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

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

      \[\leadsto \log \left(1 \cdot \color{blue}{\left(\mathsf{hypot}\left(x, \sqrt{1}\right) + x\right)}\right)\]
    7. Taylor expanded around -inf 0.2

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

      \[\leadsto \log \left(1 \cdot \color{blue}{\left(\frac{\left(1 \cdot 1\right) \cdot \frac{1}{8}}{{x}^{3}} - \left(\frac{1}{16} \cdot \frac{{\left(\sqrt{1}\right)}^{6}}{{x}^{5}} - \left(-\frac{1}{2}\right) \cdot \frac{1}{x}\right)\right)}\right)\]

    if -1.0102938707423672 < x < 0.000917194589536015

    1. Initial program 58.9

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

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

    if 0.000917194589536015 < x

    1. Initial program 32.4

      \[\log \left(x + \sqrt{x \cdot x + 1}\right)\]
    2. Using strategy rm
    3. Applied *-un-lft-identity32.4

      \[\leadsto \log \left(x + \color{blue}{1 \cdot \sqrt{x \cdot x + 1}}\right)\]
    4. Applied *-un-lft-identity32.4

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

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

      \[\leadsto \log \left(1 \cdot \color{blue}{\left(\mathsf{hypot}\left(x, \sqrt{1}\right) + x\right)}\right)\]
  3. Recombined 3 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x \le -1.01029387074236721:\\ \;\;\;\;\log \left(1 \cdot \left(\frac{\left(1 \cdot 1\right) \cdot \frac{1}{8}}{{x}^{3}} - \left(\frac{1}{16} \cdot \frac{{\left(\sqrt{1}\right)}^{6}}{{x}^{5}} - \left(-\frac{1}{2}\right) \cdot \frac{1}{x}\right)\right)\right)\\ \mathbf{elif}\;x \le 9.17194589536015031 \cdot 10^{-4}:\\ \;\;\;\;\left(\log \left(\sqrt{1}\right) + \frac{x}{\sqrt{1}}\right) - \frac{1}{6} \cdot \frac{{x}^{3}}{{\left(\sqrt{1}\right)}^{3}}\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 \cdot \left(\mathsf{hypot}\left(x, \sqrt{1}\right) + x\right)\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020020 +o rules:numerics
(FPCore (x)
  :name "Hyperbolic arcsine"
  :precision binary64

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

  (log (+ x (sqrt (+ (* x x) 1)))))