Average Error: 38.8 → 0.2
Time: 12.0s
Precision: 64
\[\log \left(1 + x\right)\]
\[\begin{array}{l} \mathbf{if}\;x + 1 \le 1.000007462280689596312299727287609130144:\\ \;\;\;\;\left(\left(\left(1 \cdot {x}^{3} + \left(1 \cdot x + 0.5 \cdot \frac{x \cdot x}{{1}^{2}}\right)\right) + \frac{0.3333333333333333148296162562473909929395}{\frac{{1}^{3}}{{x}^{3}}}\right) - \frac{{x}^{3}}{1}\right) - \left(x \cdot x\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + 1\right)\\ \end{array}\]
\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;x + 1 \le 1.000007462280689596312299727287609130144:\\
\;\;\;\;\left(\left(\left(1 \cdot {x}^{3} + \left(1 \cdot x + 0.5 \cdot \frac{x \cdot x}{{1}^{2}}\right)\right) + \frac{0.3333333333333333148296162562473909929395}{\frac{{1}^{3}}{{x}^{3}}}\right) - \frac{{x}^{3}}{1}\right) - \left(x \cdot x\right) \cdot 1\\

\mathbf{else}:\\
\;\;\;\;\log \left(x + 1\right)\\

\end{array}
double f(double x) {
        double r57746 = 1.0;
        double r57747 = x;
        double r57748 = r57746 + r57747;
        double r57749 = log(r57748);
        return r57749;
}

double f(double x) {
        double r57750 = x;
        double r57751 = 1.0;
        double r57752 = r57750 + r57751;
        double r57753 = 1.0000074622806896;
        bool r57754 = r57752 <= r57753;
        double r57755 = 3.0;
        double r57756 = pow(r57750, r57755);
        double r57757 = r57751 * r57756;
        double r57758 = r57751 * r57750;
        double r57759 = 0.5;
        double r57760 = r57750 * r57750;
        double r57761 = 2.0;
        double r57762 = pow(r57751, r57761);
        double r57763 = r57760 / r57762;
        double r57764 = r57759 * r57763;
        double r57765 = r57758 + r57764;
        double r57766 = r57757 + r57765;
        double r57767 = 0.3333333333333333;
        double r57768 = pow(r57751, r57755);
        double r57769 = r57768 / r57756;
        double r57770 = r57767 / r57769;
        double r57771 = r57766 + r57770;
        double r57772 = r57756 / r57751;
        double r57773 = r57771 - r57772;
        double r57774 = r57760 * r57751;
        double r57775 = r57773 - r57774;
        double r57776 = log(r57752);
        double r57777 = r57754 ? r57775 : r57776;
        return r57777;
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original38.8
Target0.1
Herbie0.2
\[\begin{array}{l} \mathbf{if}\;1 + x = 1:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\frac{x \cdot \log \left(1 + x\right)}{\left(1 + x\right) - 1}\\ \end{array}\]

Derivation

  1. Split input into 2 regimes
  2. if (+ 1.0 x) < 1.0000074622806896

    1. Initial program 59.1

      \[\log \left(1 + x\right)\]
    2. Using strategy rm
    3. Applied flip3-+59.2

      \[\leadsto \log \color{blue}{\left(\frac{{1}^{3} + {x}^{3}}{1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)}\right)}\]
    4. Applied log-div59.1

      \[\leadsto \color{blue}{\log \left({1}^{3} + {x}^{3}\right) - \log \left(1 \cdot 1 + \left(x \cdot x - 1 \cdot x\right)\right)}\]
    5. Simplified59.1

      \[\leadsto \log \left({1}^{3} + {x}^{3}\right) - \color{blue}{\log \left({1}^{2} + x \cdot \left(x - 1\right)\right)}\]
    6. Taylor expanded around 0 0.3

      \[\leadsto \color{blue}{\left(1 \cdot {x}^{3} + \left(0.3333333333333333148296162562473909929395 \cdot \frac{{x}^{3}}{{1}^{3}} + \left(0.5 \cdot \frac{{x}^{2}}{{1}^{2}} + 1 \cdot x\right)\right)\right) - \left(1 \cdot \frac{{x}^{3}}{{1}^{2}} + 1 \cdot {x}^{2}\right)}\]
    7. Simplified0.3

      \[\leadsto \color{blue}{\left(\left(\frac{0.3333333333333333148296162562473909929395}{\frac{{1}^{3}}{{x}^{3}}} + \left(\left(0.5 \cdot \frac{x \cdot x}{{1}^{2}} + x \cdot 1\right) + 1 \cdot {x}^{3}\right)\right) - 1 \cdot \frac{{x}^{3}}{1}\right) - 1 \cdot \left(x \cdot x\right)}\]

    if 1.0000074622806896 < (+ 1.0 x)

    1. Initial program 0.1

      \[\log \left(1 + x\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.2

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + 1 \le 1.000007462280689596312299727287609130144:\\ \;\;\;\;\left(\left(\left(1 \cdot {x}^{3} + \left(1 \cdot x + 0.5 \cdot \frac{x \cdot x}{{1}^{2}}\right)\right) + \frac{0.3333333333333333148296162562473909929395}{\frac{{1}^{3}}{{x}^{3}}}\right) - \frac{{x}^{3}}{1}\right) - \left(x \cdot x\right) \cdot 1\\ \mathbf{else}:\\ \;\;\;\;\log \left(x + 1\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2019194 
(FPCore (x)
  :name "ln(1 + x)"

  :herbie-target
  (if (== (+ 1.0 x) 1.0) x (/ (* x (log (+ 1.0 x))) (- (+ 1.0 x) 1.0)))

  (log (+ 1.0 x)))