| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6848 |
\[\mathsf{fma}\left(y, x + -0.5, 0.918938533204673 - x\right)
\]

(FPCore (x y) :precision binary64 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
(FPCore (x y) :precision binary64 (fma y (+ x -0.5) (- 0.918938533204673 x)))
double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
double code(double x, double y) {
return fma(y, (x + -0.5), (0.918938533204673 - 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 fma(y, Float64(x + -0.5), Float64(0.918938533204673 - 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[(y * N[(x + -0.5), $MachinePrecision] + N[(0.918938533204673 - x), $MachinePrecision]), $MachinePrecision]
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\mathsf{fma}\left(y, x + -0.5, 0.918938533204673 - x\right)
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Initial program 100.0%
Simplified100.0%
[Start]100.0% | \[ \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\] |
|---|---|
sub-neg [=>]100.0% | \[ \color{blue}{\left(x \cdot \left(y - 1\right) + \left(-y \cdot 0.5\right)\right)} + 0.918938533204673
\] |
+-commutative [=>]100.0% | \[ \color{blue}{\left(\left(-y \cdot 0.5\right) + x \cdot \left(y - 1\right)\right)} + 0.918938533204673
\] |
sub-neg [=>]100.0% | \[ \left(\left(-y \cdot 0.5\right) + x \cdot \color{blue}{\left(y + \left(-1\right)\right)}\right) + 0.918938533204673
\] |
distribute-rgt-in [=>]100.0% | \[ \left(\left(-y \cdot 0.5\right) + \color{blue}{\left(y \cdot x + \left(-1\right) \cdot x\right)}\right) + 0.918938533204673
\] |
associate-+r+ [=>]100.0% | \[ \color{blue}{\left(\left(\left(-y \cdot 0.5\right) + y \cdot x\right) + \left(-1\right) \cdot x\right)} + 0.918938533204673
\] |
associate-+l+ [=>]100.0% | \[ \color{blue}{\left(\left(-y \cdot 0.5\right) + y \cdot x\right) + \left(\left(-1\right) \cdot x + 0.918938533204673\right)}
\] |
distribute-rgt-neg-in [=>]100.0% | \[ \left(\color{blue}{y \cdot \left(-0.5\right)} + y \cdot x\right) + \left(\left(-1\right) \cdot x + 0.918938533204673\right)
\] |
distribute-lft-out [=>]100.0% | \[ \color{blue}{y \cdot \left(\left(-0.5\right) + x\right)} + \left(\left(-1\right) \cdot x + 0.918938533204673\right)
\] |
fma-def [=>]100.0% | \[ \color{blue}{\mathsf{fma}\left(y, \left(-0.5\right) + x, \left(-1\right) \cdot x + 0.918938533204673\right)}
\] |
+-commutative [=>]100.0% | \[ \mathsf{fma}\left(y, \color{blue}{x + \left(-0.5\right)}, \left(-1\right) \cdot x + 0.918938533204673\right)
\] |
metadata-eval [=>]100.0% | \[ \mathsf{fma}\left(y, x + \color{blue}{-0.5}, \left(-1\right) \cdot x + 0.918938533204673\right)
\] |
+-commutative [<=]100.0% | \[ \mathsf{fma}\left(y, x + -0.5, \color{blue}{0.918938533204673 + \left(-1\right) \cdot x}\right)
\] |
cancel-sign-sub-inv [<=]100.0% | \[ \mathsf{fma}\left(y, x + -0.5, \color{blue}{0.918938533204673 - 1 \cdot x}\right)
\] |
*-lft-identity [=>]100.0% | \[ \mathsf{fma}\left(y, x + -0.5, 0.918938533204673 - \color{blue}{x}\right)
\] |
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 6848 |
| Alternative 2 | |
|---|---|
| Accuracy | 50.4% |
| Cost | 1117 |
| Alternative 3 | |
|---|---|
| Accuracy | 74.5% |
| Cost | 985 |
| Alternative 4 | |
|---|---|
| Accuracy | 97.7% |
| Cost | 841 |
| Alternative 5 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 704 |
| Alternative 6 | |
|---|---|
| Accuracy | 49.9% |
| Cost | 588 |
| Alternative 7 | |
|---|---|
| Accuracy | 98.2% |
| Cost | 585 |
| Alternative 8 | |
|---|---|
| Accuracy | 97.9% |
| Cost | 585 |
| Alternative 9 | |
|---|---|
| Accuracy | 49.5% |
| Cost | 392 |
| Alternative 10 | |
|---|---|
| Accuracy | 26.1% |
| Cost | 64 |
herbie shell --seed 2023245
(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))