
(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 (/ 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-*r/99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y) :precision binary64 (if (or (<= y -3.6e-8) (not (<= y 7e-19))) (* 100.0 (/ x y)) 100.0))
double code(double x, double y) {
double tmp;
if ((y <= -3.6e-8) || !(y <= 7e-19)) {
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 <= (-3.6d-8)) .or. (.not. (y <= 7d-19))) 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 <= -3.6e-8) || !(y <= 7e-19)) {
tmp = 100.0 * (x / y);
} else {
tmp = 100.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -3.6e-8) or not (y <= 7e-19): tmp = 100.0 * (x / y) else: tmp = 100.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -3.6e-8) || !(y <= 7e-19)) 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 <= -3.6e-8) || ~((y <= 7e-19))) tmp = 100.0 * (x / y); else tmp = 100.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -3.6e-8], N[Not[LessEqual[y, 7e-19]], $MachinePrecision]], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 100.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{-8} \lor \neg \left(y \leq 7 \cdot 10^{-19}\right):\\
\;\;\;\;100 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;100\\
\end{array}
\end{array}
if y < -3.59999999999999981e-8 or 7.00000000000000031e-19 < y Initial program 99.1%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in x around 0 79.6%
if -3.59999999999999981e-8 < y < 7.00000000000000031e-19Initial program 98.9%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in x around inf 77.4%
Final simplification78.6%
(FPCore (x y) :precision binary64 (if (or (<= y -2.4e-11) (not (<= y 4.8e-15))) (* x (/ 100.0 y)) 100.0))
double code(double x, double y) {
double tmp;
if ((y <= -2.4e-11) || !(y <= 4.8e-15)) {
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.4d-11)) .or. (.not. (y <= 4.8d-15))) 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.4e-11) || !(y <= 4.8e-15)) {
tmp = x * (100.0 / y);
} else {
tmp = 100.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.4e-11) or not (y <= 4.8e-15): tmp = x * (100.0 / y) else: tmp = 100.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.4e-11) || !(y <= 4.8e-15)) 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.4e-11) || ~((y <= 4.8e-15))) tmp = x * (100.0 / y); else tmp = 100.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2.4e-11], N[Not[LessEqual[y, 4.8e-15]], $MachinePrecision]], N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision], 100.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.4 \cdot 10^{-11} \lor \neg \left(y \leq 4.8 \cdot 10^{-15}\right):\\
\;\;\;\;x \cdot \frac{100}{y}\\
\mathbf{else}:\\
\;\;\;\;100\\
\end{array}
\end{array}
if y < -2.4000000000000001e-11 or 4.7999999999999999e-15 < y Initial program 99.1%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in x around 0 79.8%
if -2.4000000000000001e-11 < y < 4.7999999999999999e-15Initial program 98.9%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in x around inf 77.4%
Final simplification78.7%
(FPCore (x y) :precision binary64 (if (or (<= y -2.8e-8) (not (<= y 4.6e-15))) (/ (* x 100.0) y) 100.0))
double code(double x, double y) {
double tmp;
if ((y <= -2.8e-8) || !(y <= 4.6e-15)) {
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.8d-8)) .or. (.not. (y <= 4.6d-15))) 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.8e-8) || !(y <= 4.6e-15)) {
tmp = (x * 100.0) / y;
} else {
tmp = 100.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.8e-8) or not (y <= 4.6e-15): tmp = (x * 100.0) / y else: tmp = 100.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.8e-8) || !(y <= 4.6e-15)) tmp = Float64(Float64(x * 100.0) / y); else tmp = 100.0; end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if ((y <= -2.8e-8) || ~((y <= 4.6e-15))) tmp = (x * 100.0) / y; else tmp = 100.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2.8e-8], N[Not[LessEqual[y, 4.6e-15]], $MachinePrecision]], N[(N[(x * 100.0), $MachinePrecision] / y), $MachinePrecision], 100.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{-8} \lor \neg \left(y \leq 4.6 \cdot 10^{-15}\right):\\
\;\;\;\;\frac{x \cdot 100}{y}\\
\mathbf{else}:\\
\;\;\;\;100\\
\end{array}
\end{array}
if y < -2.7999999999999999e-8 or 4.59999999999999981e-15 < y Initial program 99.1%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in x around 0 79.8%
associate-*r/79.8%
Applied egg-rr79.8%
if -2.7999999999999999e-8 < y < 4.59999999999999981e-15Initial program 98.9%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in x around inf 77.4%
Final simplification78.8%
(FPCore (x y) :precision binary64 (if (<= y -3.5e-11) (* x (/ 100.0 y)) (if (<= y 2.05e-28) 100.0 (/ x (* y 0.01)))))
double code(double x, double y) {
double tmp;
if (y <= -3.5e-11) {
tmp = x * (100.0 / y);
} else if (y <= 2.05e-28) {
tmp = 100.0;
} else {
tmp = x / (y * 0.01);
}
return tmp;
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8) :: tmp
if (y <= (-3.5d-11)) then
tmp = x * (100.0d0 / y)
else if (y <= 2.05d-28) then
tmp = 100.0d0
else
tmp = x / (y * 0.01d0)
end if
code = tmp
end function
public static double code(double x, double y) {
double tmp;
if (y <= -3.5e-11) {
tmp = x * (100.0 / y);
} else if (y <= 2.05e-28) {
tmp = 100.0;
} else {
tmp = x / (y * 0.01);
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -3.5e-11: tmp = x * (100.0 / y) elif y <= 2.05e-28: tmp = 100.0 else: tmp = x / (y * 0.01) return tmp
function code(x, y) tmp = 0.0 if (y <= -3.5e-11) tmp = Float64(x * Float64(100.0 / y)); elseif (y <= 2.05e-28) tmp = 100.0; else tmp = Float64(x / Float64(y * 0.01)); end return tmp end
function tmp_2 = code(x, y) tmp = 0.0; if (y <= -3.5e-11) tmp = x * (100.0 / y); elseif (y <= 2.05e-28) tmp = 100.0; else tmp = x / (y * 0.01); end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -3.5e-11], N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.05e-28], 100.0, N[(x / N[(y * 0.01), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.5 \cdot 10^{-11}:\\
\;\;\;\;x \cdot \frac{100}{y}\\
\mathbf{elif}\;y \leq 2.05 \cdot 10^{-28}:\\
\;\;\;\;100\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot 0.01}\\
\end{array}
\end{array}
if y < -3.50000000000000019e-11Initial program 98.4%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in x around 0 83.1%
if -3.50000000000000019e-11 < y < 2.0500000000000001e-28Initial program 98.9%
associate-*r/99.8%
Simplified99.8%
Taylor expanded in x around inf 77.4%
if 2.0500000000000001e-28 < y Initial program 99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in x around 0 76.8%
*-commutative76.8%
Simplified76.8%
Final simplification78.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%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in x around inf 45.3%
Final simplification45.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 2023274
(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)))