
(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 (+ 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}
(FPCore (x y)
:precision binary64
(if (or (<= y -4.5e+47)
(and (not (<= y -4.8e-56))
(or (<= y -3.2e-106) (not (<= y 2.3e+121)))))
(* 100.0 (/ x y))
100.0))
double code(double x, double y) {
double tmp;
if ((y <= -4.5e+47) || (!(y <= -4.8e-56) && ((y <= -3.2e-106) || !(y <= 2.3e+121)))) {
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 <= (-4.5d+47)) .or. (.not. (y <= (-4.8d-56))) .and. (y <= (-3.2d-106)) .or. (.not. (y <= 2.3d+121))) 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 <= -4.5e+47) || (!(y <= -4.8e-56) && ((y <= -3.2e-106) || !(y <= 2.3e+121)))) {
tmp = 100.0 * (x / y);
} else {
tmp = 100.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -4.5e+47) or (not (y <= -4.8e-56) and ((y <= -3.2e-106) or not (y <= 2.3e+121))): tmp = 100.0 * (x / y) else: tmp = 100.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -4.5e+47) || (!(y <= -4.8e-56) && ((y <= -3.2e-106) || !(y <= 2.3e+121)))) 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 <= -4.5e+47) || (~((y <= -4.8e-56)) && ((y <= -3.2e-106) || ~((y <= 2.3e+121))))) tmp = 100.0 * (x / y); else tmp = 100.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -4.5e+47], And[N[Not[LessEqual[y, -4.8e-56]], $MachinePrecision], Or[LessEqual[y, -3.2e-106], N[Not[LessEqual[y, 2.3e+121]], $MachinePrecision]]]], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 100.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+47} \lor \neg \left(y \leq -4.8 \cdot 10^{-56}\right) \land \left(y \leq -3.2 \cdot 10^{-106} \lor \neg \left(y \leq 2.3 \cdot 10^{+121}\right)\right):\\
\;\;\;\;100 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;100\\
\end{array}
\end{array}
(FPCore (x y)
:precision binary64
(let* ((t_0 (* x (/ 100.0 y))))
(if (<= y -1.85e+46)
t_0
(if (<= y -4.8e-56)
100.0
(if (<= y -3.2e-106)
(* 100.0 (/ x y))
(if (<= y 1.85e+121) 100.0 t_0))))))
double code(double x, double y) {
double t_0 = x * (100.0 / y);
double tmp;
if (y <= -1.85e+46) {
tmp = t_0;
} else if (y <= -4.8e-56) {
tmp = 100.0;
} else if (y <= -3.2e-106) {
tmp = 100.0 * (x / y);
} else if (y <= 1.85e+121) {
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 <= (-1.85d+46)) then
tmp = t_0
else if (y <= (-4.8d-56)) then
tmp = 100.0d0
else if (y <= (-3.2d-106)) then
tmp = 100.0d0 * (x / y)
else if (y <= 1.85d+121) 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 <= -1.85e+46) {
tmp = t_0;
} else if (y <= -4.8e-56) {
tmp = 100.0;
} else if (y <= -3.2e-106) {
tmp = 100.0 * (x / y);
} else if (y <= 1.85e+121) {
tmp = 100.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x * (100.0 / y) tmp = 0 if y <= -1.85e+46: tmp = t_0 elif y <= -4.8e-56: tmp = 100.0 elif y <= -3.2e-106: tmp = 100.0 * (x / y) elif y <= 1.85e+121: 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 <= -1.85e+46) tmp = t_0; elseif (y <= -4.8e-56) tmp = 100.0; elseif (y <= -3.2e-106) tmp = Float64(100.0 * Float64(x / y)); elseif (y <= 1.85e+121) 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 <= -1.85e+46) tmp = t_0; elseif (y <= -4.8e-56) tmp = 100.0; elseif (y <= -3.2e-106) tmp = 100.0 * (x / y); elseif (y <= 1.85e+121) 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, -1.85e+46], t$95$0, If[LessEqual[y, -4.8e-56], 100.0, If[LessEqual[y, -3.2e-106], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.85e+121], 100.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{100}{y}\\
\mathbf{if}\;y \leq -1.85 \cdot 10^{+46}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-56}:\\
\;\;\;\;100\\
\mathbf{elif}\;y \leq -3.2 \cdot 10^{-106}:\\
\;\;\;\;100 \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+121}:\\
\;\;\;\;100\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
(FPCore (x y)
:precision binary64
(let* ((t_0 (/ x (/ y 100.0))))
(if (<= y -7.2e+45)
t_0
(if (<= y -5.2e-56)
100.0
(if (<= y -1.9e-106)
(* 100.0 (/ x y))
(if (<= y 9.6e+122) 100.0 t_0))))))
double code(double x, double y) {
double t_0 = x / (y / 100.0);
double tmp;
if (y <= -7.2e+45) {
tmp = t_0;
} else if (y <= -5.2e-56) {
tmp = 100.0;
} else if (y <= -1.9e-106) {
tmp = 100.0 * (x / y);
} else if (y <= 9.6e+122) {
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 / (y / 100.0d0)
if (y <= (-7.2d+45)) then
tmp = t_0
else if (y <= (-5.2d-56)) then
tmp = 100.0d0
else if (y <= (-1.9d-106)) then
tmp = 100.0d0 * (x / y)
else if (y <= 9.6d+122) 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 / (y / 100.0);
double tmp;
if (y <= -7.2e+45) {
tmp = t_0;
} else if (y <= -5.2e-56) {
tmp = 100.0;
} else if (y <= -1.9e-106) {
tmp = 100.0 * (x / y);
} else if (y <= 9.6e+122) {
tmp = 100.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y): t_0 = x / (y / 100.0) tmp = 0 if y <= -7.2e+45: tmp = t_0 elif y <= -5.2e-56: tmp = 100.0 elif y <= -1.9e-106: tmp = 100.0 * (x / y) elif y <= 9.6e+122: tmp = 100.0 else: tmp = t_0 return tmp
function code(x, y) t_0 = Float64(x / Float64(y / 100.0)) tmp = 0.0 if (y <= -7.2e+45) tmp = t_0; elseif (y <= -5.2e-56) tmp = 100.0; elseif (y <= -1.9e-106) tmp = Float64(100.0 * Float64(x / y)); elseif (y <= 9.6e+122) tmp = 100.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y) t_0 = x / (y / 100.0); tmp = 0.0; if (y <= -7.2e+45) tmp = t_0; elseif (y <= -5.2e-56) tmp = 100.0; elseif (y <= -1.9e-106) tmp = 100.0 * (x / y); elseif (y <= 9.6e+122) tmp = 100.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_] := Block[{t$95$0 = N[(x / N[(y / 100.0), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -7.2e+45], t$95$0, If[LessEqual[y, -5.2e-56], 100.0, If[LessEqual[y, -1.9e-106], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9.6e+122], 100.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{\frac{y}{100}}\\
\mathbf{if}\;y \leq -7.2 \cdot 10^{+45}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{-56}:\\
\;\;\;\;100\\
\mathbf{elif}\;y \leq -1.9 \cdot 10^{-106}:\\
\;\;\;\;100 \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 9.6 \cdot 10^{+122}:\\
\;\;\;\;100\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
(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}
(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 2023343
(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)))