
(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 8 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.7%
*-un-lft-identity99.7%
times-frac99.8%
+-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y)
:precision binary64
(if (or (<= y -2.35e+58)
(not
(or (<= y -3800000000000.0)
(and (not (<= y -9e-15)) (<= y 4.4e+105)))))
(* 100.0 (/ x y))
100.0))
double code(double x, double y) {
double tmp;
if ((y <= -2.35e+58) || !((y <= -3800000000000.0) || (!(y <= -9e-15) && (y <= 4.4e+105)))) {
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.35d+58)) .or. (.not. (y <= (-3800000000000.0d0)) .or. (.not. (y <= (-9d-15))) .and. (y <= 4.4d+105))) 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.35e+58) || !((y <= -3800000000000.0) || (!(y <= -9e-15) && (y <= 4.4e+105)))) {
tmp = 100.0 * (x / y);
} else {
tmp = 100.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -2.35e+58) or not ((y <= -3800000000000.0) or (not (y <= -9e-15) and (y <= 4.4e+105))): tmp = 100.0 * (x / y) else: tmp = 100.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -2.35e+58) || !((y <= -3800000000000.0) || (!(y <= -9e-15) && (y <= 4.4e+105)))) 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.35e+58) || ~(((y <= -3800000000000.0) || (~((y <= -9e-15)) && (y <= 4.4e+105))))) tmp = 100.0 * (x / y); else tmp = 100.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -2.35e+58], N[Not[Or[LessEqual[y, -3800000000000.0], And[N[Not[LessEqual[y, -9e-15]], $MachinePrecision], LessEqual[y, 4.4e+105]]]], $MachinePrecision]], N[(100.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 100.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.35 \cdot 10^{+58} \lor \neg \left(y \leq -3800000000000 \lor \neg \left(y \leq -9 \cdot 10^{-15}\right) \land y \leq 4.4 \cdot 10^{+105}\right):\\
\;\;\;\;100 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;100\\
\end{array}
\end{array}
if y < -2.34999999999999986e58 or -3.8e12 < y < -8.9999999999999995e-15 or 4.40000000000000014e105 < y Initial program 99.7%
*-commutative99.7%
associate-/l*97.5%
+-commutative97.5%
remove-double-neg97.5%
unsub-neg97.5%
div-sub97.5%
distribute-frac-neg97.5%
*-inverses97.5%
metadata-eval97.5%
Simplified97.5%
Taylor expanded in y around inf 85.3%
if -2.34999999999999986e58 < y < -3.8e12 or -8.9999999999999995e-15 < y < 4.40000000000000014e105Initial program 99.7%
*-commutative99.7%
associate-/l*99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
distribute-frac-neg99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 77.8%
Final simplification80.7%
(FPCore (x y)
:precision binary64
(if (or (<= y -5.7e+57)
(not
(or (<= y -7800000000.0)
(and (not (<= y -1.1e-13)) (<= y 2.7e+105)))))
(* x (/ 100.0 y))
100.0))
double code(double x, double y) {
double tmp;
if ((y <= -5.7e+57) || !((y <= -7800000000.0) || (!(y <= -1.1e-13) && (y <= 2.7e+105)))) {
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 <= (-5.7d+57)) .or. (.not. (y <= (-7800000000.0d0)) .or. (.not. (y <= (-1.1d-13))) .and. (y <= 2.7d+105))) 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 <= -5.7e+57) || !((y <= -7800000000.0) || (!(y <= -1.1e-13) && (y <= 2.7e+105)))) {
tmp = x * (100.0 / y);
} else {
tmp = 100.0;
}
return tmp;
}
def code(x, y): tmp = 0 if (y <= -5.7e+57) or not ((y <= -7800000000.0) or (not (y <= -1.1e-13) and (y <= 2.7e+105))): tmp = x * (100.0 / y) else: tmp = 100.0 return tmp
function code(x, y) tmp = 0.0 if ((y <= -5.7e+57) || !((y <= -7800000000.0) || (!(y <= -1.1e-13) && (y <= 2.7e+105)))) 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 <= -5.7e+57) || ~(((y <= -7800000000.0) || (~((y <= -1.1e-13)) && (y <= 2.7e+105))))) tmp = x * (100.0 / y); else tmp = 100.0; end tmp_2 = tmp; end
code[x_, y_] := If[Or[LessEqual[y, -5.7e+57], N[Not[Or[LessEqual[y, -7800000000.0], And[N[Not[LessEqual[y, -1.1e-13]], $MachinePrecision], LessEqual[y, 2.7e+105]]]], $MachinePrecision]], N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision], 100.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.7 \cdot 10^{+57} \lor \neg \left(y \leq -7800000000 \lor \neg \left(y \leq -1.1 \cdot 10^{-13}\right) \land y \leq 2.7 \cdot 10^{+105}\right):\\
\;\;\;\;x \cdot \frac{100}{y}\\
\mathbf{else}:\\
\;\;\;\;100\\
\end{array}
\end{array}
if y < -5.6999999999999998e57 or -7.8e9 < y < -1.09999999999999998e-13 or 2.70000000000000016e105 < y Initial program 99.7%
*-commutative99.7%
associate-/l*97.5%
+-commutative97.5%
remove-double-neg97.5%
unsub-neg97.5%
div-sub97.5%
distribute-frac-neg97.5%
*-inverses97.5%
metadata-eval97.5%
Simplified97.5%
Taylor expanded in y around inf 85.3%
associate-*r/85.6%
*-commutative85.6%
associate-/l*85.7%
Simplified85.7%
clear-num83.3%
associate-/r/85.6%
clear-num85.6%
Applied egg-rr85.6%
if -5.6999999999999998e57 < y < -7.8e9 or -1.09999999999999998e-13 < y < 2.70000000000000016e105Initial program 99.7%
*-commutative99.7%
associate-/l*99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
distribute-frac-neg99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 77.8%
Final simplification80.8%
(FPCore (x y)
:precision binary64
(if (<= y -1.5e+58)
(/ x (/ y 100.0))
(if (<= y -72000000000000.0)
100.0
(if (or (<= y -2.5e-14) (not (<= y 2.7e+105))) (* x (/ 100.0 y)) 100.0))))
double code(double x, double y) {
double tmp;
if (y <= -1.5e+58) {
tmp = x / (y / 100.0);
} else if (y <= -72000000000000.0) {
tmp = 100.0;
} else if ((y <= -2.5e-14) || !(y <= 2.7e+105)) {
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 <= (-1.5d+58)) then
tmp = x / (y / 100.0d0)
else if (y <= (-72000000000000.0d0)) then
tmp = 100.0d0
else if ((y <= (-2.5d-14)) .or. (.not. (y <= 2.7d+105))) 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 <= -1.5e+58) {
tmp = x / (y / 100.0);
} else if (y <= -72000000000000.0) {
tmp = 100.0;
} else if ((y <= -2.5e-14) || !(y <= 2.7e+105)) {
tmp = x * (100.0 / y);
} else {
tmp = 100.0;
}
return tmp;
}
def code(x, y): tmp = 0 if y <= -1.5e+58: tmp = x / (y / 100.0) elif y <= -72000000000000.0: tmp = 100.0 elif (y <= -2.5e-14) or not (y <= 2.7e+105): tmp = x * (100.0 / y) else: tmp = 100.0 return tmp
function code(x, y) tmp = 0.0 if (y <= -1.5e+58) tmp = Float64(x / Float64(y / 100.0)); elseif (y <= -72000000000000.0) tmp = 100.0; elseif ((y <= -2.5e-14) || !(y <= 2.7e+105)) 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 <= -1.5e+58) tmp = x / (y / 100.0); elseif (y <= -72000000000000.0) tmp = 100.0; elseif ((y <= -2.5e-14) || ~((y <= 2.7e+105))) tmp = x * (100.0 / y); else tmp = 100.0; end tmp_2 = tmp; end
code[x_, y_] := If[LessEqual[y, -1.5e+58], N[(x / N[(y / 100.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -72000000000000.0], 100.0, If[Or[LessEqual[y, -2.5e-14], N[Not[LessEqual[y, 2.7e+105]], $MachinePrecision]], N[(x * N[(100.0 / y), $MachinePrecision]), $MachinePrecision], 100.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.5 \cdot 10^{+58}:\\
\;\;\;\;\frac{x}{\frac{y}{100}}\\
\mathbf{elif}\;y \leq -72000000000000:\\
\;\;\;\;100\\
\mathbf{elif}\;y \leq -2.5 \cdot 10^{-14} \lor \neg \left(y \leq 2.7 \cdot 10^{+105}\right):\\
\;\;\;\;x \cdot \frac{100}{y}\\
\mathbf{else}:\\
\;\;\;\;100\\
\end{array}
\end{array}
if y < -1.5000000000000001e58Initial program 99.8%
*-commutative99.8%
associate-/l*98.3%
+-commutative98.3%
remove-double-neg98.3%
unsub-neg98.3%
div-sub98.3%
distribute-frac-neg98.3%
*-inverses98.3%
metadata-eval98.3%
Simplified98.3%
Taylor expanded in y around inf 83.5%
associate-*r/83.6%
*-commutative83.6%
associate-/l*83.7%
Simplified83.7%
if -1.5000000000000001e58 < y < -7.2e13 or -2.5000000000000001e-14 < y < 2.70000000000000016e105Initial program 99.7%
*-commutative99.7%
associate-/l*99.9%
+-commutative99.9%
remove-double-neg99.9%
unsub-neg99.9%
div-sub99.9%
distribute-frac-neg99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around 0 77.8%
if -7.2e13 < y < -2.5000000000000001e-14 or 2.70000000000000016e105 < y Initial program 99.6%
*-commutative99.6%
associate-/l*96.6%
+-commutative96.6%
remove-double-neg96.6%
unsub-neg96.6%
div-sub96.6%
distribute-frac-neg96.6%
*-inverses96.6%
metadata-eval96.6%
Simplified96.6%
Taylor expanded in y around inf 87.4%
associate-*r/87.8%
*-commutative87.8%
associate-/l*87.9%
Simplified87.9%
clear-num84.7%
associate-/r/87.8%
clear-num87.9%
Applied egg-rr87.9%
Final simplification80.9%
(FPCore (x y) :precision binary64 (/ 100.0 (- (/ y x) -1.0)))
double code(double x, double y) {
return 100.0 / ((y / x) - -1.0);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = 100.0d0 / ((y / x) - (-1.0d0))
end function
public static double code(double x, double y) {
return 100.0 / ((y / x) - -1.0);
}
def code(x, y): return 100.0 / ((y / x) - -1.0)
function code(x, y) return Float64(100.0 / Float64(Float64(y / x) - -1.0)) end
function tmp = code(x, y) tmp = 100.0 / ((y / x) - -1.0); end
code[x_, y_] := N[(100.0 / N[(N[(y / x), $MachinePrecision] - -1.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{100}{\frac{y}{x} - -1}
\end{array}
Initial program 99.7%
*-commutative99.7%
associate-/l*99.0%
+-commutative99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub99.0%
distribute-frac-neg99.0%
*-inverses99.0%
metadata-eval99.0%
Simplified99.0%
Final simplification99.0%
(FPCore (x y) :precision binary64 (/ x (* (+ x y) 0.01)))
double code(double x, double y) {
return x / ((x + y) * 0.01);
}
real(8) function code(x, y)
real(8), intent (in) :: x
real(8), intent (in) :: y
code = x / ((x + y) * 0.01d0)
end function
public static double code(double x, double y) {
return x / ((x + y) * 0.01);
}
def code(x, y): return x / ((x + y) * 0.01)
function code(x, y) return Float64(x / Float64(Float64(x + y) * 0.01)) end
function tmp = code(x, y) tmp = x / ((x + y) * 0.01); end
code[x_, y_] := N[(x / N[(N[(x + y), $MachinePrecision] * 0.01), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x}{\left(x + y\right) \cdot 0.01}
\end{array}
Initial program 99.7%
expm1-log1p-u97.8%
expm1-udef65.6%
associate-/l*65.6%
div-inv65.6%
+-commutative65.6%
metadata-eval65.6%
Applied egg-rr65.6%
expm1-def97.8%
expm1-log1p99.7%
Simplified99.7%
Final simplification99.7%
(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}
Initial program 99.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.7%
*-commutative99.7%
associate-/l*99.0%
+-commutative99.0%
remove-double-neg99.0%
unsub-neg99.0%
div-sub99.0%
distribute-frac-neg99.0%
*-inverses99.0%
metadata-eval99.0%
Simplified99.0%
Taylor expanded in y around 0 54.2%
Final simplification54.2%
(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 2024021
(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)))