
(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 6 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 (/ (+ x y) 100.0)))
double code(double x, double y) {
return x / ((x + y) / 100.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / ((x + y) / 100.0d0)
end function
public static double code(double x, double y) {
return x / ((x + y) / 100.0);
}
def code(x, y): return x / ((x + y) / 100.0)
function code(x, y) return Float64(x / Float64(Float64(x + y) / 100.0)) end
function tmp = code(x, y) tmp = x / ((x + y) / 100.0); end
code[x_, y_] := N[(x / N[(N[(x + y), $MachinePrecision] / 100.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\frac{x + y}{100}}
\end{array}
Initial program 99.0%
associate-/l*99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y)
:precision binary64
(if (or (<= y -2.7e-120)
(and (not (<= y 3.9e+37)) (or (<= y 4.4e+102) (not (<= y 3.8e+142)))))
(* x (/ 100.0 y))
100.0))
double code(double x, double y) {
double tmp;
if ((y <= -2.7e-120) || (!(y <= 3.9e+37) && ((y <= 4.4e+102) || !(y <= 3.8e+142)))) {
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 <= (-2.7d-120)) .or. (.not. (y <= 3.9d+37)) .and. (y <= 4.4d+102) .or. (.not. (y <= 3.8d+142))) 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 <= -2.7e-120) || (!(y <= 3.9e+37) && ((y <= 4.4e+102) || !(y <= 3.8e+142)))) {
tmp = x * (100.0 / y);
} else {
tmp = 100.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.7e-120) or (not (y <= 3.9e+37) and ((y <= 4.4e+102) or not (y <= 3.8e+142))): tmp = x * (100.0 / y) else: tmp = 100.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.7e-120) || (!(y <= 3.9e+37) && ((y <= 4.4e+102) || !(y <= 3.8e+142)))) 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 <= -2.7e-120) || (~((y <= 3.9e+37)) && ((y <= 4.4e+102) || ~((y <= 3.8e+142))))) tmp = x * (100.0 / y); else tmp = 100.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2.7e-120], And[N[Not[LessEqual[y, 3.9e+37]], $MachinePrecision], Or[LessEqual[y, 4.4e+102], N[Not[LessEqual[y, 3.8e+142]], $MachinePrecision]]]], N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision], 100.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-120} \lor \neg \left(y \leq 3.9 \cdot 10^{+37}\right) \land \left(y \leq 4.4 \cdot 10^{+102} \lor \neg \left(y \leq 3.8 \cdot 10^{+142}\right)\right):\\
\;\;\;\;x \cdot \frac{100}{y}\\
\mathbf{else}:\\
\;\;\;\;100\\
\end{array}
\end{array}
if y < -2.6999999999999999e-120 or 3.8999999999999999e37 < y < 4.40000000000000015e102 or 3.7999999999999999e142 < y Initial program 99.1%
associate-/l*99.7%
Simplified99.7%
clear-num98.4%
associate-/r/99.5%
clear-num99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 79.3%
if -2.6999999999999999e-120 < y < 3.8999999999999999e37 or 4.40000000000000015e102 < y < 3.7999999999999999e142Initial program 99.0%
+-commutative99.0%
associate-*l/99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 76.6%
Final simplification78.1%
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ 100.0 y))))
(if (<= y -2.7e-120)
t_0
(if (<= y 2.4e+45)
100.0
(if (<= y 3.2e+101)
(* 100.0 (/ x y))
(if (<= y 2.6e+142) 100.0 t_0))))))
double code(double x, double y) {
double t_0 = x * (100.0 / y);
double tmp;
if (y <= -2.7e-120) {
tmp = t_0;
} else if (y <= 2.4e+45) {
tmp = 100.0;
} else if (y <= 3.2e+101) {
tmp = 100.0 * (x / y);
} else if (y <= 2.6e+142) {
tmp = 100.0;
} else {
tmp = t_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 <= (-2.7d-120)) then
tmp = t_0
else if (y <= 2.4d+45) then
tmp = 100.0d0
else if (y <= 3.2d+101) then
tmp = 100.0d0 * (x / y)
else if (y <= 2.6d+142) then
tmp = 100.0d0
else
tmp = t_0
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 <= -2.7e-120) {
tmp = t_0;
} else if (y <= 2.4e+45) {
tmp = 100.0;
} else if (y <= 3.2e+101) {
tmp = 100.0 * (x / y);
} else if (y <= 2.6e+142) {
tmp = 100.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (100.0 / y) tmp = 0 if y <= -2.7e-120: tmp = t_0 elif y <= 2.4e+45: tmp = 100.0 elif y <= 3.2e+101: tmp = 100.0 * (x / y) elif y <= 2.6e+142: tmp = 100.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x * Float64(100.0 / y)) tmp = 0.0 if (y <= -2.7e-120) tmp = t_0; elseif (y <= 2.4e+45) tmp = 100.0; elseif (y <= 3.2e+101) tmp = Float64(100.0 * Float64(x / y)); elseif (y <= 2.6e+142) tmp = 100.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x * (100.0 / y); tmp = 0.0; if (y <= -2.7e-120) tmp = t_0; elseif (y <= 2.4e+45) tmp = 100.0; elseif (y <= 3.2e+101) tmp = 100.0 * (x / y); elseif (y <= 2.6e+142) tmp = 100.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.7e-120], t$95$0, If[LessEqual[y, 2.4e+45], 100.0, If[LessEqual[y, 3.2e+101], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+142], 100.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{100}{y}\\
\mathbf{if}\;y \leq -2.7 \cdot 10^{-120}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+45}:\\
\;\;\;\;100\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+101}:\\
\;\;\;\;100 \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+142}:\\
\;\;\;\;100\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.6999999999999999e-120 or 2.60000000000000021e142 < y Initial program 99.0%
associate-/l*99.7%
Simplified99.7%
clear-num98.3%
associate-/r/99.5%
clear-num99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 79.4%
if -2.6999999999999999e-120 < y < 2.39999999999999989e45 or 3.20000000000000005e101 < y < 2.60000000000000021e142Initial program 99.0%
+-commutative99.0%
associate-*l/99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 76.6%
if 2.39999999999999989e45 < y < 3.20000000000000005e101Initial program 100.0%
+-commutative100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 78.0%
Final simplification78.1%
(FPCore (x y)
:precision binary64
(if (<= y -2.7e-120)
(* x (/ 100.0 y))
(if (<= y 6.5e+38)
100.0
(if (<= y 3.4e+101)
(* 100.0 (/ x y))
(if (<= y 2.6e+142) 100.0 (/ (* x 100.0) y))))))
double code(double x, double y) {
double tmp;
if (y <= -2.7e-120) {
tmp = x * (100.0 / y);
} else if (y <= 6.5e+38) {
tmp = 100.0;
} else if (y <= 3.4e+101) {
tmp = 100.0 * (x / y);
} else if (y <= 2.6e+142) {
tmp = 100.0;
} else {
tmp = (x * 100.0) / y;
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-2.7d-120)) then
tmp = x * (100.0d0 / y)
else if (y <= 6.5d+38) then
tmp = 100.0d0
else if (y <= 3.4d+101) then
tmp = 100.0d0 * (x / y)
else if (y <= 2.6d+142) then
tmp = 100.0d0
else
tmp = (x * 100.0d0) / y
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -2.7e-120) {
tmp = x * (100.0 / y);
} else if (y <= 6.5e+38) {
tmp = 100.0;
} else if (y <= 3.4e+101) {
tmp = 100.0 * (x / y);
} else if (y <= 2.6e+142) {
tmp = 100.0;
} else {
tmp = (x * 100.0) / y;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -2.7e-120: tmp = x * (100.0 / y) elif y <= 6.5e+38: tmp = 100.0 elif y <= 3.4e+101: tmp = 100.0 * (x / y) elif y <= 2.6e+142: tmp = 100.0 else: tmp = (x * 100.0) / y return tmp
function code(x, y) tmp = 0.0 if (y <= -2.7e-120) tmp = Float64(x * Float64(100.0 / y)); elseif (y <= 6.5e+38) tmp = 100.0; elseif (y <= 3.4e+101) tmp = Float64(100.0 * Float64(x / y)); elseif (y <= 2.6e+142) tmp = 100.0; else tmp = Float64(Float64(x * 100.0) / y); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -2.7e-120) tmp = x * (100.0 / y); elseif (y <= 6.5e+38) tmp = 100.0; elseif (y <= 3.4e+101) tmp = 100.0 * (x / y); elseif (y <= 2.6e+142) tmp = 100.0; else tmp = (x * 100.0) / y; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -2.7e-120], N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 6.5e+38], 100.0, If[LessEqual[y, 3.4e+101], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+142], 100.0, N[(N[(x * 100.0), $MachinePrecision] / y), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{-120}:\\
\;\;\;\;x \cdot \frac{100}{y}\\
\mathbf{elif}\;y \leq 6.5 \cdot 10^{+38}:\\
\;\;\;\;100\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+101}:\\
\;\;\;\;100 \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 2.6 \cdot 10^{+142}:\\
\;\;\;\;100\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot 100}{y}\\
\end{array}
\end{array}
if y < -2.6999999999999999e-120Initial program 98.6%
associate-/l*99.7%
Simplified99.7%
clear-num97.6%
associate-/r/99.5%
clear-num99.7%
Applied egg-rr99.7%
Taylor expanded in x around 0 71.4%
if -2.6999999999999999e-120 < y < 6.5e38 or 3.40000000000000017e101 < y < 2.60000000000000021e142Initial program 99.0%
+-commutative99.0%
associate-*l/99.8%
+-commutative99.8%
Simplified99.8%
Taylor expanded in x around inf 76.6%
if 6.5e38 < y < 3.40000000000000017e101Initial program 100.0%
+-commutative100.0%
associate-*l/100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 78.0%
if 2.60000000000000021e142 < y Initial program 99.9%
+-commutative99.9%
associate-*l/99.6%
+-commutative99.6%
Simplified99.6%
Taylor expanded in x around 0 94.1%
associate-*r/94.4%
Simplified94.4%
Final simplification78.1%
(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(x * Float64(100.0 / Float64(x + y))) end
function tmp = code(x, y) tmp = x * (100.0 / (x + y)); end
code[x_, y_] := N[(x * N[(100.0 / N[(x + y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{100}{x + y}
\end{array}
Initial program 99.0%
associate-/l*99.7%
Simplified99.7%
clear-num99.0%
associate-/r/99.5%
clear-num99.7%
Applied egg-rr99.7%
Final simplification99.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.0%
+-commutative99.0%
associate-*l/99.7%
+-commutative99.7%
Simplified99.7%
Taylor expanded in x around inf 47.3%
Final simplification47.3%
(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 2023310
(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)))