
(FPCore (x y) :precision binary64 (/ (* x 100.0) (+ x y)))
double code(double x, double y) {
return (x * 100.0) / (x + y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 100.0d0) / (x + y)
end function
public static double code(double x, double y) {
return (x * 100.0) / (x + y);
}
def code(x, y): return (x * 100.0) / (x + y)
function code(x, y) return Float64(Float64(x * 100.0) / Float64(x + y)) end
function tmp = code(x, y) tmp = (x * 100.0) / (x + y); end
code[x_, y_] := N[(N[(x * 100.0), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 100}{x + y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y) :precision binary64 (/ (* x 100.0) (+ x y)))
double code(double x, double y) {
return (x * 100.0) / (x + y);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x * 100.0d0) / (x + y)
end function
public static double code(double x, double y) {
return (x * 100.0) / (x + y);
}
def code(x, y): return (x * 100.0) / (x + y)
function code(x, y) return Float64(Float64(x * 100.0) / Float64(x + y)) end
function tmp = code(x, y) tmp = (x * 100.0) / (x + y); end
code[x_, y_] := N[(N[(x * 100.0), $MachinePrecision] / N[(x + y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot 100}{x + y}
\end{array}
(FPCore (x y) :precision binary64 (* x (/ 100.0 (+ y x))))
double code(double x, double y) {
return x * (100.0 / (y + x));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x * (100.0d0 / (y + x))
end function
public static double code(double x, double y) {
return x * (100.0 / (y + x));
}
def code(x, y): return x * (100.0 / (y + x))
function code(x, y) return Float64(x * Float64(100.0 / Float64(y + x))) end
function tmp = code(x, y) tmp = x * (100.0 / (y + x)); end
code[x_, y_] := N[(x * N[(100.0 / N[(y + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{100}{y + x}
\end{array}
Initial program 99.8%
associate-/l*99.7%
Simplified99.7%
clear-num99.0%
associate-/r/99.5%
clear-num99.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (or (<= y -2.15e+136)
(not
(or (<= y -4.1e+128) (and (not (<= y -2.9e+45)) (<= y 1.6e+31)))))
(* 100.0 (/ x y))
100.0))
double code(double x, double y) {
double tmp;
if ((y <= -2.15e+136) || !((y <= -4.1e+128) || (!(y <= -2.9e+45) && (y <= 1.6e+31)))) {
tmp = 100.0 * (x / y);
} else {
tmp = 100.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-2.15d+136)) .or. (.not. (y <= (-4.1d+128)) .or. (.not. (y <= (-2.9d+45))) .and. (y <= 1.6d+31))) then
tmp = 100.0d0 * (x / y)
else
tmp = 100.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -2.15e+136) || !((y <= -4.1e+128) || (!(y <= -2.9e+45) && (y <= 1.6e+31)))) {
tmp = 100.0 * (x / y);
} else {
tmp = 100.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.15e+136) or not ((y <= -4.1e+128) or (not (y <= -2.9e+45) and (y <= 1.6e+31))): tmp = 100.0 * (x / y) else: tmp = 100.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.15e+136) || !((y <= -4.1e+128) || (!(y <= -2.9e+45) && (y <= 1.6e+31)))) tmp = Float64(100.0 * Float64(x / y)); else tmp = 100.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -2.15e+136) || ~(((y <= -4.1e+128) || (~((y <= -2.9e+45)) && (y <= 1.6e+31))))) tmp = 100.0 * (x / y); else tmp = 100.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2.15e+136], N[Not[Or[LessEqual[y, -4.1e+128], And[N[Not[LessEqual[y, -2.9e+45]], $MachinePrecision], LessEqual[y, 1.6e+31]]]], $MachinePrecision]], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 100.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+136} \lor \neg \left(y \leq -4.1 \cdot 10^{+128} \lor \neg \left(y \leq -2.9 \cdot 10^{+45}\right) \land y \leq 1.6 \cdot 10^{+31}\right):\\
\;\;\;\;100 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;100\\
\end{array}
\end{array}
if y < -2.1499999999999999e136 or -4.10000000000000012e128 < y < -2.8999999999999997e45 or 1.6e31 < y Initial program 99.7%
*-commutative99.7%
+-commutative99.7%
associate-/l*97.8%
remove-double-neg97.8%
unsub-neg97.8%
div-sub97.8%
distribute-frac-neg97.8%
*-inverses97.8%
metadata-eval97.8%
Simplified97.8%
Taylor expanded in y around inf 77.1%
if -2.1499999999999999e136 < y < -4.10000000000000012e128 or -2.8999999999999997e45 < y < 1.6e31Initial program 99.8%
*-commutative99.8%
+-commutative99.8%
associate-/l*99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub99.5%
distribute-frac-neg99.5%
*-inverses99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in y around 0 76.2%
Final simplification76.6%
(FPCore (x y)
:precision binary64
(if (or (<= y -3.2e+135)
(not (or (<= y -4e+128) (and (not (<= y -2.1e+46)) (<= y 2.95e+31)))))
(* x (/ 100.0 y))
100.0))
double code(double x, double y) {
double tmp;
if ((y <= -3.2e+135) || !((y <= -4e+128) || (!(y <= -2.1e+46) && (y <= 2.95e+31)))) {
tmp = x * (100.0 / y);
} else {
tmp = 100.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if ((y <= (-3.2d+135)) .or. (.not. (y <= (-4d+128)) .or. (.not. (y <= (-2.1d+46))) .and. (y <= 2.95d+31))) then
tmp = x * (100.0d0 / y)
else
tmp = 100.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if ((y <= -3.2e+135) || !((y <= -4e+128) || (!(y <= -2.1e+46) && (y <= 2.95e+31)))) {
tmp = x * (100.0 / y);
} else {
tmp = 100.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -3.2e+135) or not ((y <= -4e+128) or (not (y <= -2.1e+46) and (y <= 2.95e+31))): tmp = x * (100.0 / y) else: tmp = 100.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -3.2e+135) || !((y <= -4e+128) || (!(y <= -2.1e+46) && (y <= 2.95e+31)))) tmp = Float64(x * Float64(100.0 / y)); else tmp = 100.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -3.2e+135) || ~(((y <= -4e+128) || (~((y <= -2.1e+46)) && (y <= 2.95e+31))))) tmp = x * (100.0 / y); else tmp = 100.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -3.2e+135], N[Not[Or[LessEqual[y, -4e+128], And[N[Not[LessEqual[y, -2.1e+46]], $MachinePrecision], LessEqual[y, 2.95e+31]]]], $MachinePrecision]], N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision], 100.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.2 \cdot 10^{+135} \lor \neg \left(y \leq -4 \cdot 10^{+128} \lor \neg \left(y \leq -2.1 \cdot 10^{+46}\right) \land y \leq 2.95 \cdot 10^{+31}\right):\\
\;\;\;\;x \cdot \frac{100}{y}\\
\mathbf{else}:\\
\;\;\;\;100\\
\end{array}
\end{array}
if y < -3.19999999999999975e135 or -4.0000000000000003e128 < y < -2.1e46 or 2.9500000000000002e31 < y Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
clear-num98.4%
associate-/r/99.6%
clear-num99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in y around inf 77.5%
if -3.19999999999999975e135 < y < -4.0000000000000003e128 or -2.1e46 < y < 2.9500000000000002e31Initial program 99.8%
*-commutative99.8%
+-commutative99.8%
associate-/l*99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub99.5%
distribute-frac-neg99.5%
*-inverses99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in y around 0 76.2%
Final simplification76.7%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ 100.0 y))))
(if (<= y -4.9e+135)
t_0
(if (<= y -4.1e+128)
(/ (* 100.0 x) x)
(if (or (<= y -2.95e+47) (not (<= y 3.7e+32))) t_0 100.0)))))
double code(double x, double y) {
double t_0 = x * (100.0 / y);
double tmp;
if (y <= -4.9e+135) {
tmp = t_0;
} else if (y <= -4.1e+128) {
tmp = (100.0 * x) / x;
} else if ((y <= -2.95e+47) || !(y <= 3.7e+32)) {
tmp = t_0;
} else {
tmp = 100.0;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: t_0
real(8) :: tmp
t_0 = x * (100.0d0 / y)
if (y <= (-4.9d+135)) then
tmp = t_0
else if (y <= (-4.1d+128)) then
tmp = (100.0d0 * x) / x
else if ((y <= (-2.95d+47)) .or. (.not. (y <= 3.7d+32))) then
tmp = t_0
else
tmp = 100.0d0
end if
code = tmp
end function
public static double code(double x, double y) {
double t_0 = x * (100.0 / y);
double tmp;
if (y <= -4.9e+135) {
tmp = t_0;
} else if (y <= -4.1e+128) {
tmp = (100.0 * x) / x;
} else if ((y <= -2.95e+47) || !(y <= 3.7e+32)) {
tmp = t_0;
} else {
tmp = 100.0;
}
return tmp;
}
def code(x, y): t_0 = x * (100.0 / y) tmp = 0 if y <= -4.9e+135: tmp = t_0 elif y <= -4.1e+128: tmp = (100.0 * x) / x elif (y <= -2.95e+47) or not (y <= 3.7e+32): tmp = t_0 else: tmp = 100.0 return tmp
function code(x, y) t_0 = Float64(x * Float64(100.0 / y)) tmp = 0.0 if (y <= -4.9e+135) tmp = t_0; elseif (y <= -4.1e+128) tmp = Float64(Float64(100.0 * x) / x); elseif ((y <= -2.95e+47) || !(y <= 3.7e+32)) tmp = t_0; else tmp = 100.0; end return tmp end
function tmp_2 = code(x, y) t_0 = x * (100.0 / y); tmp = 0.0; if (y <= -4.9e+135) tmp = t_0; elseif (y <= -4.1e+128) tmp = (100.0 * x) / x; elseif ((y <= -2.95e+47) || ~((y <= 3.7e+32))) tmp = t_0; else tmp = 100.0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -4.9e+135], t$95$0, If[LessEqual[y, -4.1e+128], N[(N[(100.0 * x), $MachinePrecision] / x), $MachinePrecision], If[Or[LessEqual[y, -2.95e+47], N[Not[LessEqual[y, 3.7e+32]], $MachinePrecision]], t$95$0, 100.0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{100}{y}\\
\mathbf{if}\;y \leq -4.9 \cdot 10^{+135}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -4.1 \cdot 10^{+128}:\\
\;\;\;\;\frac{100 \cdot x}{x}\\
\mathbf{elif}\;y \leq -2.95 \cdot 10^{+47} \lor \neg \left(y \leq 3.7 \cdot 10^{+32}\right):\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;100\\
\end{array}
\end{array}
if y < -4.9000000000000001e135 or -4.10000000000000012e128 < y < -2.95000000000000017e47 or 3.7e32 < y Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
clear-num98.4%
associate-/r/99.6%
clear-num99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in y around inf 77.5%
if -4.9000000000000001e135 < y < -4.10000000000000012e128Initial program 99.7%
associate-/l*99.1%
Simplified99.1%
clear-num99.4%
associate-/r/98.8%
clear-num99.7%
+-commutative99.7%
Applied egg-rr99.7%
Taylor expanded in y around 0 88.1%
associate-*l/88.4%
Applied egg-rr88.4%
if -2.95000000000000017e47 < y < 3.7e32Initial program 99.8%
*-commutative99.8%
+-commutative99.8%
associate-/l*99.5%
remove-double-neg99.5%
unsub-neg99.5%
div-sub99.5%
distribute-frac-neg99.5%
*-inverses99.5%
metadata-eval99.5%
Simplified99.5%
Taylor expanded in y around 0 75.9%
Final simplification76.7%
(FPCore (x y) :precision binary64 100.0)
double code(double x, double y) {
return 100.0;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 100.0d0
end function
public static double code(double x, double y) {
return 100.0;
}
def code(x, y): return 100.0
function code(x, y) return 100.0 end
function tmp = code(x, y) tmp = 100.0; end
code[x_, y_] := 100.0
\begin{array}{l}
\\
100
\end{array}
Initial program 99.8%
*-commutative99.8%
+-commutative99.8%
associate-/l*98.9%
remove-double-neg98.9%
unsub-neg98.9%
div-sub98.9%
distribute-frac-neg98.9%
*-inverses98.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in y around 0 56.0%
Final simplification56.0%
(FPCore (x y) :precision binary64 (* (/ x 1.0) (/ 100.0 (+ x y))))
double code(double x, double y) {
return (x / 1.0) * (100.0 / (x + y));
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = (x / 1.0d0) * (100.0d0 / (x + y))
end function
public static double code(double x, double y) {
return (x / 1.0) * (100.0 / (x + y));
}
def code(x, y): return (x / 1.0) * (100.0 / (x + y))
function code(x, y) return Float64(Float64(x / 1.0) * Float64(100.0 / Float64(x + y))) end
function tmp = code(x, y) tmp = (x / 1.0) * (100.0 / (x + y)); end
code[x_, y_] := N[(N[(x / 1.0), $MachinePrecision] * N[(100.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{1} \cdot \frac{100}{x + y}
\end{array}
herbie shell --seed 2023318
(FPCore (x y)
:name "Development.Shake.Progress:message from shake-0.15.5"
:precision binary64
:herbie-target
(* (/ x 1.0) (/ 100.0 (+ x y)))
(/ (* x 100.0) (+ x y)))