Average Error: 0.0 → 0.0
Time: 7.2s
Precision: binary64
Cost: 6848
\[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
\[0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right) \]
(FPCore (x y)
 :precision binary64
 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
(FPCore (x y) :precision binary64 (- 0.918938533204673 (fma y (- 0.5 x) x)))
double code(double x, double y) {
	return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
double code(double x, double y) {
	return 0.918938533204673 - fma(y, (0.5 - x), x);
}
function code(x, y)
	return Float64(Float64(Float64(x * Float64(y - 1.0)) - Float64(y * 0.5)) + 0.918938533204673)
end
function code(x, y)
	return Float64(0.918938533204673 - fma(y, Float64(0.5 - x), x))
end
code[x_, y_] := N[(N[(N[(x * N[(y - 1.0), $MachinePrecision]), $MachinePrecision] - N[(y * 0.5), $MachinePrecision]), $MachinePrecision] + 0.918938533204673), $MachinePrecision]
code[x_, y_] := N[(0.918938533204673 - N[(y * N[(0.5 - x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)

Error

Derivation

  1. Initial program 0.0

    \[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
  2. Simplified0.0

    \[\leadsto \color{blue}{0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)} \]
    Proof
    (-.f64 918938533204673/1000000000000000 (fma.f64 y (-.f64 1/2 x) x)): 0 points increase in error, 0 points decrease in error
    (-.f64 918938533204673/1000000000000000 (Rewrite<= fma-def_binary64 (+.f64 (*.f64 y (-.f64 1/2 x)) x))): 2 points increase in error, 0 points decrease in error
    (-.f64 918938533204673/1000000000000000 (+.f64 (Rewrite<= distribute-rgt-out--_binary64 (-.f64 (*.f64 1/2 y) (*.f64 x y))) x)): 1 points increase in error, 1 points decrease in error
    (-.f64 918938533204673/1000000000000000 (+.f64 (-.f64 (Rewrite<= *-commutative_binary64 (*.f64 y 1/2)) (*.f64 x y)) x)): 0 points increase in error, 0 points decrease in error
    (-.f64 918938533204673/1000000000000000 (Rewrite<= associate--r-_binary64 (-.f64 (*.f64 y 1/2) (-.f64 (*.f64 x y) x)))): 0 points increase in error, 0 points decrease in error
    (-.f64 918938533204673/1000000000000000 (-.f64 (*.f64 y 1/2) (-.f64 (*.f64 x y) (Rewrite<= *-lft-identity_binary64 (*.f64 1 x))))): 0 points increase in error, 0 points decrease in error
    (-.f64 918938533204673/1000000000000000 (-.f64 (*.f64 y 1/2) (-.f64 (Rewrite=> *-commutative_binary64 (*.f64 y x)) (*.f64 1 x)))): 0 points increase in error, 0 points decrease in error
    (-.f64 918938533204673/1000000000000000 (-.f64 (*.f64 y 1/2) (Rewrite=> distribute-rgt-out--_binary64 (*.f64 x (-.f64 y 1))))): 2 points increase in error, 2 points decrease in error
    (Rewrite=> associate--r-_binary64 (+.f64 (-.f64 918938533204673/1000000000000000 (*.f64 y 1/2)) (*.f64 x (-.f64 y 1)))): 0 points increase in error, 0 points decrease in error
    (+.f64 (Rewrite=> cancel-sign-sub-inv_binary64 (+.f64 918938533204673/1000000000000000 (*.f64 (neg.f64 y) 1/2))) (*.f64 x (-.f64 y 1))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= associate-+r+_binary64 (+.f64 918938533204673/1000000000000000 (+.f64 (*.f64 (neg.f64 y) 1/2) (*.f64 x (-.f64 y 1))))): 0 points increase in error, 0 points decrease in error
    (+.f64 918938533204673/1000000000000000 (Rewrite<= +-commutative_binary64 (+.f64 (*.f64 x (-.f64 y 1)) (*.f64 (neg.f64 y) 1/2)))): 0 points increase in error, 0 points decrease in error
    (+.f64 918938533204673/1000000000000000 (Rewrite<= cancel-sign-sub-inv_binary64 (-.f64 (*.f64 x (-.f64 y 1)) (*.f64 y 1/2)))): 0 points increase in error, 0 points decrease in error
    (Rewrite<= +-commutative_binary64 (+.f64 (-.f64 (*.f64 x (-.f64 y 1)) (*.f64 y 1/2)) 918938533204673/1000000000000000)): 0 points increase in error, 0 points decrease in error
  3. Final simplification0.0

    \[\leadsto 0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right) \]

Alternatives

Alternative 1
Error28.2
Cost1644
\[\begin{array}{l} \mathbf{if}\;y \leq -6.0312996875384626 \cdot 10^{+69}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.7365772822780502 \cdot 10^{+40}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -247756747.24193823:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -2.558064474429204 \cdot 10^{-85}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq -5.836407665182025 \cdot 10^{-102}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -6.742514586969581 \cdot 10^{-192}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 3.895902570230874 \cdot 10^{-298}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.1668277656337483 \cdot 10^{-270}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 4.070439229536817 \cdot 10^{-125}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.6247118226599419 \cdot 10^{-49}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 0.00045304359284184265:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]
Alternative 2
Error28.1
Cost1380
\[\begin{array}{l} \mathbf{if}\;y \leq -247756747.24193823:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -2.558064474429204 \cdot 10^{-85}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq -5.836407665182025 \cdot 10^{-102}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -6.742514586969581 \cdot 10^{-192}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 3.895902570230874 \cdot 10^{-298}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.1668277656337483 \cdot 10^{-270}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 4.070439229536817 \cdot 10^{-125}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 1.6247118226599419 \cdot 10^{-49}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 0.00045304359284184265:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]
Alternative 3
Error11.1
Cost980
\[\begin{array}{l} \mathbf{if}\;y \leq -6.0312996875384626 \cdot 10^{+69}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.7365772822780502 \cdot 10^{+40}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -9.326475587132545 \cdot 10^{+19}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 9.370400178375818 \cdot 10^{-27}:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{elif}\;y \leq 301775525093.5044:\\ \;\;\;\;x \cdot \left(y + -1\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]
Alternative 4
Error11.0
Cost720
\[\begin{array}{l} \mathbf{if}\;y \leq -6.0312996875384626 \cdot 10^{+69}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq -1.7365772822780502 \cdot 10^{+40}:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;y \leq -9.326475587132545 \cdot 10^{+19}:\\ \;\;\;\;y \cdot -0.5\\ \mathbf{elif}\;y \leq 0.00045304359284184265:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot -0.5\\ \end{array} \]
Alternative 5
Error1.4
Cost712
\[\begin{array}{l} t_0 := x \cdot \left(y + -1\right)\\ \mathbf{if}\;x \leq -1575091921097.4602:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.5173412119868305 \cdot 10^{-6}:\\ \;\;\;\;0.918938533204673 + y \cdot \left(x + -0.5\right)\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 6
Error0.0
Cost704
\[\left(0.918938533204673 - x \cdot \left(1 - y\right)\right) + y \cdot -0.5 \]
Alternative 7
Error1.7
Cost584
\[\begin{array}{l} t_0 := x \cdot \left(y + -1\right)\\ \mathbf{if}\;x \leq -9.070102058445586:\\ \;\;\;\;t_0\\ \mathbf{elif}\;x \leq 3.5173412119868305 \cdot 10^{-6}:\\ \;\;\;\;0.918938533204673 + y \cdot -0.5\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 8
Error28.2
Cost392
\[\begin{array}{l} \mathbf{if}\;x \leq -0.002505036966755584:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq 2.8522117366795206 \cdot 10^{-11}:\\ \;\;\;\;0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]
Alternative 9
Error45.0
Cost64
\[0.918938533204673 \]

Error

Reproduce

herbie shell --seed 2022317 
(FPCore (x y)
  :name "Numeric.SpecFunctions:logGamma from math-functions-0.1.5.2, A"
  :precision binary64
  (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))