Average Error: 0.3 → 0.3
Time: 2.5s
Precision: binary64
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
\[\frac{\mathsf{fma}\left(-6, x, 6\right)}{-1 - \mathsf{fma}\left(4, \sqrt{x}, x\right)} \]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
\frac{\mathsf{fma}\left(-6, x, 6\right)}{-1 - \mathsf{fma}\left(4, \sqrt{x}, x\right)}
(FPCore (x)
 :precision binary64
 (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))
(FPCore (x)
 :precision binary64
 (/ (fma -6.0 x 6.0) (- -1.0 (fma 4.0 (sqrt x) x))))
double code(double x) {
	return (6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)));
}
double code(double x) {
	return fma(-6.0, x, 6.0) / (-1.0 - fma(4.0, sqrt(x), x));
}

Error

Bits error versus x

Target

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

Derivation

  1. Initial program 0.3

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

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(6, x, -6\right)}{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)}} \]
  3. Applied frac-2neg_binary640.3

    \[\leadsto \color{blue}{\frac{-\mathsf{fma}\left(6, x, -6\right)}{-\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)}} \]
  4. Simplified0.3

    \[\leadsto \frac{\color{blue}{\mathsf{fma}\left(-6, x, 6\right)}}{-\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)} \]
  5. Simplified0.3

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

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

Reproduce

herbie shell --seed 2022081 
(FPCore (x)
  :name "Data.Approximate.Numerics:blog from approximate-0.2.2.1"
  :precision binary64

  :herbie-target
  (/ 6.0 (/ (+ (+ x 1.0) (* 4.0 (sqrt x))) (- x 1.0)))

  (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))