| Alternative 1 | |
|---|---|
| Error | 21.5 |
| Cost | 64 |
\[x
\]
(FPCore (x y z) :precision binary64 (+ x (/ (* y y) z)))
(FPCore (x y z) :precision binary64 (if (<= (* y y) 2e+302) (+ x (/ (* y y) z)) x))
double code(double x, double y, double z) {
return x + ((y * y) / z);
}
double code(double x, double y, double z) {
double tmp;
if ((y * y) <= 2e+302) {
tmp = x + ((y * y) / z);
} else {
tmp = x;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = x + ((y * y) / z)
end function
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y * y) <= 2d+302) then
tmp = x + ((y * y) / z)
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z) {
return x + ((y * y) / z);
}
public static double code(double x, double y, double z) {
double tmp;
if ((y * y) <= 2e+302) {
tmp = x + ((y * y) / z);
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z): return x + ((y * y) / z)
def code(x, y, z): tmp = 0 if (y * y) <= 2e+302: tmp = x + ((y * y) / z) else: tmp = x return tmp
function code(x, y, z) return Float64(x + Float64(Float64(y * y) / z)) end
function code(x, y, z) tmp = 0.0 if (Float64(y * y) <= 2e+302) tmp = Float64(x + Float64(Float64(y * y) / z)); else tmp = x; end return tmp end
function tmp = code(x, y, z) tmp = x + ((y * y) / z); end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y * y) <= 2e+302) tmp = x + ((y * y) / z); else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_] := N[(x + N[(N[(y * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_] := If[LessEqual[N[(y * y), $MachinePrecision], 2e+302], N[(x + N[(N[(y * y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], x]
x + \frac{y \cdot y}{z}
\begin{array}{l}
\mathbf{if}\;y \cdot y \leq 2 \cdot 10^{+302}:\\
\;\;\;\;x + \frac{y \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
Results
| Original | 6.0 |
|---|---|
| Target | 0.1 |
| Herbie | 5.3 |
if (*.f64 y y) < 2.0000000000000002e302Initial program 0.9
if 2.0000000000000002e302 < (*.f64 y y) Initial program 62.0
Taylor expanded in x around inf 53.9
Final simplification5.3
| Alternative 1 | |
|---|---|
| Error | 21.5 |
| Cost | 64 |
herbie shell --seed 2023090
(FPCore (x y z)
:name "Crypto.Random.Test:calculate from crypto-random-0.0.9"
:precision binary64
:herbie-target
(+ x (* y (/ y z)))
(+ x (/ (* y y) z)))