Average Error: 42.3 → 0.0
Time: 1.2m
Precision: 64
Internal Precision: 1408
\[\log \left(1 + x\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le 11.706590011007084:\\ \;\;\;\;x + \left(x \cdot x\right) \cdot \left(x \cdot \frac{1}{3} - \frac{1}{2}\right)\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 + x\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original42.3
Target7.0
Herbie0.0
\[\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 < 11.706590011007084

    1. Initial program 59.5

      \[\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(x \cdot x\right) \cdot \left(x \cdot \frac{1}{3} - \frac{1}{2}\right)}\]

    if 11.706590011007084 < x

    1. Initial program 0

      \[\log \left(1 + x\right)\]
  3. Recombined 2 regimes into one program.
  4. Removed slow pow expressions.

Runtime

Time bar (total: 1.2m)Debug logProfile

herbie shell --seed '#(1063027428 1192549564 1443466578 604016274 3637110559 1698629644)' 
(FPCore (x)
  :name "ln(1 + x)"

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

  (log (+ 1 x)))