Average Error: 38.8 → 0.6
Time: 41.1s
Precision: 64
Internal Precision: 1344
\[\log \left(1 + x\right)\]
\[\begin{array}{l} \mathbf{if}\;\sqrt[3]{\sqrt{{\left(\log \left(x + 1\right)\right)}^{3}}} \cdot \sqrt[3]{\sqrt{{\left(\log \left(x + 1\right)\right)}^{3}}} \le 0.0229992528663422:\\ \;\;\;\;x - \left(\frac{1}{2} - x \cdot \frac{1}{3}\right) \cdot \left(x \cdot x\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 + x\right)\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original38.8
Target0.3
Herbie0.6
\[\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 (* (cbrt (sqrt (pow (log (+ x 1)) 3))) (cbrt (sqrt (pow (log (+ x 1)) 3)))) < 0.0229992528663422

    1. Initial program 59.6

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

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

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

    if 0.0229992528663422 < (* (cbrt (sqrt (pow (log (+ x 1)) 3))) (cbrt (sqrt (pow (log (+ x 1)) 3))))

    1. Initial program 1.5

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

Runtime

Time bar (total: 41.1s)Debug logProfile

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

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

  (log (+ 1 x)))