Average Error: 0.0 → 0.0
Time: 12.9s
Precision: binary64
Cost: 13312
\[\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673 \]
\[\mathsf{fma}\left(x, y + -1, -\mathsf{fma}\left(0.5, y, -0.918938533204673\right)\right) \]
(FPCore (x y)
 :precision binary64
 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
(FPCore (x y)
 :precision binary64
 (fma x (+ y -1.0) (- (fma 0.5 y -0.918938533204673))))
double code(double x, double y) {
	return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
double code(double x, double y) {
	return fma(x, (y + -1.0), -fma(0.5, y, -0.918938533204673));
}
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 fma(x, Float64(y + -1.0), Float64(-fma(0.5, y, -0.918938533204673)))
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[(x * N[(y + -1.0), $MachinePrecision] + (-N[(0.5 * y + -0.918938533204673), $MachinePrecision])), $MachinePrecision]
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\mathsf{fma}\left(x, y + -1, -\mathsf{fma}\left(0.5, y, -0.918938533204673\right)\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}{\mathsf{fma}\left(x, y + -1, -\mathsf{fma}\left(0.5, y, -0.918938533204673\right)\right)} \]
    Proof

Alternatives

Alternative 1
Error29.4
Cost1248
\[\begin{array}{l} \mathbf{if}\;x \leq -4 \cdot 10^{+111}:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq -0.000325:\\ \;\;\;\;y \cdot x\\ \mathbf{elif}\;x \leq 6 \cdot 10^{-193}:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{elif}\;x \leq 3.4 \cdot 10^{-130}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;x \leq 1.65 \cdot 10^{-115}:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-91}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;x \leq 5.6 \cdot 10^{-5}:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{elif}\;x \leq 4.6 \cdot 10^{+86}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]
Alternative 2
Error28.3
Cost984
\[\begin{array}{l} \mathbf{if}\;y \leq -6.7 \cdot 10^{-6}:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{elif}\;y \leq -2.05 \cdot 10^{-113}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq -6 \cdot 10^{-269}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{-230}:\\ \;\;\;\;-x\\ \mathbf{elif}\;y \leq 8.2 \cdot 10^{-164}:\\ \;\;\;\;0.918938533204673\\ \mathbf{elif}\;y \leq 1.1:\\ \;\;\;\;-x\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot y\\ \end{array} \]
Alternative 3
Error1.0
Cost776
\[\begin{array}{l} t_0 := y \cdot \left(-0.5 + x\right) - x\\ \mathbf{if}\;y \leq -385:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 3.7 \cdot 10^{-10}:\\ \;\;\;\;\left(\left(-x\right) - y \cdot 0.5\right) + 0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 4
Error1.5
Cost712
\[\begin{array}{l} t_0 := y \cdot \left(x - 0.5\right) + 0.918938533204673\\ \mathbf{if}\;y \leq -2.15 \cdot 10^{-7}:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 2.4 \cdot 10^{-25}:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 5
Error1.2
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.7 \cdot 10^{-7}:\\ \;\;\;\;y \cdot \left(x - 0.5\right) + 0.918938533204673\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-6}:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-0.5 + x\right) - x\\ \end{array} \]
Alternative 6
Error0.9
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -5 \cdot 10^{-6}:\\ \;\;\;\;y \cdot \left(x - 0.5\right) + 0.918938533204673\\ \mathbf{elif}\;y \leq 1.85:\\ \;\;\;\;\left(y \cdot x - x\right) - -0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(-0.5 + x\right) - x\\ \end{array} \]
Alternative 7
Error10.6
Cost588
\[\begin{array}{l} \mathbf{if}\;y \leq -38:\\ \;\;\;\;-0.5 \cdot y\\ \mathbf{elif}\;y \leq 1.05:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{elif}\;y \leq 1.62 \cdot 10^{+78}:\\ \;\;\;\;y \cdot x\\ \mathbf{else}:\\ \;\;\;\;-0.5 \cdot y\\ \end{array} \]
Alternative 8
Error1.6
Cost584
\[\begin{array}{l} t_0 := y \cdot \left(x - 0.5\right)\\ \mathbf{if}\;y \leq -1.5:\\ \;\;\;\;t_0\\ \mathbf{elif}\;y \leq 1.65:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;t_0\\ \end{array} \]
Alternative 9
Error1.6
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.25:\\ \;\;\;\;y \cdot x + y \cdot -0.5\\ \mathbf{elif}\;y \leq 1.65:\\ \;\;\;\;0.918938533204673 - x\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(x - 0.5\right)\\ \end{array} \]
Alternative 10
Error0.0
Cost576
\[y \cdot \left(-0.5 + x\right) - \left(x + -0.918938533204673\right) \]
Alternative 11
Error27.9
Cost392
\[\begin{array}{l} \mathbf{if}\;x \leq -14500000:\\ \;\;\;\;-x\\ \mathbf{elif}\;x \leq 0.92:\\ \;\;\;\;0.918938533204673\\ \mathbf{else}:\\ \;\;\;\;-x\\ \end{array} \]
Alternative 12
Error44.9
Cost64
\[0.918938533204673 \]

Error

Reproduce

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