Average Error: 38.5 → 0.0
Time: 2.2s
Precision: binary64
\[\log \left(1 + x\right) \]
\[\mathsf{log1p}\left(x\right) \]
\log \left(1 + x\right)
\mathsf{log1p}\left(x\right)
(FPCore (x) :precision binary64 (log (+ 1.0 x)))
(FPCore (x) :precision binary64 (log1p x))
double code(double x) {
	return log(1.0 + x);
}
double code(double x) {
	return log1p(x);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original38.5
Target0.3
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. Initial program 38.5

    \[\log \left(1 + x\right) \]
  2. Simplified0.0

    \[\leadsto \color{blue}{\mathsf{log1p}\left(x\right)} \]
  3. Final simplification0.0

    \[\leadsto \mathsf{log1p}\left(x\right) \]

Reproduce

herbie shell --seed 2022020 
(FPCore (x)
  :name "ln(1 + x)"
  :precision binary64

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

  (log (+ 1.0 x)))