Average Error: 0.2 → 0.2
Time: 4.9s
Precision: binary64
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
\[\begin{array}{l} t_0 := \sqrt{6} \cdot \sqrt{6}\\ \frac{\mathsf{fma}\left(6, x, -t_0\right) + \left(t_0 + -6\right)}{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)} \end{array} \]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
\begin{array}{l}
t_0 := \sqrt{6} \cdot \sqrt{6}\\
\frac{\mathsf{fma}\left(6, x, -t_0\right) + \left(t_0 + -6\right)}{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)}
\end{array}
(FPCore (x)
 :precision binary64
 (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))
(FPCore (x)
 :precision binary64
 (let* ((t_0 (* (sqrt 6.0) (sqrt 6.0))))
   (/ (+ (fma 6.0 x (- t_0)) (+ t_0 -6.0)) (fma 4.0 (sqrt x) (+ x 1.0)))))
double code(double x) {
	return (6.0 * (x - 1.0)) / ((x + 1.0) + (4.0 * sqrt(x)));
}
double code(double x) {
	double t_0 = sqrt(6.0) * sqrt(6.0);
	return (fma(6.0, x, -t_0) + (t_0 + -6.0)) / fma(4.0, sqrt(x), (x + 1.0));
}

Error

Bits error versus x

Target

Original0.2
Target0.0
Herbie0.2
\[\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.2

    \[\leadsto \color{blue}{\frac{\mathsf{fma}\left(6, x, -6\right)}{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)}} \]
  3. Taylor expanded in x around 0 0.2

    \[\leadsto \frac{\color{blue}{6 \cdot x - 6}}{\mathsf{fma}\left(4, \sqrt{x}, x + 1\right)} \]
  4. Applied add-sqr-sqrt_binary640.6

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

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

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

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

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

Reproduce

herbie shell --seed 2021280 
(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)))))