Average Error: 0.4 → 0.4
Time: 10.1s
Precision: binary64
Cost: 13504
\[\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right) \]
\[\sqrt{x} \cdot \left(-3 - \mathsf{fma}\left(y, -3, \frac{\frac{1}{x}}{-3}\right)\right) \]
(FPCore (x y)
 :precision binary64
 (* (* 3.0 (sqrt x)) (- (+ y (/ 1.0 (* x 9.0))) 1.0)))
(FPCore (x y)
 :precision binary64
 (* (sqrt x) (- -3.0 (fma y -3.0 (/ (/ 1.0 x) -3.0)))))
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 sqrt(x) * (-3.0 - fma(y, -3.0, ((1.0 / x) / -3.0)));
}
function code(x, y)
	return Float64(Float64(3.0 * sqrt(x)) * Float64(Float64(y + Float64(1.0 / Float64(x * 9.0))) - 1.0))
end
function code(x, y)
	return Float64(sqrt(x) * Float64(-3.0 - fma(y, -3.0, Float64(Float64(1.0 / x) / -3.0))))
end
code[x_, y_] := N[(N[(3.0 * N[Sqrt[x], $MachinePrecision]), $MachinePrecision] * N[(N[(y + N[(1.0 / N[(x * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - 1.0), $MachinePrecision]), $MachinePrecision]
code[x_, y_] := N[(N[Sqrt[x], $MachinePrecision] * N[(-3.0 - N[(y * -3.0 + N[(N[(1.0 / x), $MachinePrecision] / -3.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\left(3 \cdot \sqrt{x}\right) \cdot \left(\left(y + \frac{1}{x \cdot 9}\right) - 1\right)
\sqrt{x} \cdot \left(-3 - \mathsf{fma}\left(y, -3, \frac{\frac{1}{x}}{-3}\right)\right)

Error

Target

Original0.4
Target0.4
Herbie0.4
\[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. Simplified0.4

    \[\leadsto \color{blue}{\sqrt{x} \cdot \left(-3 - \mathsf{fma}\left(y, -3, \frac{-0.3333333333333333}{x}\right)\right)} \]
    Proof
    (*.f64 (sqrt.f64 x) (-.f64 -3 (fma.f64 y -3 (/.f64 -1/3 x)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (Rewrite<= metadata-eval (*.f64 -1 3)) (fma.f64 y -3 (/.f64 -1/3 x)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (Rewrite<= metadata-eval (neg.f64 1)) 3) (fma.f64 y -3 (/.f64 -1/3 x)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (fma.f64 y (Rewrite<= metadata-eval (*.f64 -1 3)) (/.f64 -1/3 x)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (fma.f64 y (*.f64 (Rewrite<= metadata-eval (neg.f64 1)) 3) (/.f64 -1/3 x)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (fma.f64 y (*.f64 (neg.f64 1) 3) (/.f64 (Rewrite<= metadata-eval (*.f64 3 -1/9)) x)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (fma.f64 y (*.f64 (neg.f64 1) 3) (/.f64 (*.f64 3 (Rewrite<= metadata-eval (neg.f64 1/9))) x)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (fma.f64 y (*.f64 (neg.f64 1) 3) (/.f64 (*.f64 3 (neg.f64 (Rewrite<= metadata-eval (/.f64 1 9)))) x)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (fma.f64 y (*.f64 (neg.f64 1) 3) (Rewrite<= associate-*r/_binary64 (*.f64 3 (/.f64 (neg.f64 (/.f64 1 9)) x)))))): 21 points increase in error, 8 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (fma.f64 y (*.f64 (neg.f64 1) 3) (*.f64 3 (Rewrite<= distribute-neg-frac_binary64 (neg.f64 (/.f64 (/.f64 1 9) x))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (fma.f64 y (*.f64 (neg.f64 1) 3) (*.f64 3 (neg.f64 (Rewrite<= associate-/r*_binary64 (/.f64 1 (*.f64 9 x)))))))): 14 points increase in error, 17 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (fma.f64 y (*.f64 (neg.f64 1) 3) (*.f64 3 (neg.f64 (/.f64 1 (Rewrite<= *-commutative_binary64 (*.f64 x 9)))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (fma.f64 y (*.f64 (neg.f64 1) 3) (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 3 (/.f64 1 (*.f64 x 9)))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (*.f64 (neg.f64 1) 3)) (neg.f64 (*.f64 3 (/.f64 1 (*.f64 x 9)))))))): 5 points increase in error, 2 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (+.f64 (*.f64 y (*.f64 (Rewrite=> metadata-eval -1) 3)) (neg.f64 (*.f64 3 (/.f64 1 (*.f64 x 9))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (+.f64 (*.f64 y (Rewrite=> metadata-eval -3)) (neg.f64 (*.f64 3 (/.f64 1 (*.f64 x 9))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (+.f64 (*.f64 y (Rewrite<= metadata-eval (neg.f64 3))) (neg.f64 (*.f64 3 (/.f64 1 (*.f64 x 9))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (+.f64 (Rewrite<= distribute-rgt-neg-in_binary64 (neg.f64 (*.f64 y 3))) (neg.f64 (*.f64 3 (/.f64 1 (*.f64 x 9))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (Rewrite<= distribute-neg-in_binary64 (neg.f64 (+.f64 (*.f64 y 3) (*.f64 3 (/.f64 1 (*.f64 x 9)))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (neg.f64 (+.f64 (Rewrite=> *-commutative_binary64 (*.f64 3 y)) (*.f64 3 (/.f64 1 (*.f64 x 9))))))): 0 points increase in error, 0 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (neg.f64 (Rewrite<= distribute-lft-in_binary64 (*.f64 3 (+.f64 y (/.f64 1 (*.f64 x 9)))))))): 1 points increase in error, 2 points decrease in error
    (*.f64 (sqrt.f64 x) (-.f64 (*.f64 (neg.f64 1) 3) (neg.f64 (Rewrite<= *-commutative_binary64 (*.f64 (+.f64 y (/.f64 1 (*.f64 x 9))) 3))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 (*.f64 (neg.f64 1) 3) (sqrt.f64 x)) (*.f64 (neg.f64 (*.f64 (+.f64 y (/.f64 1 (*.f64 x 9))) 3)) (sqrt.f64 x)))): 3 points increase in error, 0 points decrease in error
    (-.f64 (Rewrite<= associate-*r*_binary64 (*.f64 (neg.f64 1) (*.f64 3 (sqrt.f64 x)))) (*.f64 (neg.f64 (*.f64 (+.f64 y (/.f64 1 (*.f64 x 9))) 3)) (sqrt.f64 x))): 0 points increase in error, 0 points decrease in error
    (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 3 (sqrt.f64 x)) (neg.f64 1))) (*.f64 (neg.f64 (*.f64 (+.f64 y (/.f64 1 (*.f64 x 9))) 3)) (sqrt.f64 x))): 0 points increase in error, 0 points decrease in error
    (Rewrite=> cancel-sign-sub_binary64 (+.f64 (*.f64 (*.f64 3 (sqrt.f64 x)) (neg.f64 1)) (*.f64 (*.f64 (+.f64 y (/.f64 1 (*.f64 x 9))) 3) (sqrt.f64 x)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (*.f64 (*.f64 3 (sqrt.f64 x)) (neg.f64 1)) (Rewrite<= associate-*r*_binary64 (*.f64 (+.f64 y (/.f64 1 (*.f64 x 9))) (*.f64 3 (sqrt.f64 x))))): 39 points increase in error, 35 points decrease in error
    (+.f64 (*.f64 (*.f64 3 (sqrt.f64 x)) (neg.f64 1)) (Rewrite<= *-commutative_binary64 (*.f64 (*.f64 3 (sqrt.f64 x)) (+.f64 y (/.f64 1 (*.f64 x 9)))))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= distribute-lft-in_binary64 (*.f64 (*.f64 3 (sqrt.f64 x)) (+.f64 (neg.f64 1) (+.f64 y (/.f64 1 (*.f64 x 9)))))): 1 points increase in error, 0 points decrease in error
    (*.f64 (*.f64 3 (sqrt.f64 x)) (Rewrite<= +-commutative_binary64 (+.f64 (+.f64 y (/.f64 1 (*.f64 x 9))) (neg.f64 1)))): 0 points increase in error, 0 points decrease in error
    (*.f64 (*.f64 3 (sqrt.f64 x)) (Rewrite<= sub-neg_binary64 (-.f64 (+.f64 y (/.f64 1 (*.f64 x 9))) 1))): 0 points increase in error, 0 points decrease in error
  3. Applied egg-rr0.4

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

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

    \[\leadsto \sqrt{x} \cdot \left(-3 - \mathsf{fma}\left(y, -3, \frac{\frac{1}{x}}{-3}\right)\right) \]

Alternatives

Alternative 1
Error0.4
Cost13376
\[\sqrt{x} \cdot \left(-3 - \mathsf{fma}\left(y, -3, \frac{-0.3333333333333333}{x}\right)\right) \]
Alternative 2
Error26.3
Cost7248
\[\begin{array}{l} t_0 := y \cdot \sqrt{x \cdot 9}\\ t_1 := \sqrt{x} \cdot \frac{0.3333333333333333}{x}\\ \mathbf{if}\;y \leq -3.149376573246545 \cdot 10^{+55}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -2.810840553847747 \cdot 10^{-67}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq -5.858470568139115 \cdot 10^{-291}:\\ \;\;\;\;\sqrt{x} \cdot -3\\ \mathbf{elif}\;y \leq 206083093.2296176:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 3
Error26.3
Cost7248
\[\begin{array}{l} t_0 := \sqrt{x} \cdot \frac{0.3333333333333333}{x}\\ \mathbf{if}\;y \leq -3.149376573246545 \cdot 10^{+55}:\\ \;\;\;\;\sqrt{x} \cdot \left(y \cdot 3\right)\\ \mathbf{elif}\;y \leq -2.810840553847747 \cdot 10^{-67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -5.858470568139115 \cdot 10^{-291}:\\ \;\;\;\;\sqrt{x} \cdot -3\\ \mathbf{elif}\;y \leq 206083093.2296176:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot \sqrt{x \cdot 9}\\ \end{array} \]
Alternative 4
Error26.3
Cost7248
\[\begin{array}{l} t_0 := \sqrt{x} \cdot \frac{0.3333333333333333}{x}\\ \mathbf{if}\;y \leq -3.149376573246545 \cdot 10^{+55}:\\ \;\;\;\;3 \cdot \left(\sqrt{x} \cdot y\right)\\ \mathbf{elif}\;y \leq -2.810840553847747 \cdot 10^{-67}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq -5.858470568139115 \cdot 10^{-291}:\\ \;\;\;\;\sqrt{x} \cdot -3\\ \mathbf{elif}\;y \leq 206083093.2296176:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;y \cdot \sqrt{x \cdot 9}\\ \end{array} \]
Alternative 5
Error10.4
Cost7244
\[\begin{array}{l} t_0 := \sqrt{x} \cdot \frac{0.3333333333333333}{x}\\ \mathbf{if}\;x \leq 3.4616890672738776 \cdot 10^{-99}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 9.161897283899674 \cdot 10^{-63}:\\ \;\;\;\;y \cdot \left(\sqrt{x} \cdot 3\right)\\ \mathbf{elif}\;x \leq 4.425302712017836 \cdot 10^{-31}:\\ \;\;\;\;t_0\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot \left(-3 + y \cdot 3\right)\\ \end{array} \]
Alternative 6
Error9.2
Cost7240
\[\begin{array}{l} \mathbf{if}\;y \leq -3.149376573246545 \cdot 10^{+55}:\\ \;\;\;\;3 \cdot \left(\sqrt{x} \cdot y\right)\\ \mathbf{elif}\;y \leq 206083093.2296176:\\ \;\;\;\;\sqrt{x} \cdot \left(-3 + \frac{-1}{x \cdot -3}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \sqrt{x \cdot 9}\\ \end{array} \]
Alternative 7
Error9.2
Cost7240
\[\begin{array}{l} \mathbf{if}\;y \leq -3.149376573246545 \cdot 10^{+55}:\\ \;\;\;\;3 \cdot \left(\sqrt{x} \cdot y\right)\\ \mathbf{elif}\;y \leq 206083093.2296176:\\ \;\;\;\;\sqrt{x} \cdot \left(-3 + \frac{\frac{-1}{x}}{-3}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \sqrt{x \cdot 9}\\ \end{array} \]
Alternative 8
Error9.2
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -3.149376573246545 \cdot 10^{+55}:\\ \;\;\;\;3 \cdot \left(\sqrt{x} \cdot y\right)\\ \mathbf{elif}\;y \leq 206083093.2296176:\\ \;\;\;\;\sqrt{x} \cdot \left(-3 + \frac{0.3333333333333333}{x}\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \sqrt{x \cdot 9}\\ \end{array} \]
Alternative 9
Error0.4
Cost7104
\[\sqrt{x \cdot 9} \cdot \left(-1 + \left(y - \frac{-0.1111111111111111}{x}\right)\right) \]
Alternative 10
Error0.4
Cost7104
\[\sqrt{x} \cdot \left(\left(\frac{0.1111111111111111}{x} + \left(y + -1\right)\right) \cdot 3\right) \]
Alternative 11
Error0.4
Cost7104
\[\sqrt{x} \cdot \left(-3 + \left(\frac{0.3333333333333333}{x} + y \cdot 3\right)\right) \]
Alternative 12
Error22.2
Cost6852
\[\begin{array}{l} \mathbf{if}\;x \leq 2.749397497676217 \cdot 10^{-9}:\\ \;\;\;\;\sqrt{x} \cdot \frac{0.3333333333333333}{x}\\ \mathbf{else}:\\ \;\;\;\;\sqrt{x} \cdot -3\\ \end{array} \]
Alternative 13
Error61.9
Cost6592
\[\sqrt{x} \cdot 3 \]
Alternative 14
Error46.5
Cost6592
\[\sqrt{x} \cdot -3 \]

Error

Reproduce

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