| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 576 |
\[0.918938533204673 + \left(y \cdot \left(x - 0.5\right) - x\right)
\]

(FPCore (x y) :precision binary64 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
(FPCore (x y) :precision binary64 (+ 0.918938533204673 (- (* y (- x 0.5)) 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 + ((y * (x - 0.5)) - x);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x * (y - 1.0d0)) - (y * 0.5d0)) + 0.918938533204673d0
end function
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 0.918938533204673d0 + ((y * (x - 0.5d0)) - x)
end function
public static double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
public static double code(double x, double y) {
return 0.918938533204673 + ((y * (x - 0.5)) - x);
}
def code(x, y): return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673
def code(x, y): return 0.918938533204673 + ((y * (x - 0.5)) - 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 + Float64(Float64(y * Float64(x - 0.5)) - x)) end
function tmp = code(x, y) tmp = ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673; end
function tmp = code(x, y) tmp = 0.918938533204673 + ((y * (x - 0.5)) - 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[(N[(y * N[(x - 0.5), $MachinePrecision]), $MachinePrecision] - x), $MachinePrecision]), $MachinePrecision]
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
0.918938533204673 + \left(y \cdot \left(x - 0.5\right) - x\right)
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
Results
Initial program 100.0%
Simplified100.0%
[Start]100.0% | \[ \left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\] |
|---|---|
associate-+l- [=>]100.0% | \[ \color{blue}{x \cdot \left(y - 1\right) - \left(y \cdot 0.5 - 0.918938533204673\right)}
\] |
fma-neg [=>]100.0% | \[ \color{blue}{\mathsf{fma}\left(x, y - 1, -\left(y \cdot 0.5 - 0.918938533204673\right)\right)}
\] |
sub-neg [=>]100.0% | \[ \mathsf{fma}\left(x, \color{blue}{y + \left(-1\right)}, -\left(y \cdot 0.5 - 0.918938533204673\right)\right)
\] |
+-commutative [=>]100.0% | \[ \mathsf{fma}\left(x, \color{blue}{\left(-1\right) + y}, -\left(y \cdot 0.5 - 0.918938533204673\right)\right)
\] |
remove-double-neg [<=]100.0% | \[ \mathsf{fma}\left(x, \left(-1\right) + \color{blue}{\left(-\left(-y\right)\right)}, -\left(y \cdot 0.5 - 0.918938533204673\right)\right)
\] |
sub-neg [<=]100.0% | \[ \mathsf{fma}\left(x, \color{blue}{\left(-1\right) - \left(-y\right)}, -\left(y \cdot 0.5 - 0.918938533204673\right)\right)
\] |
fma-neg [<=]100.0% | \[ \color{blue}{x \cdot \left(\left(-1\right) - \left(-y\right)\right) - \left(y \cdot 0.5 - 0.918938533204673\right)}
\] |
sub-neg [=>]100.0% | \[ x \cdot \color{blue}{\left(\left(-1\right) + \left(-\left(-y\right)\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right)
\] |
remove-double-neg [=>]100.0% | \[ x \cdot \left(\left(-1\right) + \color{blue}{y}\right) - \left(y \cdot 0.5 - 0.918938533204673\right)
\] |
+-commutative [<=]100.0% | \[ x \cdot \color{blue}{\left(y + \left(-1\right)\right)} - \left(y \cdot 0.5 - 0.918938533204673\right)
\] |
metadata-eval [=>]100.0% | \[ x \cdot \left(y + \color{blue}{-1}\right) - \left(y \cdot 0.5 - 0.918938533204673\right)
\] |
Taylor expanded in y around 0 100.0%
Final simplification100.0%
| Alternative 1 | |
|---|---|
| Accuracy | 100.0% |
| Cost | 576 |
| Alternative 2 | |
|---|---|
| Accuracy | 49.5% |
| Cost | 1184 |
| Alternative 3 | |
|---|---|
| Accuracy | 73.7% |
| Cost | 853 |
| Alternative 4 | |
|---|---|
| Accuracy | 49.5% |
| Cost | 788 |
| Alternative 5 | |
|---|---|
| Accuracy | 97.9% |
| Cost | 585 |
| Alternative 6 | |
|---|---|
| Accuracy | 98.1% |
| Cost | 585 |
| Alternative 7 | |
|---|---|
| Accuracy | 49.6% |
| Cost | 392 |
| Alternative 8 | |
|---|---|
| Accuracy | 26.7% |
| Cost | 64 |
herbie shell --seed 2023165
(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))