
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 4 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
function tmp = code(x, y) tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0)); end
code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))
assert(x < y);
double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0d0))
end function
assert x < y;
public static double code(double x, double y) {
return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
}
[x, y] = sort([x, y]) def code(x, y): return (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(x * y) / Float64(Float64(Float64(x + y) * Float64(x + y)) * Float64(Float64(x + y) + 1.0))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (x * y) / (((x + y) * (x + y)) * ((x + y) + 1.0));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(x * y), $MachinePrecision] / N[(N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision] * N[(N[(x + y), $MachinePrecision] + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x \cdot y}{\left(\left(x + y\right) \cdot \left(x + y\right)\right) \cdot \left(\left(x + y\right) + 1\right)}
\end{array}
Initial program 75.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* (/ y (* (+ x y) (+ x y))) (/ x (+ x (+ y 1.0)))))
assert(x < y);
double code(double x, double y) {
return (y / ((x + y) * (x + y))) * (x / (x + (y + 1.0)));
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (y / ((x + y) * (x + y))) * (x / (x + (y + 1.0d0)))
end function
assert x < y;
public static double code(double x, double y) {
return (y / ((x + y) * (x + y))) * (x / (x + (y + 1.0)));
}
[x, y] = sort([x, y]) def code(x, y): return (y / ((x + y) * (x + y))) * (x / (x + (y + 1.0)))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(y / Float64(Float64(x + y) * Float64(x + y))) * Float64(x / Float64(x + Float64(y + 1.0)))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (y / ((x + y) * (x + y))) * (x / (x + (y + 1.0)));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(y / N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(x / N[(x + N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{y}{\left(x + y\right) \cdot \left(x + y\right)} \cdot \frac{x}{x + \left(y + 1\right)}
\end{array}
Initial program 89.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* (/ x (* (+ x y) (+ x y))) (/ y (+ x (+ y 1.0)))))
assert(x < y);
double code(double x, double y) {
return (x / ((x + y) * (x + y))) * (y / (x + (y + 1.0)));
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / ((x + y) * (x + y))) * (y / (x + (y + 1.0d0)))
end function
assert x < y;
public static double code(double x, double y) {
return (x / ((x + y) * (x + y))) * (y / (x + (y + 1.0)));
}
[x, y] = sort([x, y]) def code(x, y): return (x / ((x + y) * (x + y))) * (y / (x + (y + 1.0)))
x, y = sort([x, y]) function code(x, y) return Float64(Float64(x / Float64(Float64(x + y) * Float64(x + y))) * Float64(y / Float64(x + Float64(y + 1.0)))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y)
tmp = (x / ((x + y) * (x + y))) * (y / (x + (y + 1.0)));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(N[(x / N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * N[(y / N[(x + N[(y + 1.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{x}{\left(x + y\right) \cdot \left(x + y\right)} \cdot \frac{y}{x + \left(y + 1\right)}
\end{array}
Initial program 89.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y) :precision binary64 (* y (/ x (fma (+ x y) (+ x y) (pow (+ x y) 3.0)))))
assert(x < y);
double code(double x, double y) {
return y * (x / fma((x + y), (x + y), pow((x + y), 3.0)));
}
x, y = sort([x, y]) function code(x, y) return Float64(y * Float64(x / fma(Float64(x + y), Float64(x + y), (Float64(x + y) ^ 3.0)))) end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_] := N[(y * N[(x / N[(N[(x + y), $MachinePrecision] * N[(x + y), $MachinePrecision] + N[Power[N[(x + y), $MachinePrecision], 3.0], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
y \cdot \frac{x}{\mathsf{fma}\left(x + y, x + y, {\left(x + y\right)}^{3}\right)}
\end{array}
Initial program 85.7%
(FPCore (x y) :precision binary64 (/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x)))))
double code(double x, double y) {
return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = ((x / ((y + 1.0d0) + x)) / (y + x)) / (1.0d0 / (y / (y + x)))
end function
public static double code(double x, double y) {
return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)));
}
def code(x, y): return ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x)))
function code(x, y) return Float64(Float64(Float64(x / Float64(Float64(y + 1.0) + x)) / Float64(y + x)) / Float64(1.0 / Float64(y / Float64(y + x)))) end
function tmp = code(x, y) tmp = ((x / ((y + 1.0) + x)) / (y + x)) / (1.0 / (y / (y + x))); end
code[x_, y_] := N[(N[(N[(x / N[(N[(y + 1.0), $MachinePrecision] + x), $MachinePrecision]), $MachinePrecision] / N[(y + x), $MachinePrecision]), $MachinePrecision] / N[(1.0 / N[(y / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\frac{\frac{x}{\left(y + 1\right) + x}}{y + x}}{\frac{1}{\frac{y}{y + x}}}
\end{array}
herbie shell --seed 2023276
(FPCore (x y)
:name "Numeric.SpecFunctions:incompleteBetaApprox from math-functions-0.1.5.2, A"
:precision binary64
:herbie-target
(/ (/ (/ x (+ (+ y 1.0) x)) (+ y x)) (/ 1.0 (/ y (+ y x))))
(/ (* x y) (* (* (+ x y) (+ x y)) (+ (+ x y) 1.0))))