Average Error: 0.2 → 0.1
Time: 3.6s
Precision: 64
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}\]
\[\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}\right)\right) \cdot 6\]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}\right)\right) \cdot 6
double code(double x) {
	return ((6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x))));
}
double code(double x) {
	return (log1p(expm1(((x - 1.0) / fma(sqrt(x), 4.0, (x + 1.0))))) * 6.0);
}

Error

Bits error versus x

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original0.2
Target0.0
Herbie0.1
\[\frac{6}{\frac{\left(x + 1\right) + 4 \cdot \sqrt{x}}{x - 1}}\]

Derivation

  1. Initial program 0.2

    \[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}\]
  2. Simplified0.0

    \[\leadsto \color{blue}{\frac{x - 1}{\frac{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}{6}}}\]
  3. Using strategy rm
  4. Applied associate-/r/0.0

    \[\leadsto \color{blue}{\frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)} \cdot 6}\]
  5. Using strategy rm
  6. Applied log1p-expm1-u0.1

    \[\leadsto \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}\right)\right)} \cdot 6\]
  7. Final simplification0.1

    \[\leadsto \mathsf{log1p}\left(\mathsf{expm1}\left(\frac{x - 1}{\mathsf{fma}\left(\sqrt{x}, 4, x + 1\right)}\right)\right) \cdot 6\]

Reproduce

herbie shell --seed 2020057 +o rules:numerics
(FPCore (x)
  :name "Data.Approximate.Numerics:blog from approximate-0.2.2.1"
  :precision binary64

  :herbie-target
  (/ 6 (/ (+ (+ x 1) (* 4 (sqrt x))) (- x 1)))

  (/ (* 6 (- x 1)) (+ (+ x 1) (* 4 (sqrt x)))))