Average Error: 38.8 → 0.2
Time: 10.0s
Precision: 64
\[\log \left(1 + x\right)\]
\[\begin{array}{l} \mathbf{if}\;1 + x \le 1.00000051390067646:\\ \;\;\;\;\left(x \cdot \left(\sqrt[3]{1} \cdot \left(\left(0.1388888888888889 \cdot {x}^{2} + 1\right) - 0.333333333333333315 \cdot x\right) - 0.166666666666666657 \cdot \left(\sqrt[3]{\frac{1}{{1}^{5}}} \cdot {x}^{2}\right)\right)\right) \cdot \sqrt[3]{1 - 0.5 \cdot x} + \log 1\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 + x\right)\\ \end{array}\]
\log \left(1 + x\right)
\begin{array}{l}
\mathbf{if}\;1 + x \le 1.00000051390067646:\\
\;\;\;\;\left(x \cdot \left(\sqrt[3]{1} \cdot \left(\left(0.1388888888888889 \cdot {x}^{2} + 1\right) - 0.333333333333333315 \cdot x\right) - 0.166666666666666657 \cdot \left(\sqrt[3]{\frac{1}{{1}^{5}}} \cdot {x}^{2}\right)\right)\right) \cdot \sqrt[3]{1 - 0.5 \cdot x} + \log 1\\

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

\end{array}
double f(double x) {
        double r63468 = 1.0;
        double r63469 = x;
        double r63470 = r63468 + r63469;
        double r63471 = log(r63470);
        return r63471;
}

double f(double x) {
        double r63472 = 1.0;
        double r63473 = x;
        double r63474 = r63472 + r63473;
        double r63475 = 1.0000005139006765;
        bool r63476 = r63474 <= r63475;
        double r63477 = cbrt(r63472);
        double r63478 = 0.1388888888888889;
        double r63479 = 2.0;
        double r63480 = pow(r63473, r63479);
        double r63481 = r63478 * r63480;
        double r63482 = 1.0;
        double r63483 = r63481 + r63482;
        double r63484 = 0.3333333333333333;
        double r63485 = r63484 * r63473;
        double r63486 = r63483 - r63485;
        double r63487 = r63477 * r63486;
        double r63488 = 0.16666666666666666;
        double r63489 = 5.0;
        double r63490 = pow(r63472, r63489);
        double r63491 = r63482 / r63490;
        double r63492 = cbrt(r63491);
        double r63493 = r63492 * r63480;
        double r63494 = r63488 * r63493;
        double r63495 = r63487 - r63494;
        double r63496 = r63473 * r63495;
        double r63497 = 0.5;
        double r63498 = r63497 * r63473;
        double r63499 = r63472 - r63498;
        double r63500 = cbrt(r63499);
        double r63501 = r63496 * r63500;
        double r63502 = log(r63472);
        double r63503 = r63501 + r63502;
        double r63504 = log(r63474);
        double r63505 = r63476 ? r63503 : r63504;
        return r63505;
}

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.0000005139006765

    1. Initial program 59.2

      \[\log \left(1 + x\right)\]
    2. Taylor expanded around 0 0.3

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

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

      \[\leadsto \color{blue}{x \cdot \left(1 - 0.5 \cdot x\right) + \log 1}\]
    5. Using strategy rm
    6. Applied add-cube-cbrt0.3

      \[\leadsto x \cdot \color{blue}{\left(\left(\sqrt[3]{1 - 0.5 \cdot x} \cdot \sqrt[3]{1 - 0.5 \cdot x}\right) \cdot \sqrt[3]{1 - 0.5 \cdot x}\right)} + \log 1\]
    7. Applied associate-*r*0.3

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

      \[\leadsto \left(x \cdot \color{blue}{\left(\left(0.1388888888888889 \cdot \left({x}^{2} \cdot {1}^{\frac{1}{3}}\right) + {1}^{\frac{1}{3}}\right) - \left(0.333333333333333315 \cdot \left(x \cdot {1}^{\frac{1}{3}}\right) + 0.166666666666666657 \cdot \left({x}^{2} \cdot {\left(\frac{1}{{1}^{5}}\right)}^{\frac{1}{3}}\right)\right)\right)}\right) \cdot \sqrt[3]{1 - 0.5 \cdot x} + \log 1\]
    9. Simplified0.3

      \[\leadsto \left(x \cdot \color{blue}{\left(\sqrt[3]{1} \cdot \left(\left(0.1388888888888889 \cdot {x}^{2} + 1\right) - 0.333333333333333315 \cdot x\right) - 0.166666666666666657 \cdot \left(\sqrt[3]{\frac{1}{{1}^{5}}} \cdot {x}^{2}\right)\right)}\right) \cdot \sqrt[3]{1 - 0.5 \cdot x} + \log 1\]

    if 1.0000005139006765 < (+ 1.0 x)

    1. Initial program 0.2

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;1 + x \le 1.00000051390067646:\\ \;\;\;\;\left(x \cdot \left(\sqrt[3]{1} \cdot \left(\left(0.1388888888888889 \cdot {x}^{2} + 1\right) - 0.333333333333333315 \cdot x\right) - 0.166666666666666657 \cdot \left(\sqrt[3]{\frac{1}{{1}^{5}}} \cdot {x}^{2}\right)\right)\right) \cdot \sqrt[3]{1 - 0.5 \cdot x} + \log 1\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 + x\right)\\ \end{array}\]

Reproduce

herbie shell --seed 2020043 
(FPCore (x)
  :name "ln(1 + x)"
  :precision binary64

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

  (log (+ 1 x)))