Average Error: 0.4 → 0.3
Time: 3.3s
Precision: binary64
\[\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right) \]
\[\mathsf{fma}\left(\sqrt{x}, 3 \cdot y - 3, 0.3333333333333333 \cdot {x}^{-0.5}\right) \]
\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\mathsf{fma}\left(\sqrt{x}, 3 \cdot y - 3, 0.3333333333333333 \cdot {x}^{-0.5}\right)
(FPCore (x y)
 :precision binary64
 (* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))
(FPCore (x y)
 :precision binary64
 (fma (sqrt x) (- (* 3.0 y) 3.0) (* 0.3333333333333333 (pow x -0.5))))
double code(double x, double y) {
	return (3.0 * sqrt(x)) * ((y + (1.0 / (x * 9.0))) - 1.0);
}
double code(double x, double y) {
	return fma(sqrt(x), ((3.0 * y) - 3.0), (0.3333333333333333 * pow(x, -0.5)));
}

Error

Bits error versus x

Bits error versus y

Target

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

Derivation

  1. Initial program 0.4

    \[\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right) \]
  2. Taylor expanded in y around 0 0.3

    \[\leadsto \color{blue}{\left(3 \cdot \left(y \cdot \sqrt{x}\right) + 0.3333333333333333 \cdot \sqrt{\frac{1}{x}}\right) - 3 \cdot \sqrt{x}} \]
  3. Simplified0.4

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

    \[\leadsto \mathsf{fma}\left(\sqrt{x}, \color{blue}{3 \cdot y - 3}, 0.3333333333333333 \cdot \sqrt{\frac{1}{x}}\right) \]
  5. Applied inv-pow_binary640.4

    \[\leadsto \mathsf{fma}\left(\sqrt{x}, 3 \cdot y - 3, 0.3333333333333333 \cdot \sqrt{\color{blue}{{x}^{-1}}}\right) \]
  6. Applied sqrt-pow1_binary640.3

    \[\leadsto \mathsf{fma}\left(\sqrt{x}, 3 \cdot y - 3, 0.3333333333333333 \cdot \color{blue}{{x}^{\left(\frac{-1}{2}\right)}}\right) \]
  7. Final simplification0.3

    \[\leadsto \mathsf{fma}\left(\sqrt{x}, 3 \cdot y - 3, 0.3333333333333333 \cdot {x}^{-0.5}\right) \]

Reproduce

herbie shell --seed 2022088 
(FPCore (x y)
  :name "Numeric.SpecFunctions:incompleteGamma from math-functions-0.1.5.2, B"
  :precision binary64

  :herbie-target
  (* 3.0 (+ (* y (sqrt x)) (* (- (/ 1.0 (* x 9.0)) 1.0) (sqrt x))))

  (* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))