Average Error: 38.7 → 0.2
Time: 13.6s
Precision: 64
Internal Precision: 576
\[\log \left(1 + x\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le 0.00016980754533681377:\\ \;\;\;\;x + \left(x \cdot x\right) \cdot \left(\frac{1}{3} \cdot x - \frac{1}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(\sqrt{x + 1}\right) + \log \left(\sqrt{x + 1}\right)\\ \end{array}\]

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original38.7
Target0.2
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 x < 0.00016980754533681377

    1. Initial program 58.8

      \[\log \left(1 + x\right)\]
    2. Initial simplification58.8

      \[\leadsto \log \left(x + 1\right)\]
    3. Taylor expanded around 0 0.2

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

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

    if 0.00016980754533681377 < x

    1. Initial program 0.1

      \[\log \left(1 + x\right)\]
    2. Initial simplification0.1

      \[\leadsto \log \left(x + 1\right)\]
    3. Using strategy rm
    4. Applied add-sqr-sqrt0.1

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

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

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

Runtime

Time bar (total: 13.6s)Debug logProfile

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

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

  (log (+ 1 x)))