
(FPCore (x y) :precision binary64 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
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
public static double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
def code(x, y): return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673
function code(x, y) return Float64(Float64(Float64(x * Float64(y - 1.0)) - Float64(y * 0.5)) + 0.918938533204673) end
function tmp = code(x, y) tmp = ((x * (y - 1.0)) - (y * 0.5)) + 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]
\begin{array}{l}
\\
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 6 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
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
public static double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
def code(x, y): return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673
function code(x, y) return Float64(Float64(Float64(x * Float64(y - 1.0)) - Float64(y * 0.5)) + 0.918938533204673) end
function tmp = code(x, y) tmp = ((x * (y - 1.0)) - (y * 0.5)) + 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]
\begin{array}{l}
\\
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\end{array}
(FPCore (x y) :precision binary64 (+ (- (* x (- y 1.0)) (* y 0.5)) 0.918938533204673))
double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
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
public static double code(double x, double y) {
return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673;
}
def code(x, y): return ((x * (y - 1.0)) - (y * 0.5)) + 0.918938533204673
function code(x, y) return Float64(Float64(Float64(x * Float64(y - 1.0)) - Float64(y * 0.5)) + 0.918938533204673) end
function tmp = code(x, y) tmp = ((x * (y - 1.0)) - (y * 0.5)) + 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]
\begin{array}{l}
\\
\left(x \cdot \left(y - 1\right) - y \cdot 0.5\right) + 0.918938533204673
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (- (* x (+ y -1.0)) (- (* y 0.5) 0.918938533204673)))
double code(double x, double y) {
return (x * (y + -1.0)) - ((y * 0.5) - 0.918938533204673);
}
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
public static double code(double x, double y) {
return (x * (y + -1.0)) - ((y * 0.5) - 0.918938533204673);
}
def code(x, y): return (x * (y + -1.0)) - ((y * 0.5) - 0.918938533204673)
function code(x, y) return Float64(Float64(x * Float64(y + -1.0)) - Float64(Float64(y * 0.5) - 0.918938533204673)) end
function tmp = code(x, y) tmp = (x * (y + -1.0)) - ((y * 0.5) - 0.918938533204673); end
code[x_, y_] := N[(N[(x * N[(y + -1.0), $MachinePrecision]), $MachinePrecision] - N[(N[(y * 0.5), $MachinePrecision] - 0.918938533204673), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \left(y + -1\right) - \left(y \cdot 0.5 - 0.918938533204673\right)
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (+ (fma x (+ y -1.0) (* y -0.5)) 0.918938533204673))
double code(double x, double y) {
return fma(x, (y + -1.0), (y * -0.5)) + 0.918938533204673;
}
function code(x, y) return Float64(fma(x, Float64(y + -1.0), Float64(y * -0.5)) + 0.918938533204673) end
code[x_, y_] := N[(N[(x * N[(y + -1.0), $MachinePrecision] + N[(y * -0.5), $MachinePrecision]), $MachinePrecision] + 0.918938533204673), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y + -1, y \cdot -0.5\right) + 0.918938533204673
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (fma x (+ y -1.0) (fma y -0.5 0.918938533204673)))
double code(double x, double y) {
return fma(x, (y + -1.0), fma(y, -0.5, 0.918938533204673));
}
function code(x, y) return fma(x, Float64(y + -1.0), fma(y, -0.5, 0.918938533204673)) end
code[x_, y_] := N[(x * N[(y + -1.0), $MachinePrecision] + N[(y * -0.5 + 0.918938533204673), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x, y + -1, \mathsf{fma}\left(y, -0.5, 0.918938533204673\right)\right)
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (- 0.918938533204673 (fma y (- 0.5 x) x)))
double code(double x, double y) {
return 0.918938533204673 - fma(y, (0.5 - x), x);
}
function code(x, y) return Float64(0.918938533204673 - fma(y, Float64(0.5 - x), x)) end
code[x_, y_] := N[(0.918938533204673 - N[(y * N[(0.5 - x), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.918938533204673 - \mathsf{fma}\left(y, 0.5 - x, x\right)
\end{array}
Initial program 100.0%
(FPCore (x y) :precision binary64 (- (fma y (- x 0.5) 0.918938533204673) x))
double code(double x, double y) {
return fma(y, (x - 0.5), 0.918938533204673) - x;
}
function code(x, y) return Float64(fma(y, Float64(x - 0.5), 0.918938533204673) - x) end
code[x_, y_] := N[(N[(y * N[(x - 0.5), $MachinePrecision] + 0.918938533204673), $MachinePrecision] - x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, x - 0.5, 0.918938533204673\right) - x
\end{array}
Initial program 100.0%
herbie shell --seed 2023276
(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))