
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
def code(x, y, z, t, a): return ((x * y) - ((z * 9.0) * t)) / (a * 2.0)
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0)) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t a) :precision binary64 (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))
double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
end function
public static double code(double x, double y, double z, double t, double a) {
return ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
def code(x, y, z, t, a): return ((x * y) - ((z * 9.0) * t)) / (a * 2.0)
function code(x, y, z, t, a) return Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0)) end
function tmp = code(x, y, z, t, a) tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0); end
code[x_, y_, z_, t_, a_] := N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}
\end{array}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (- (* x y) (* (* z 9.0) t))))
(if (or (<= t_1 -5e+223) (not (<= t_1 5e+267)))
(- (* x (/ y (* a 2.0))) (* z (/ (* 9.0 t) (* a 2.0))))
(/ t_1 (* a 2.0)))))assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) - ((z * 9.0) * t);
double tmp;
if ((t_1 <= -5e+223) || !(t_1 <= 5e+267)) {
tmp = (x * (y / (a * 2.0))) - (z * ((9.0 * t) / (a * 2.0)));
} else {
tmp = t_1 / (a * 2.0);
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: t_1
real(8) :: tmp
t_1 = (x * y) - ((z * 9.0d0) * t)
if ((t_1 <= (-5d+223)) .or. (.not. (t_1 <= 5d+267))) then
tmp = (x * (y / (a * 2.0d0))) - (z * ((9.0d0 * t) / (a * 2.0d0)))
else
tmp = t_1 / (a * 2.0d0)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = (x * y) - ((z * 9.0) * t);
double tmp;
if ((t_1 <= -5e+223) || !(t_1 <= 5e+267)) {
tmp = (x * (y / (a * 2.0))) - (z * ((9.0 * t) / (a * 2.0)));
} else {
tmp = t_1 / (a * 2.0);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): t_1 = (x * y) - ((z * 9.0) * t) tmp = 0 if (t_1 <= -5e+223) or not (t_1 <= 5e+267): tmp = (x * (y / (a * 2.0))) - (z * ((9.0 * t) / (a * 2.0))) else: tmp = t_1 / (a * 2.0) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) t_1 = Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) tmp = 0.0 if ((t_1 <= -5e+223) || !(t_1 <= 5e+267)) tmp = Float64(Float64(x * Float64(y / Float64(a * 2.0))) - Float64(z * Float64(Float64(9.0 * t) / Float64(a * 2.0)))); else tmp = Float64(t_1 / Float64(a * 2.0)); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = (x * y) - ((z * 9.0) * t);
tmp = 0.0;
if ((t_1 <= -5e+223) || ~((t_1 <= 5e+267)))
tmp = (x * (y / (a * 2.0))) - (z * ((9.0 * t) / (a * 2.0)));
else
tmp = t_1 / (a * 2.0);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
code[x_, y_, z_, t_, a_] := Block[{t$95$1 = N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision]}, If[Or[LessEqual[t$95$1, -5e+223], N[Not[LessEqual[t$95$1, 5e+267]], $MachinePrecision]], N[(N[(x * N[(y / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - N[(z * N[(N[(9.0 * t), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(t$95$1 / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
t_1 := x \cdot y - \left(z \cdot 9\right) \cdot t\\
\mathbf{if}\;t\_1 \leq -5 \cdot 10^{+223} \lor \neg \left(t\_1 \leq 5 \cdot 10^{+267}\right):\\
\;\;\;\;x \cdot \frac{y}{a \cdot 2} - z \cdot \frac{9 \cdot t}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{t\_1}{a \cdot 2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t)) < -4.99999999999999985e223 or 4.9999999999999999e267 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t)) Initial program 79.5%
div-sub78.4%
*-commutative78.4%
div-sub79.5%
cancel-sign-sub-inv79.5%
*-commutative79.5%
fma-define80.7%
distribute-rgt-neg-in80.7%
associate-*r*80.6%
distribute-lft-neg-in80.6%
*-commutative80.6%
distribute-rgt-neg-in80.6%
metadata-eval80.6%
Simplified80.6%
*-un-lft-identity80.6%
*-un-lft-identity80.6%
*-commutative80.6%
associate-*r*80.7%
metadata-eval80.7%
distribute-rgt-neg-in80.7%
distribute-lft-neg-in80.7%
fma-neg79.5%
div-sub78.4%
associate-/l*89.0%
associate-*l*89.0%
associate-/l*96.6%
Applied egg-rr96.6%
if -4.99999999999999985e223 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z #s(literal 9 binary64)) t)) < 4.9999999999999999e267Initial program 99.6%
Final simplification98.5%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= (* x y) -5e+37) (not (<= (* x y) 1.5e-23))) (* y (* 0.5 (/ x a))) (/ (* -9.0 (* z t)) (* a 2.0))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -5e+37) || !((x * y) <= 1.5e-23)) {
tmp = y * (0.5 * (x / a));
} else {
tmp = (-9.0 * (z * t)) / (a * 2.0);
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (((x * y) <= (-5d+37)) .or. (.not. ((x * y) <= 1.5d-23))) then
tmp = y * (0.5d0 * (x / a))
else
tmp = ((-9.0d0) * (z * t)) / (a * 2.0d0)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -5e+37) || !((x * y) <= 1.5e-23)) {
tmp = y * (0.5 * (x / a));
} else {
tmp = (-9.0 * (z * t)) / (a * 2.0);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if ((x * y) <= -5e+37) or not ((x * y) <= 1.5e-23): tmp = y * (0.5 * (x / a)) else: tmp = (-9.0 * (z * t)) / (a * 2.0) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if ((Float64(x * y) <= -5e+37) || !(Float64(x * y) <= 1.5e-23)) tmp = Float64(y * Float64(0.5 * Float64(x / a))); else tmp = Float64(Float64(-9.0 * Float64(z * t)) / Float64(a * 2.0)); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (((x * y) <= -5e+37) || ~(((x * y) <= 1.5e-23)))
tmp = y * (0.5 * (x / a));
else
tmp = (-9.0 * (z * t)) / (a * 2.0);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+37], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.5e-23]], $MachinePrecision]], N[(y * N[(0.5 * N[(x / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-9.0 * N[(z * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+37} \lor \neg \left(x \cdot y \leq 1.5 \cdot 10^{-23}\right):\\
\;\;\;\;y \cdot \left(0.5 \cdot \frac{x}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-9 \cdot \left(z \cdot t\right)}{a \cdot 2}\\
\end{array}
\end{array}
if (*.f64 x y) < -4.99999999999999989e37 or 1.50000000000000001e-23 < (*.f64 x y) Initial program 88.1%
div-sub84.0%
*-commutative84.0%
div-sub88.1%
cancel-sign-sub-inv88.1%
*-commutative88.1%
fma-define88.9%
distribute-rgt-neg-in88.9%
associate-*r*88.9%
distribute-lft-neg-in88.9%
*-commutative88.9%
distribute-rgt-neg-in88.9%
metadata-eval88.9%
Simplified88.9%
Taylor expanded in y around inf 85.9%
Taylor expanded in t around 0 81.2%
if -4.99999999999999989e37 < (*.f64 x y) < 1.50000000000000001e-23Initial program 96.7%
div-sub96.7%
*-commutative96.7%
div-sub96.7%
cancel-sign-sub-inv96.7%
*-commutative96.7%
fma-define96.7%
distribute-rgt-neg-in96.7%
associate-*r*96.8%
distribute-lft-neg-in96.8%
*-commutative96.8%
distribute-rgt-neg-in96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in x around 0 84.1%
Final simplification82.8%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= (* x y) -5e+37) (not (<= (* x y) 1.5e-23))) (* y (* 0.5 (/ x a))) (/ (* (* z t) -4.5) a)))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -5e+37) || !((x * y) <= 1.5e-23)) {
tmp = y * (0.5 * (x / a));
} else {
tmp = ((z * t) * -4.5) / a;
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (((x * y) <= (-5d+37)) .or. (.not. ((x * y) <= 1.5d-23))) then
tmp = y * (0.5d0 * (x / a))
else
tmp = ((z * t) * (-4.5d0)) / a
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -5e+37) || !((x * y) <= 1.5e-23)) {
tmp = y * (0.5 * (x / a));
} else {
tmp = ((z * t) * -4.5) / a;
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if ((x * y) <= -5e+37) or not ((x * y) <= 1.5e-23): tmp = y * (0.5 * (x / a)) else: tmp = ((z * t) * -4.5) / a return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if ((Float64(x * y) <= -5e+37) || !(Float64(x * y) <= 1.5e-23)) tmp = Float64(y * Float64(0.5 * Float64(x / a))); else tmp = Float64(Float64(Float64(z * t) * -4.5) / a); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (((x * y) <= -5e+37) || ~(((x * y) <= 1.5e-23)))
tmp = y * (0.5 * (x / a));
else
tmp = ((z * t) * -4.5) / a;
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+37], N[Not[LessEqual[N[(x * y), $MachinePrecision], 1.5e-23]], $MachinePrecision]], N[(y * N[(0.5 * N[(x / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z * t), $MachinePrecision] * -4.5), $MachinePrecision] / a), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+37} \lor \neg \left(x \cdot y \leq 1.5 \cdot 10^{-23}\right):\\
\;\;\;\;y \cdot \left(0.5 \cdot \frac{x}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(z \cdot t\right) \cdot -4.5}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -4.99999999999999989e37 or 1.50000000000000001e-23 < (*.f64 x y) Initial program 88.1%
div-sub84.0%
*-commutative84.0%
div-sub88.1%
cancel-sign-sub-inv88.1%
*-commutative88.1%
fma-define88.9%
distribute-rgt-neg-in88.9%
associate-*r*88.9%
distribute-lft-neg-in88.9%
*-commutative88.9%
distribute-rgt-neg-in88.9%
metadata-eval88.9%
Simplified88.9%
Taylor expanded in y around inf 85.9%
Taylor expanded in t around 0 81.2%
if -4.99999999999999989e37 < (*.f64 x y) < 1.50000000000000001e-23Initial program 96.7%
div-sub96.7%
*-commutative96.7%
div-sub96.7%
cancel-sign-sub-inv96.7%
*-commutative96.7%
fma-define96.7%
distribute-rgt-neg-in96.7%
associate-*r*96.8%
distribute-lft-neg-in96.8%
*-commutative96.8%
distribute-rgt-neg-in96.8%
metadata-eval96.8%
Simplified96.8%
Taylor expanded in y around inf 73.3%
Taylor expanded in a around 0 83.2%
Taylor expanded in y around 0 84.1%
Final simplification82.8%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) -2e+275) (* 0.5 (* x (/ y a))) (/ (- (* x y) (* (* z 9.0) t)) (* a 2.0))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -2e+275) {
tmp = 0.5 * (x * (y / a));
} else {
tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((x * y) <= (-2d+275)) then
tmp = 0.5d0 * (x * (y / a))
else
tmp = ((x * y) - ((z * 9.0d0) * t)) / (a * 2.0d0)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -2e+275) {
tmp = 0.5 * (x * (y / a));
} else {
tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -2e+275: tmp = 0.5 * (x * (y / a)) else: tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -2e+275) tmp = Float64(0.5 * Float64(x * Float64(y / a))); else tmp = Float64(Float64(Float64(x * y) - Float64(Float64(z * 9.0) * t)) / Float64(a * 2.0)); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -2e+275)
tmp = 0.5 * (x * (y / a));
else
tmp = ((x * y) - ((z * 9.0) * t)) / (a * 2.0);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -2e+275], N[(0.5 * N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(N[(x * y), $MachinePrecision] - N[(N[(z * 9.0), $MachinePrecision] * t), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -2 \cdot 10^{+275}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot y - \left(z \cdot 9\right) \cdot t}{a \cdot 2}\\
\end{array}
\end{array}
if (*.f64 x y) < -1.99999999999999992e275Initial program 66.9%
div-sub63.1%
*-commutative63.1%
div-sub66.9%
cancel-sign-sub-inv66.9%
*-commutative66.9%
fma-define66.9%
distribute-rgt-neg-in66.9%
associate-*r*66.9%
distribute-lft-neg-in66.9%
*-commutative66.9%
distribute-rgt-neg-in66.9%
metadata-eval66.9%
Simplified66.9%
Taylor expanded in x around inf 66.9%
associate-/l*96.3%
Simplified96.3%
if -1.99999999999999992e275 < (*.f64 x y) Initial program 95.5%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= x -1.85e+78) (not (<= x 2.65e-78))) (* 0.5 (* x (/ y a))) (* -4.5 (/ (* z t) a))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x <= -1.85e+78) || !(x <= 2.65e-78)) {
tmp = 0.5 * (x * (y / a));
} else {
tmp = -4.5 * ((z * t) / a);
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if ((x <= (-1.85d+78)) .or. (.not. (x <= 2.65d-78))) then
tmp = 0.5d0 * (x * (y / a))
else
tmp = (-4.5d0) * ((z * t) / a)
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x <= -1.85e+78) || !(x <= 2.65e-78)) {
tmp = 0.5 * (x * (y / a));
} else {
tmp = -4.5 * ((z * t) / a);
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if (x <= -1.85e+78) or not (x <= 2.65e-78): tmp = 0.5 * (x * (y / a)) else: tmp = -4.5 * ((z * t) / a) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if ((x <= -1.85e+78) || !(x <= 2.65e-78)) tmp = Float64(0.5 * Float64(x * Float64(y / a))); else tmp = Float64(-4.5 * Float64(Float64(z * t) / a)); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x <= -1.85e+78) || ~((x <= 2.65e-78)))
tmp = 0.5 * (x * (y / a));
else
tmp = -4.5 * ((z * t) / a);
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[x, -1.85e+78], N[Not[LessEqual[x, 2.65e-78]], $MachinePrecision]], N[(0.5 * N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 * N[(N[(z * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.85 \cdot 10^{+78} \lor \neg \left(x \leq 2.65 \cdot 10^{-78}\right):\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\
\mathbf{else}:\\
\;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\
\end{array}
\end{array}
if x < -1.84999999999999992e78 or 2.64999999999999979e-78 < x Initial program 89.7%
div-sub86.7%
*-commutative86.7%
div-sub89.7%
cancel-sign-sub-inv89.7%
*-commutative89.7%
fma-define90.5%
distribute-rgt-neg-in90.5%
associate-*r*90.5%
distribute-lft-neg-in90.5%
*-commutative90.5%
distribute-rgt-neg-in90.5%
metadata-eval90.5%
Simplified90.5%
Taylor expanded in x around inf 62.8%
associate-/l*66.6%
Simplified66.6%
if -1.84999999999999992e78 < x < 2.64999999999999979e-78Initial program 95.7%
div-sub94.9%
*-commutative94.9%
div-sub95.7%
cancel-sign-sub-inv95.7%
*-commutative95.7%
fma-define95.7%
distribute-rgt-neg-in95.7%
associate-*r*95.7%
distribute-lft-neg-in95.7%
*-commutative95.7%
distribute-rgt-neg-in95.7%
metadata-eval95.7%
Simplified95.7%
Taylor expanded in x around 0 74.6%
Final simplification70.5%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= x -1.25e+76) (* 0.5 (* x (/ y a))) (if (<= x 5.8e-78) (* -4.5 (/ (* z t) a)) (* y (* 0.5 (/ x a))))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -1.25e+76) {
tmp = 0.5 * (x * (y / a));
} else if (x <= 5.8e-78) {
tmp = -4.5 * ((z * t) / a);
} else {
tmp = y * (0.5 * (x / a));
}
return tmp;
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (x <= (-1.25d+76)) then
tmp = 0.5d0 * (x * (y / a))
else if (x <= 5.8d-78) then
tmp = (-4.5d0) * ((z * t) / a)
else
tmp = y * (0.5d0 * (x / a))
end if
code = tmp
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (x <= -1.25e+76) {
tmp = 0.5 * (x * (y / a));
} else if (x <= 5.8e-78) {
tmp = -4.5 * ((z * t) / a);
} else {
tmp = y * (0.5 * (x / a));
}
return tmp;
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): tmp = 0 if x <= -1.25e+76: tmp = 0.5 * (x * (y / a)) elif x <= 5.8e-78: tmp = -4.5 * ((z * t) / a) else: tmp = y * (0.5 * (x / a)) return tmp
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) tmp = 0.0 if (x <= -1.25e+76) tmp = Float64(0.5 * Float64(x * Float64(y / a))); elseif (x <= 5.8e-78) tmp = Float64(-4.5 * Float64(Float64(z * t) / a)); else tmp = Float64(y * Float64(0.5 * Float64(x / a))); end return tmp end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (x <= -1.25e+76)
tmp = 0.5 * (x * (y / a));
elseif (x <= 5.8e-78)
tmp = -4.5 * ((z * t) / a);
else
tmp = y * (0.5 * (x / a));
end
tmp_2 = tmp;
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[x, -1.25e+76], N[(0.5 * N[(x * N[(y / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 5.8e-78], N[(-4.5 * N[(N[(z * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], N[(y * N[(0.5 * N[(x / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.25 \cdot 10^{+76}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{y}{a}\right)\\
\mathbf{elif}\;x \leq 5.8 \cdot 10^{-78}:\\
\;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(0.5 \cdot \frac{x}{a}\right)\\
\end{array}
\end{array}
if x < -1.24999999999999998e76Initial program 85.8%
div-sub85.8%
*-commutative85.8%
div-sub85.8%
cancel-sign-sub-inv85.8%
*-commutative85.8%
fma-define87.9%
distribute-rgt-neg-in87.9%
associate-*r*88.0%
distribute-lft-neg-in88.0%
*-commutative88.0%
distribute-rgt-neg-in88.0%
metadata-eval88.0%
Simplified88.0%
Taylor expanded in x around inf 68.5%
associate-/l*73.9%
Simplified73.9%
if -1.24999999999999998e76 < x < 5.8000000000000001e-78Initial program 95.7%
div-sub94.9%
*-commutative94.9%
div-sub95.7%
cancel-sign-sub-inv95.7%
*-commutative95.7%
fma-define95.7%
distribute-rgt-neg-in95.7%
associate-*r*95.7%
distribute-lft-neg-in95.7%
*-commutative95.7%
distribute-rgt-neg-in95.7%
metadata-eval95.7%
Simplified95.7%
Taylor expanded in x around 0 74.6%
if 5.8000000000000001e-78 < x Initial program 91.9%
div-sub87.2%
*-commutative87.2%
div-sub91.9%
cancel-sign-sub-inv91.9%
*-commutative91.9%
fma-define91.9%
distribute-rgt-neg-in91.9%
associate-*r*91.9%
distribute-lft-neg-in91.9%
*-commutative91.9%
distribute-rgt-neg-in91.9%
metadata-eval91.9%
Simplified91.9%
Taylor expanded in y around inf 76.5%
Taylor expanded in t around 0 57.0%
Final simplification68.6%
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* -4.5 (* t (/ z a))))
assert(x < y && y < z && z < t && t < a);
double code(double x, double y, double z, double t, double a) {
return -4.5 * (t * (z / a));
}
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function.
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
code = (-4.5d0) * (t * (z / a))
end function
assert x < y && y < z && z < t && t < a;
public static double code(double x, double y, double z, double t, double a) {
return -4.5 * (t * (z / a));
}
[x, y, z, t, a] = sort([x, y, z, t, a]) def code(x, y, z, t, a): return -4.5 * (t * (z / a))
x, y, z, t, a = sort([x, y, z, t, a]) function code(x, y, z, t, a) return Float64(-4.5 * Float64(t * Float64(z / a))) end
x, y, z, t, a = num2cell(sort([x, y, z, t, a])){:}
function tmp = code(x, y, z, t, a)
tmp = -4.5 * (t * (z / a));
end
NOTE: x, y, z, t, and a should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(-4.5 * N[(t * N[(z / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y, z, t, a] = \mathsf{sort}([x, y, z, t, a])\\
\\
-4.5 \cdot \left(t \cdot \frac{z}{a}\right)
\end{array}
Initial program 92.6%
div-sub90.6%
*-commutative90.6%
div-sub92.6%
cancel-sign-sub-inv92.6%
*-commutative92.6%
fma-define93.0%
distribute-rgt-neg-in93.0%
associate-*r*93.0%
distribute-lft-neg-in93.0%
*-commutative93.0%
distribute-rgt-neg-in93.0%
metadata-eval93.0%
Simplified93.0%
Taylor expanded in x around 0 55.6%
associate-/l*55.9%
Simplified55.9%
(FPCore (x y z t a)
:precision binary64
(if (< a -2.090464557976709e+86)
(- (* 0.5 (/ (* y x) a)) (* 4.5 (/ t (/ a z))))
(if (< a 2.144030707833976e+99)
(/ (- (* x y) (* z (* 9.0 t))) (* a 2.0))
(- (* (/ y a) (* x 0.5)) (* (/ t a) (* z 4.5))))))
double code(double x, double y, double z, double t, double a) {
double tmp;
if (a < -2.090464557976709e+86) {
tmp = (0.5 * ((y * x) / a)) - (4.5 * (t / (a / z)));
} else if (a < 2.144030707833976e+99) {
tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0);
} else {
tmp = ((y / a) * (x * 0.5)) - ((t / a) * (z * 4.5));
}
return tmp;
}
real(8) function code(x, y, z, t, a)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8), intent (in) :: t
real(8), intent (in) :: a
real(8) :: tmp
if (a < (-2.090464557976709d+86)) then
tmp = (0.5d0 * ((y * x) / a)) - (4.5d0 * (t / (a / z)))
else if (a < 2.144030707833976d+99) then
tmp = ((x * y) - (z * (9.0d0 * t))) / (a * 2.0d0)
else
tmp = ((y / a) * (x * 0.5d0)) - ((t / a) * (z * 4.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (a < -2.090464557976709e+86) {
tmp = (0.5 * ((y * x) / a)) - (4.5 * (t / (a / z)));
} else if (a < 2.144030707833976e+99) {
tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0);
} else {
tmp = ((y / a) * (x * 0.5)) - ((t / a) * (z * 4.5));
}
return tmp;
}
def code(x, y, z, t, a): tmp = 0 if a < -2.090464557976709e+86: tmp = (0.5 * ((y * x) / a)) - (4.5 * (t / (a / z))) elif a < 2.144030707833976e+99: tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0) else: tmp = ((y / a) * (x * 0.5)) - ((t / a) * (z * 4.5)) return tmp
function code(x, y, z, t, a) tmp = 0.0 if (a < -2.090464557976709e+86) tmp = Float64(Float64(0.5 * Float64(Float64(y * x) / a)) - Float64(4.5 * Float64(t / Float64(a / z)))); elseif (a < 2.144030707833976e+99) tmp = Float64(Float64(Float64(x * y) - Float64(z * Float64(9.0 * t))) / Float64(a * 2.0)); else tmp = Float64(Float64(Float64(y / a) * Float64(x * 0.5)) - Float64(Float64(t / a) * Float64(z * 4.5))); end return tmp end
function tmp_2 = code(x, y, z, t, a) tmp = 0.0; if (a < -2.090464557976709e+86) tmp = (0.5 * ((y * x) / a)) - (4.5 * (t / (a / z))); elseif (a < 2.144030707833976e+99) tmp = ((x * y) - (z * (9.0 * t))) / (a * 2.0); else tmp = ((y / a) * (x * 0.5)) - ((t / a) * (z * 4.5)); end tmp_2 = tmp; end
code[x_, y_, z_, t_, a_] := If[Less[a, -2.090464557976709e+86], N[(N[(0.5 * N[(N[(y * x), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] - N[(4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[Less[a, 2.144030707833976e+99], N[(N[(N[(x * y), $MachinePrecision] - N[(z * N[(9.0 * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(N[(N[(y / a), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision] - N[(N[(t / a), $MachinePrecision] * N[(z * 4.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;a < -2.090464557976709 \cdot 10^{+86}:\\
\;\;\;\;0.5 \cdot \frac{y \cdot x}{a} - 4.5 \cdot \frac{t}{\frac{a}{z}}\\
\mathbf{elif}\;a < 2.144030707833976 \cdot 10^{+99}:\\
\;\;\;\;\frac{x \cdot y - z \cdot \left(9 \cdot t\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{a} \cdot \left(x \cdot 0.5\right) - \frac{t}{a} \cdot \left(z \cdot 4.5\right)\\
\end{array}
\end{array}
herbie shell --seed 2024133
(FPCore (x y z t a)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, I"
:precision binary64
:alt
(! :herbie-platform default (if (< a -209046455797670900000000000000000000000000000000000000000000000000000000000000000000000) (- (* 1/2 (/ (* y x) a)) (* 9/2 (/ t (/ a z)))) (if (< a 2144030707833976000000000000000000000000000000000000000000000000000000000000000000000000000000000000) (/ (- (* x y) (* z (* 9 t))) (* a 2)) (- (* (/ y a) (* x 1/2)) (* (/ t a) (* z 9/2))))))
(/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))