Average Error: 0.2 → 0.2
Time: 2.2s
Precision: binary64
\[\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}} \]
\[\frac{\mathsf{fma}\left(x, 6, -6\right)}{\mathsf{fma}\left(4, \sqrt{x}, x\right) + 1} \]
(FPCore (x)
 :precision binary64
 (/ (* 6.0 (- x 1.0)) (+ (+ x 1.0) (* 4.0 (sqrt x)))))
(FPCore (x)
 :precision binary64
 (/ (fma x 6.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) {
	return fma(x, 6.0, -6.0) / (fma(4.0, sqrt(x), x) + 1.0);
}
function code(x)
	return Float64(Float64(6.0 * Float64(x - 1.0)) / Float64(Float64(x + 1.0) + Float64(4.0 * sqrt(x))))
end
function code(x)
	return Float64(fma(x, 6.0, -6.0) / Float64(fma(4.0, sqrt(x), x) + 1.0))
end
code[x_] := N[(N[(6.0 * N[(x - 1.0), $MachinePrecision]), $MachinePrecision] / N[(N[(x + 1.0), $MachinePrecision] + N[(4.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_] := N[(N[(x * 6.0 + -6.0), $MachinePrecision] / N[(N[(4.0 * N[Sqrt[x], $MachinePrecision] + x), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]
\frac{6 \cdot \left(x - 1\right)}{\left(x + 1\right) + 4 \cdot \sqrt{x}}
\frac{\mathsf{fma}\left(x, 6, -6\right)}{\mathsf{fma}\left(4, \sqrt{x}, x\right) + 1}

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. Applied egg-rr0.3

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

    \[\leadsto \mathsf{fma}\left(6, x, -6\right) \cdot \color{blue}{{\left(\sqrt[3]{e^{-\mathsf{log1p}\left(\mathsf{fma}\left(4, \sqrt{x}, x\right)\right)}}\right)}^{3}} \]
  5. Applied egg-rr0.2

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

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

Reproduce

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