Average Error: 38.8 → 0.2
Time: 24.3s
Precision: 64
Internal Precision: 1344
\[\log \left(1 + x\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le 0.00016083016722330594:\\ \;\;\;\;e^{\frac{-1}{2} \cdot x} \cdot \left(x \cdot {\left(e^{\frac{5}{24}}\right)}^{\left(x \cdot x\right)}\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.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.00016083016722330594

    1. Initial program 59.0

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

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

      \[\leadsto \color{blue}{\left(x \cdot \frac{1}{3} - \frac{1}{2}\right) \cdot \left(x \cdot x\right) + x}\]
    4. Using strategy rm
    5. Applied add-exp-log34.6

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

      \[\leadsto e^{\color{blue}{\left(\frac{5}{24} \cdot {x}^{2} + \log x\right) - \frac{1}{2} \cdot x}}\]
    7. Using strategy rm
    8. Applied sub-neg34.6

      \[\leadsto e^{\color{blue}{\left(\frac{5}{24} \cdot {x}^{2} + \log x\right) + \left(-\frac{1}{2} \cdot x\right)}}\]
    9. Applied exp-sum34.6

      \[\leadsto \color{blue}{e^{\frac{5}{24} \cdot {x}^{2} + \log x} \cdot e^{-\frac{1}{2} \cdot x}}\]
    10. Simplified0.2

      \[\leadsto \color{blue}{\left(x \cdot {\left(e^{\frac{5}{24}}\right)}^{\left(x \cdot x\right)}\right)} \cdot e^{-\frac{1}{2} \cdot x}\]

    if 0.00016083016722330594 < 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 \le 0.00016083016722330594:\\ \;\;\;\;e^{\frac{-1}{2} \cdot x} \cdot \left(x \cdot {\left(e^{\frac{5}{24}}\right)}^{\left(x \cdot x\right)}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 + x\right)\\ \end{array}\]

Runtime

Time bar (total: 24.3s)Debug logProfile

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

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

  (log (+ 1 x)))