
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * (((y / z) * t) / t)
end function
public static double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
def code(x, y, z, t): return x * (((y / z) * t) / t)
function code(x, y, z, t) return Float64(x * Float64(Float64(Float64(y / z) * t) / t)) end
function tmp = code(x, y, z, t) tmp = x * (((y / z) * t) / t); end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 5 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (* x (/ (* (/ y z) t) t)))
double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x * (((y / z) * t) / t)
end function
public static double code(double x, double y, double z, double t) {
return x * (((y / z) * t) / t);
}
def code(x, y, z, t): return x * (((y / z) * t) / t)
function code(x, y, z, t) return Float64(x * Float64(Float64(Float64(y / z) * t) / t)) end
function tmp = code(x, y, z, t) tmp = x * (((y / z) * t) / t); end
code[x_, y_, z_, t_] := N[(x * N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x \cdot \frac{\frac{y}{z} \cdot t}{t}
\end{array}
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* (/ y z) x)) (t_2 (/ y (/ z x))))
(if (<= (/ y z) -2e+285)
t_2
(if (<= (/ y z) -5e-207)
t_1
(if (<= (/ y z) 1e-151)
(/ (* y x) z)
(if (<= (/ y z) 5e+126) t_1 t_2))))))assert(x < y);
double code(double x, double y, double z, double t) {
double t_1 = (y / z) * x;
double t_2 = y / (z / x);
double tmp;
if ((y / z) <= -2e+285) {
tmp = t_2;
} else if ((y / z) <= -5e-207) {
tmp = t_1;
} else if ((y / z) <= 1e-151) {
tmp = (y * x) / z;
} else if ((y / z) <= 5e+126) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: tmp
t_1 = (y / z) * x
t_2 = y / (z / x)
if ((y / z) <= (-2d+285)) then
tmp = t_2
else if ((y / z) <= (-5d-207)) then
tmp = t_1
else if ((y / z) <= 1d-151) then
tmp = (y * x) / z
else if ((y / z) <= 5d+126) then
tmp = t_1
else
tmp = t_2
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t) {
double t_1 = (y / z) * x;
double t_2 = y / (z / x);
double tmp;
if ((y / z) <= -2e+285) {
tmp = t_2;
} else if ((y / z) <= -5e-207) {
tmp = t_1;
} else if ((y / z) <= 1e-151) {
tmp = (y * x) / z;
} else if ((y / z) <= 5e+126) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t): t_1 = (y / z) * x t_2 = y / (z / x) tmp = 0 if (y / z) <= -2e+285: tmp = t_2 elif (y / z) <= -5e-207: tmp = t_1 elif (y / z) <= 1e-151: tmp = (y * x) / z elif (y / z) <= 5e+126: tmp = t_1 else: tmp = t_2 return tmp
x, y = sort([x, y]) function code(x, y, z, t) t_1 = Float64(Float64(y / z) * x) t_2 = Float64(y / Float64(z / x)) tmp = 0.0 if (Float64(y / z) <= -2e+285) tmp = t_2; elseif (Float64(y / z) <= -5e-207) tmp = t_1; elseif (Float64(y / z) <= 1e-151) tmp = Float64(Float64(y * x) / z); elseif (Float64(y / z) <= 5e+126) tmp = t_1; else tmp = t_2; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t)
t_1 = (y / z) * x;
t_2 = y / (z / x);
tmp = 0.0;
if ((y / z) <= -2e+285)
tmp = t_2;
elseif ((y / z) <= -5e-207)
tmp = t_1;
elseif ((y / z) <= 1e-151)
tmp = (y * x) / z;
elseif ((y / z) <= 5e+126)
tmp = t_1;
else
tmp = t_2;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]}, Block[{t$95$2 = N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y / z), $MachinePrecision], -2e+285], t$95$2, If[LessEqual[N[(y / z), $MachinePrecision], -5e-207], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], 1e-151], N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 5e+126], t$95$1, t$95$2]]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_1 := \frac{y}{z} \cdot x\\
t_2 := \frac{y}{\frac{z}{x}}\\
\mathbf{if}\;\frac{y}{z} \leq -2 \cdot 10^{+285}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;\frac{y}{z} \leq -5 \cdot 10^{-207}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{y}{z} \leq 10^{-151}:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{+126}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (/.f64 y z) < -2e285 or 4.99999999999999977e126 < (/.f64 y z) Initial program 69.6%
associate-/l*78.9%
associate-*r/78.9%
*-commutative78.9%
*-inverses78.9%
/-rgt-identity78.9%
*-commutative78.9%
Simplified78.9%
associate-*r/99.0%
*-commutative99.0%
associate-/l*99.8%
Applied egg-rr99.8%
if -2e285 < (/.f64 y z) < -5.00000000000000014e-207 or 9.9999999999999994e-152 < (/.f64 y z) < 4.99999999999999977e126Initial program 82.3%
associate-/l*99.7%
associate-*r/99.7%
*-commutative99.7%
*-inverses99.7%
/-rgt-identity99.7%
*-commutative99.7%
Simplified99.7%
if -5.00000000000000014e-207 < (/.f64 y z) < 9.9999999999999994e-152Initial program 65.2%
associate-/l*80.5%
associate-*r/80.5%
*-commutative80.5%
*-inverses80.5%
/-rgt-identity80.5%
*-commutative80.5%
Simplified80.5%
Taylor expanded in x around 0 97.0%
Final simplification99.0%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(if (or (<= (/ y z) (- INFINITY))
(and (not (<= (/ y z) -5e-246))
(or (<= (/ y z) 2e-253) (not (<= (/ y z) 5e+258)))))
(* y (/ x z))
(* (/ y z) x)))assert(x < y);
double code(double x, double y, double z, double t) {
double tmp;
if (((y / z) <= -((double) INFINITY)) || (!((y / z) <= -5e-246) && (((y / z) <= 2e-253) || !((y / z) <= 5e+258)))) {
tmp = y * (x / z);
} else {
tmp = (y / z) * x;
}
return tmp;
}
assert x < y;
public static double code(double x, double y, double z, double t) {
double tmp;
if (((y / z) <= -Double.POSITIVE_INFINITY) || (!((y / z) <= -5e-246) && (((y / z) <= 2e-253) || !((y / z) <= 5e+258)))) {
tmp = y * (x / z);
} else {
tmp = (y / z) * x;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t): tmp = 0 if ((y / z) <= -math.inf) or (not ((y / z) <= -5e-246) and (((y / z) <= 2e-253) or not ((y / z) <= 5e+258))): tmp = y * (x / z) else: tmp = (y / z) * x return tmp
x, y = sort([x, y]) function code(x, y, z, t) tmp = 0.0 if ((Float64(y / z) <= Float64(-Inf)) || (!(Float64(y / z) <= -5e-246) && ((Float64(y / z) <= 2e-253) || !(Float64(y / z) <= 5e+258)))) tmp = Float64(y * Float64(x / z)); else tmp = Float64(Float64(y / z) * x); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t)
tmp = 0.0;
if (((y / z) <= -Inf) || (~(((y / z) <= -5e-246)) && (((y / z) <= 2e-253) || ~(((y / z) <= 5e+258)))))
tmp = y * (x / z);
else
tmp = (y / z) * x;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := If[Or[LessEqual[N[(y / z), $MachinePrecision], (-Infinity)], And[N[Not[LessEqual[N[(y / z), $MachinePrecision], -5e-246]], $MachinePrecision], Or[LessEqual[N[(y / z), $MachinePrecision], 2e-253], N[Not[LessEqual[N[(y / z), $MachinePrecision], 5e+258]], $MachinePrecision]]]], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;\frac{y}{z} \leq -\infty \lor \neg \left(\frac{y}{z} \leq -5 \cdot 10^{-246}\right) \land \left(\frac{y}{z} \leq 2 \cdot 10^{-253} \lor \neg \left(\frac{y}{z} \leq 5 \cdot 10^{+258}\right)\right):\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\end{array}
\end{array}
if (/.f64 y z) < -inf.0 or -4.9999999999999997e-246 < (/.f64 y z) < 2.0000000000000001e-253 or 5e258 < (/.f64 y z) Initial program 65.4%
associate-/l*67.9%
associate-*r/67.9%
*-commutative67.9%
*-inverses67.9%
/-rgt-identity67.9%
associate-*l/99.8%
associate-*r/99.8%
Simplified99.8%
if -inf.0 < (/.f64 y z) < -4.9999999999999997e-246 or 2.0000000000000001e-253 < (/.f64 y z) < 5e258Initial program 78.9%
associate-/l*99.6%
associate-*r/99.6%
*-commutative99.6%
*-inverses99.6%
/-rgt-identity99.6%
*-commutative99.6%
Simplified99.6%
Final simplification99.7%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* y (/ x z))))
(if (<= (/ y z) (- INFINITY))
t_1
(if (<= (/ y z) -5e-246)
(* (/ y z) x)
(if (or (<= (/ y z) 0.0) (not (<= (/ y z) 1e+297)))
t_1
(/ x (/ z y)))))))assert(x < y);
double code(double x, double y, double z, double t) {
double t_1 = y * (x / z);
double tmp;
if ((y / z) <= -((double) INFINITY)) {
tmp = t_1;
} else if ((y / z) <= -5e-246) {
tmp = (y / z) * x;
} else if (((y / z) <= 0.0) || !((y / z) <= 1e+297)) {
tmp = t_1;
} else {
tmp = x / (z / y);
}
return tmp;
}
assert x < y;
public static double code(double x, double y, double z, double t) {
double t_1 = y * (x / z);
double tmp;
if ((y / z) <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if ((y / z) <= -5e-246) {
tmp = (y / z) * x;
} else if (((y / z) <= 0.0) || !((y / z) <= 1e+297)) {
tmp = t_1;
} else {
tmp = x / (z / y);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t): t_1 = y * (x / z) tmp = 0 if (y / z) <= -math.inf: tmp = t_1 elif (y / z) <= -5e-246: tmp = (y / z) * x elif ((y / z) <= 0.0) or not ((y / z) <= 1e+297): tmp = t_1 else: tmp = x / (z / y) return tmp
x, y = sort([x, y]) function code(x, y, z, t) t_1 = Float64(y * Float64(x / z)) tmp = 0.0 if (Float64(y / z) <= Float64(-Inf)) tmp = t_1; elseif (Float64(y / z) <= -5e-246) tmp = Float64(Float64(y / z) * x); elseif ((Float64(y / z) <= 0.0) || !(Float64(y / z) <= 1e+297)) tmp = t_1; else tmp = Float64(x / Float64(z / y)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t)
t_1 = y * (x / z);
tmp = 0.0;
if ((y / z) <= -Inf)
tmp = t_1;
elseif ((y / z) <= -5e-246)
tmp = (y / z) * x;
elseif (((y / z) <= 0.0) || ~(((y / z) <= 1e+297)))
tmp = t_1;
else
tmp = x / (z / y);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y / z), $MachinePrecision], (-Infinity)], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], -5e-246], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision], If[Or[LessEqual[N[(y / z), $MachinePrecision], 0.0], N[Not[LessEqual[N[(y / z), $MachinePrecision], 1e+297]], $MachinePrecision]], t$95$1, N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_1 := y \cdot \frac{x}{z}\\
\mathbf{if}\;\frac{y}{z} \leq -\infty:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{y}{z} \leq -5 \cdot 10^{-246}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\mathbf{elif}\;\frac{y}{z} \leq 0 \lor \neg \left(\frac{y}{z} \leq 10^{+297}\right):\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\end{array}
\end{array}
if (/.f64 y z) < -inf.0 or -4.9999999999999997e-246 < (/.f64 y z) < -0.0 or 1e297 < (/.f64 y z) Initial program 59.0%
associate-/l*60.5%
associate-*r/60.5%
*-commutative60.5%
*-inverses60.5%
/-rgt-identity60.5%
associate-*l/99.9%
associate-*r/99.8%
Simplified99.8%
if -inf.0 < (/.f64 y z) < -4.9999999999999997e-246Initial program 77.8%
associate-/l*99.8%
associate-*r/99.8%
*-commutative99.8%
*-inverses99.8%
/-rgt-identity99.8%
*-commutative99.8%
Simplified99.8%
if -0.0 < (/.f64 y z) < 1e297Initial program 81.7%
associate-/l*99.4%
associate-*r/99.4%
*-commutative99.4%
*-inverses99.4%
/-rgt-identity99.4%
*-commutative99.4%
Simplified99.4%
clear-num98.5%
un-div-inv98.8%
Applied egg-rr98.8%
Final simplification99.4%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (/ y (/ z x))))
(if (<= (/ y z) -2e+285)
t_1
(if (<= (/ y z) -5e-246)
(* (/ y z) x)
(if (<= (/ y z) 0.0)
(* y (/ x z))
(if (<= (/ y z) 5e+130) (/ x (/ z y)) t_1))))))assert(x < y);
double code(double x, double y, double z, double t) {
double t_1 = y / (z / x);
double tmp;
if ((y / z) <= -2e+285) {
tmp = t_1;
} else if ((y / z) <= -5e-246) {
tmp = (y / z) * x;
} else if ((y / z) <= 0.0) {
tmp = y * (x / z);
} else if ((y / z) <= 5e+130) {
tmp = x / (z / y);
} else {
tmp = t_1;
}
return tmp;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: tmp
t_1 = y / (z / x)
if ((y / z) <= (-2d+285)) then
tmp = t_1
else if ((y / z) <= (-5d-246)) then
tmp = (y / z) * x
else if ((y / z) <= 0.0d0) then
tmp = y * (x / z)
else if ((y / z) <= 5d+130) then
tmp = x / (z / y)
else
tmp = t_1
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t) {
double t_1 = y / (z / x);
double tmp;
if ((y / z) <= -2e+285) {
tmp = t_1;
} else if ((y / z) <= -5e-246) {
tmp = (y / z) * x;
} else if ((y / z) <= 0.0) {
tmp = y * (x / z);
} else if ((y / z) <= 5e+130) {
tmp = x / (z / y);
} else {
tmp = t_1;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t): t_1 = y / (z / x) tmp = 0 if (y / z) <= -2e+285: tmp = t_1 elif (y / z) <= -5e-246: tmp = (y / z) * x elif (y / z) <= 0.0: tmp = y * (x / z) elif (y / z) <= 5e+130: tmp = x / (z / y) else: tmp = t_1 return tmp
x, y = sort([x, y]) function code(x, y, z, t) t_1 = Float64(y / Float64(z / x)) tmp = 0.0 if (Float64(y / z) <= -2e+285) tmp = t_1; elseif (Float64(y / z) <= -5e-246) tmp = Float64(Float64(y / z) * x); elseif (Float64(y / z) <= 0.0) tmp = Float64(y * Float64(x / z)); elseif (Float64(y / z) <= 5e+130) tmp = Float64(x / Float64(z / y)); else tmp = t_1; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t)
t_1 = y / (z / x);
tmp = 0.0;
if ((y / z) <= -2e+285)
tmp = t_1;
elseif ((y / z) <= -5e-246)
tmp = (y / z) * x;
elseif ((y / z) <= 0.0)
tmp = y * (x / z);
elseif ((y / z) <= 5e+130)
tmp = x / (z / y);
else
tmp = t_1;
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(y / z), $MachinePrecision], -2e+285], t$95$1, If[LessEqual[N[(y / z), $MachinePrecision], -5e-246], N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 0.0], N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(y / z), $MachinePrecision], 5e+130], N[(x / N[(z / y), $MachinePrecision]), $MachinePrecision], t$95$1]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_1 := \frac{y}{\frac{z}{x}}\\
\mathbf{if}\;\frac{y}{z} \leq -2 \cdot 10^{+285}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;\frac{y}{z} \leq -5 \cdot 10^{-246}:\\
\;\;\;\;\frac{y}{z} \cdot x\\
\mathbf{elif}\;\frac{y}{z} \leq 0:\\
\;\;\;\;y \cdot \frac{x}{z}\\
\mathbf{elif}\;\frac{y}{z} \leq 5 \cdot 10^{+130}:\\
\;\;\;\;\frac{x}{\frac{z}{y}}\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if (/.f64 y z) < -2e285 or 4.9999999999999996e130 < (/.f64 y z) Initial program 68.6%
associate-/l*78.2%
associate-*r/78.2%
*-commutative78.2%
*-inverses78.2%
/-rgt-identity78.2%
*-commutative78.2%
Simplified78.2%
associate-*r/99.0%
*-commutative99.0%
associate-/l*99.8%
Applied egg-rr99.8%
if -2e285 < (/.f64 y z) < -4.9999999999999997e-246Initial program 77.6%
associate-/l*99.8%
associate-*r/99.8%
*-commutative99.8%
*-inverses99.8%
/-rgt-identity99.8%
*-commutative99.8%
Simplified99.8%
if -4.9999999999999997e-246 < (/.f64 y z) < -0.0Initial program 58.5%
associate-/l*61.3%
associate-*r/61.3%
*-commutative61.3%
*-inverses61.3%
/-rgt-identity61.3%
associate-*l/99.9%
associate-*r/99.9%
Simplified99.9%
if -0.0 < (/.f64 y z) < 4.9999999999999996e130Initial program 82.9%
associate-/l*99.3%
associate-*r/99.3%
*-commutative99.3%
*-inverses99.3%
/-rgt-identity99.3%
*-commutative99.3%
Simplified99.3%
clear-num98.2%
un-div-inv98.4%
Applied egg-rr98.4%
Final simplification99.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t) :precision binary64 (* (/ y z) x))
assert(x < y);
double code(double x, double y, double z, double t) {
return (y / z) * x;
}
NOTE: x and y should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
code = (y / z) * x
end function
assert x < y;
public static double code(double x, double y, double z, double t) {
return (y / z) * x;
}
[x, y] = sort([x, y]) def code(x, y, z, t): return (y / z) * x
x, y = sort([x, y]) function code(x, y, z, t) return Float64(Float64(y / z) * x) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z, t)
tmp = (y / z) * x;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_] := N[(N[(y / z), $MachinePrecision] * x), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\frac{y}{z} \cdot x
\end{array}
Initial program 74.6%
associate-/l*89.5%
associate-*r/89.5%
*-commutative89.5%
*-inverses89.5%
/-rgt-identity89.5%
*-commutative89.5%
Simplified89.5%
Final simplification89.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (* x (/ y z))) (t_2 (/ (* (/ y z) t) t)) (t_3 (/ y (/ z x))))
(if (< t_2 -1.20672205123045e+245)
t_3
(if (< t_2 -5.907522236933906e-275)
t_1
(if (< t_2 5.658954423153415e-65)
t_3
(if (< t_2 2.0087180502407133e+217) t_1 (/ (* y x) z)))))))
double code(double x, double y, double z, double t) {
double t_1 = x * (y / z);
double t_2 = ((y / z) * t) / t;
double t_3 = y / (z / x);
double tmp;
if (t_2 < -1.20672205123045e+245) {
tmp = t_3;
} else if (t_2 < -5.907522236933906e-275) {
tmp = t_1;
} else if (t_2 < 5.658954423153415e-65) {
tmp = t_3;
} else if (t_2 < 2.0087180502407133e+217) {
tmp = t_1;
} else {
tmp = (y * x) / z;
}
return tmp;
}
real(8) function code(x, y, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8) :: t_1
real(8) :: t_2
real(8) :: t_3
real(8) :: tmp
t_1 = x * (y / z)
t_2 = ((y / z) * t) / t
t_3 = y / (z / x)
if (t_2 < (-1.20672205123045d+245)) then
tmp = t_3
else if (t_2 < (-5.907522236933906d-275)) then
tmp = t_1
else if (t_2 < 5.658954423153415d-65) then
tmp = t_3
else if (t_2 < 2.0087180502407133d+217) then
tmp = t_1
else
tmp = (y * x) / z
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = x * (y / z);
double t_2 = ((y / z) * t) / t;
double t_3 = y / (z / x);
double tmp;
if (t_2 < -1.20672205123045e+245) {
tmp = t_3;
} else if (t_2 < -5.907522236933906e-275) {
tmp = t_1;
} else if (t_2 < 5.658954423153415e-65) {
tmp = t_3;
} else if (t_2 < 2.0087180502407133e+217) {
tmp = t_1;
} else {
tmp = (y * x) / z;
}
return tmp;
}
def code(x, y, z, t): t_1 = x * (y / z) t_2 = ((y / z) * t) / t t_3 = y / (z / x) tmp = 0 if t_2 < -1.20672205123045e+245: tmp = t_3 elif t_2 < -5.907522236933906e-275: tmp = t_1 elif t_2 < 5.658954423153415e-65: tmp = t_3 elif t_2 < 2.0087180502407133e+217: tmp = t_1 else: tmp = (y * x) / z return tmp
function code(x, y, z, t) t_1 = Float64(x * Float64(y / z)) t_2 = Float64(Float64(Float64(y / z) * t) / t) t_3 = Float64(y / Float64(z / x)) tmp = 0.0 if (t_2 < -1.20672205123045e+245) tmp = t_3; elseif (t_2 < -5.907522236933906e-275) tmp = t_1; elseif (t_2 < 5.658954423153415e-65) tmp = t_3; elseif (t_2 < 2.0087180502407133e+217) tmp = t_1; else tmp = Float64(Float64(y * x) / z); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x * (y / z); t_2 = ((y / z) * t) / t; t_3 = y / (z / x); tmp = 0.0; if (t_2 < -1.20672205123045e+245) tmp = t_3; elseif (t_2 < -5.907522236933906e-275) tmp = t_1; elseif (t_2 < 5.658954423153415e-65) tmp = t_3; elseif (t_2 < 2.0087180502407133e+217) tmp = t_1; else tmp = (y * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(x * N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(y / z), $MachinePrecision] * t), $MachinePrecision] / t), $MachinePrecision]}, Block[{t$95$3 = N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]}, If[Less[t$95$2, -1.20672205123045e+245], t$95$3, If[Less[t$95$2, -5.907522236933906e-275], t$95$1, If[Less[t$95$2, 5.658954423153415e-65], t$95$3, If[Less[t$95$2, 2.0087180502407133e+217], t$95$1, N[(N[(y * x), $MachinePrecision] / z), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x \cdot \frac{y}{z}\\
t_2 := \frac{\frac{y}{z} \cdot t}{t}\\
t_3 := \frac{y}{\frac{z}{x}}\\
\mathbf{if}\;t_2 < -1.20672205123045 \cdot 10^{+245}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_2 < -5.907522236933906 \cdot 10^{-275}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;t_2 < 5.658954423153415 \cdot 10^{-65}:\\
\;\;\;\;t_3\\
\mathbf{elif}\;t_2 < 2.0087180502407133 \cdot 10^{+217}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{z}\\
\end{array}
\end{array}
herbie shell --seed 2023274
(FPCore (x y z t)
:name "Graphics.Rendering.Chart.Backend.Diagrams:calcFontMetrics from Chart-diagrams-1.5.1, B"
:precision binary64
:herbie-target
(if (< (/ (* (/ y z) t) t) -1.20672205123045e+245) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) -5.907522236933906e-275) (* x (/ y z)) (if (< (/ (* (/ y z) t) t) 5.658954423153415e-65) (/ y (/ z x)) (if (< (/ (* (/ y z) t) t) 2.0087180502407133e+217) (* x (/ y z)) (/ (* y x) z)))))
(* x (/ (* (/ y z) t) t)))