Average Error: 41.6 → 0.0
Time: 6.4s
Precision: 64
Internal precision: 1408
\[\log \left(1 + x\right)\]
\[\begin{array}{l} \mathbf{if}\;x \le 7.988163388129748:\\ \;\;\;\;{x}^2 \cdot \left(x \cdot \frac{1}{3} - \frac{1}{2}\right) + x\\ \mathbf{else}:\\ \;\;\;\;\log \left(1 + x\right)\\ \end{array}\]

Error

Bits error versus x

Target

Original41.6
Comparison6.8
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 < 7.988163388129748

    1. Initial program 59.5

      \[\log \left(1 + x\right)\]
    2. Applied taylor 0.1

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

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

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

    if 7.988163388129748 < 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: 6.4s) Debug logProfile

Please include this information when filing a bug report:

herbie shell --seed '#(1064524629 4159152179 2999149171 575749698 4006532819 692958815)'
(FPCore (x)
  :name "ln(1 + x)"

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

  (log (+ 1 x)))