
(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 11 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 and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= (* a 2.0) -1e+53) (not (<= (* a 2.0) 5e-44))) (fma x (* y (/ 0.5 a)) (* (/ z a) (* 0.5 (* t (- 9.0))))) (/ (fma x y (* -9.0 (* z t))) (* a 2.0))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((a * 2.0) <= -1e+53) || !((a * 2.0) <= 5e-44)) {
tmp = fma(x, (y * (0.5 / a)), ((z / a) * (0.5 * (t * -9.0))));
} else {
tmp = fma(x, y, (-9.0 * (z * t))) / (a * 2.0);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if ((Float64(a * 2.0) <= -1e+53) || !(Float64(a * 2.0) <= 5e-44)) tmp = fma(x, Float64(y * Float64(0.5 / a)), Float64(Float64(z / a) * Float64(0.5 * Float64(t * Float64(-9.0))))); else tmp = Float64(fma(x, y, Float64(-9.0 * Float64(z * t))) / Float64(a * 2.0)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(a * 2.0), $MachinePrecision], -1e+53], N[Not[LessEqual[N[(a * 2.0), $MachinePrecision], 5e-44]], $MachinePrecision]], N[(x * N[(y * N[(0.5 / a), $MachinePrecision]), $MachinePrecision] + N[(N[(z / a), $MachinePrecision] * N[(0.5 * N[(t * (-9.0)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y + N[(-9.0 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;a \cdot 2 \leq -1 \cdot 10^{+53} \lor \neg \left(a \cdot 2 \leq 5 \cdot 10^{-44}\right):\\
\;\;\;\;\mathsf{fma}\left(x, y \cdot \frac{0.5}{a}, \frac{z}{a} \cdot \left(0.5 \cdot \left(t \cdot \left(-9\right)\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, -9 \cdot \left(z \cdot t\right)\right)}{a \cdot 2}\\
\end{array}
\end{array}
if (*.f64 a 2) < -9.9999999999999999e52 or 5.00000000000000039e-44 < (*.f64 a 2) Initial program 79.6%
associate-*l*79.6%
Simplified79.6%
div-sub79.6%
div-inv79.6%
*-commutative79.6%
associate-/r*79.6%
metadata-eval79.6%
times-frac88.6%
Applied egg-rr88.6%
cancel-sign-sub-inv88.6%
associate-*l*96.7%
fma-def96.7%
div-inv96.7%
*-commutative96.7%
metadata-eval96.7%
Applied egg-rr96.7%
if -9.9999999999999999e52 < (*.f64 a 2) < 5.00000000000000039e-44Initial program 95.1%
fma-neg96.7%
*-commutative96.7%
associate-*l*96.7%
distribute-lft-neg-in96.7%
metadata-eval96.7%
Simplified96.7%
Final simplification96.7%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (- (* x y) (* t (* z 9.0))) (- INFINITY)) (- (* (/ 0.5 a) (* x y)) (* (/ z a) (/ (* t 9.0) 2.0))) (* (/ 0.5 a) (fma x y (* z (* t -9.0))))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) - (t * (z * 9.0))) <= -((double) INFINITY)) {
tmp = ((0.5 / a) * (x * y)) - ((z / a) * ((t * 9.0) / 2.0));
} else {
tmp = (0.5 / a) * fma(x, y, (z * (t * -9.0)));
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(x * y) - Float64(t * Float64(z * 9.0))) <= Float64(-Inf)) tmp = Float64(Float64(Float64(0.5 / a) * Float64(x * y)) - Float64(Float64(z / a) * Float64(Float64(t * 9.0) / 2.0))); else tmp = Float64(Float64(0.5 / a) * fma(x, y, Float64(z * Float64(t * -9.0)))); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] - N[(t * N[(z * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], (-Infinity)], N[(N[(N[(0.5 / a), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision] - N[(N[(z / a), $MachinePrecision] * N[(N[(t * 9.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(0.5 / a), $MachinePrecision] * N[(x * y + N[(z * N[(t * -9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y - t \cdot \left(z \cdot 9\right) \leq -\infty:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y\right) - \frac{z}{a} \cdot \frac{t \cdot 9}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{0.5}{a} \cdot \mathsf{fma}\left(x, y, z \cdot \left(t \cdot -9\right)\right)\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < -inf.0Initial program 56.4%
associate-*l*56.4%
Simplified56.4%
div-sub48.7%
div-inv48.7%
*-commutative48.7%
associate-/r*48.7%
metadata-eval48.7%
times-frac85.0%
Applied egg-rr85.0%
if -inf.0 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) Initial program 90.8%
associate-*l*90.8%
Simplified90.8%
div-inv90.8%
fma-neg92.1%
distribute-rgt-neg-in92.1%
*-commutative92.1%
distribute-rgt-neg-in92.1%
metadata-eval92.1%
*-commutative92.1%
associate-/r*92.1%
metadata-eval92.1%
Applied egg-rr92.1%
Final simplification91.4%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (- (* x y) (* t (* z 9.0))) -1e+217) (- (* (/ 0.5 a) (* x y)) (* (/ z a) (/ (* t 9.0) 2.0))) (/ (fma x y (* -9.0 (* z t))) (* a 2.0))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) - (t * (z * 9.0))) <= -1e+217) {
tmp = ((0.5 / a) * (x * y)) - ((z / a) * ((t * 9.0) / 2.0));
} else {
tmp = fma(x, y, (-9.0 * (z * t))) / (a * 2.0);
}
return tmp;
}
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(Float64(x * y) - Float64(t * Float64(z * 9.0))) <= -1e+217) tmp = Float64(Float64(Float64(0.5 / a) * Float64(x * y)) - Float64(Float64(z / a) * Float64(Float64(t * 9.0) / 2.0))); else tmp = Float64(fma(x, y, Float64(-9.0 * Float64(z * t))) / Float64(a * 2.0)); end return tmp end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(N[(x * y), $MachinePrecision] - N[(t * N[(z * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], -1e+217], N[(N[(N[(0.5 / a), $MachinePrecision] * N[(x * y), $MachinePrecision]), $MachinePrecision] - N[(N[(z / a), $MachinePrecision] * N[(N[(t * 9.0), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * y + N[(-9.0 * N[(z * t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y - t \cdot \left(z \cdot 9\right) \leq -1 \cdot 10^{+217}:\\
\;\;\;\;\frac{0.5}{a} \cdot \left(x \cdot y\right) - \frac{z}{a} \cdot \frac{t \cdot 9}{2}\\
\mathbf{else}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, y, -9 \cdot \left(z \cdot t\right)\right)}{a \cdot 2}\\
\end{array}
\end{array}
if (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) < -9.9999999999999996e216Initial program 70.1%
associate-*l*70.1%
Simplified70.1%
div-sub64.8%
div-inv64.8%
*-commutative64.8%
associate-/r*64.8%
metadata-eval64.8%
times-frac86.9%
Applied egg-rr86.9%
if -9.9999999999999996e216 < (-.f64 (*.f64 x y) (*.f64 (*.f64 z 9) t)) Initial program 90.3%
fma-neg91.7%
*-commutative91.7%
associate-*l*91.7%
distribute-lft-neg-in91.7%
metadata-eval91.7%
Simplified91.7%
Final simplification91.0%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* t (* z 9.0))) (t_2 (* t (* (/ z a) -4.5))))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -5e-222)
(/ (- (* x y) t_1) (* a 2.0))
(if (<= t_1 2e-251)
(* (* x 0.5) (/ y a))
(if (<= t_1 5e+219)
(+ (* -4.5 (/ (* z t) a)) (* 0.5 (/ (* x y) a)))
t_2))))))assert(x < y);
double code(double x, double y, double z, double t, double a) {
double t_1 = t * (z * 9.0);
double t_2 = t * ((z / a) * -4.5);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -5e-222) {
tmp = ((x * y) - t_1) / (a * 2.0);
} else if (t_1 <= 2e-251) {
tmp = (x * 0.5) * (y / a);
} else if (t_1 <= 5e+219) {
tmp = (-4.5 * ((z * t) / a)) + (0.5 * ((x * y) / a));
} else {
tmp = t_2;
}
return tmp;
}
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = t * (z * 9.0);
double t_2 = t * ((z / a) * -4.5);
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = t_2;
} else if (t_1 <= -5e-222) {
tmp = ((x * y) - t_1) / (a * 2.0);
} else if (t_1 <= 2e-251) {
tmp = (x * 0.5) * (y / a);
} else if (t_1 <= 5e+219) {
tmp = (-4.5 * ((z * t) / a)) + (0.5 * ((x * y) / a));
} else {
tmp = t_2;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): t_1 = t * (z * 9.0) t_2 = t * ((z / a) * -4.5) tmp = 0 if t_1 <= -math.inf: tmp = t_2 elif t_1 <= -5e-222: tmp = ((x * y) - t_1) / (a * 2.0) elif t_1 <= 2e-251: tmp = (x * 0.5) * (y / a) elif t_1 <= 5e+219: tmp = (-4.5 * ((z * t) / a)) + (0.5 * ((x * y) / a)) else: tmp = t_2 return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) t_1 = Float64(t * Float64(z * 9.0)) t_2 = Float64(t * Float64(Float64(z / a) * -4.5)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= -5e-222) tmp = Float64(Float64(Float64(x * y) - t_1) / Float64(a * 2.0)); elseif (t_1 <= 2e-251) tmp = Float64(Float64(x * 0.5) * Float64(y / a)); elseif (t_1 <= 5e+219) tmp = Float64(Float64(-4.5 * Float64(Float64(z * t) / a)) + Float64(0.5 * Float64(Float64(x * y) / a))); else tmp = t_2; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = t * (z * 9.0);
t_2 = t * ((z / a) * -4.5);
tmp = 0.0;
if (t_1 <= -Inf)
tmp = t_2;
elseif (t_1 <= -5e-222)
tmp = ((x * y) - t_1) / (a * 2.0);
elseif (t_1 <= 2e-251)
tmp = (x * 0.5) * (y / a);
elseif (t_1 <= 5e+219)
tmp = (-4.5 * ((z * t) / a)) + (0.5 * ((x * y) / a));
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_, a_] := Block[{t$95$1 = N[(t * N[(z * 9.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(N[(z / a), $MachinePrecision] * -4.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, -5e-222], N[(N[(N[(x * y), $MachinePrecision] - t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-251], N[(N[(x * 0.5), $MachinePrecision] * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+219], N[(N[(-4.5 * N[(N[(z * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision] + N[(0.5 * N[(N[(x * y), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_1 := t \cdot \left(z \cdot 9\right)\\
t_2 := t \cdot \left(\frac{z}{a} \cdot -4.5\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq -5 \cdot 10^{-222}:\\
\;\;\;\;\frac{x \cdot y - t_1}{a \cdot 2}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-251}:\\
\;\;\;\;\left(x \cdot 0.5\right) \cdot \frac{y}{a}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+219}:\\
\;\;\;\;-4.5 \cdot \frac{z \cdot t}{a} + 0.5 \cdot \frac{x \cdot y}{a}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 z 9) t) < -inf.0 or 5e219 < (*.f64 (*.f64 z 9) t) Initial program 53.3%
associate-*l*53.2%
Simplified53.2%
div-inv53.2%
fma-neg60.2%
distribute-rgt-neg-in60.2%
*-commutative60.2%
distribute-rgt-neg-in60.2%
metadata-eval60.2%
*-commutative60.2%
associate-/r*60.2%
metadata-eval60.2%
Applied egg-rr60.2%
Taylor expanded in x around 0 60.2%
associate-*r/92.8%
*-commutative92.8%
associate-*l*92.9%
*-commutative92.9%
Simplified92.9%
if -inf.0 < (*.f64 (*.f64 z 9) t) < -5.00000000000000008e-222Initial program 97.5%
if -5.00000000000000008e-222 < (*.f64 (*.f64 z 9) t) < 2.00000000000000003e-251Initial program 83.7%
associate-*l*83.7%
Simplified83.7%
div-inv83.6%
fma-neg83.6%
distribute-rgt-neg-in83.6%
*-commutative83.6%
distribute-rgt-neg-in83.6%
metadata-eval83.6%
*-commutative83.6%
associate-/r*83.6%
metadata-eval83.6%
Applied egg-rr83.6%
Taylor expanded in x around inf 81.8%
associate-*r/81.9%
Applied egg-rr81.9%
*-commutative81.9%
associate-*r*81.9%
*-un-lft-identity81.9%
times-frac93.1%
Applied egg-rr93.1%
if 2.00000000000000003e-251 < (*.f64 (*.f64 z 9) t) < 5e219Initial program 96.0%
associate-*l*95.9%
Simplified95.9%
Taylor expanded in x around 0 96.0%
Final simplification95.5%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* t (* z 9.0))) (t_2 (* t (* (/ z a) -4.5))))
(if (<= t_1 (- INFINITY))
t_2
(if (<= t_1 -5e-222)
(/ (- (* x y) t_1) (* a 2.0))
(if (<= t_1 2e-251)
(* (* x 0.5) (/ y a))
(if (<= t_1 5e+219)
(/ (- (* x y) (* z (* t 9.0))) (* a 2.0))
t_2))))))assert(x < y);
double code(double x, double y, double z, double t, double a) {
double t_1 = t * (z * 9.0);
double t_2 = t * ((z / a) * -4.5);
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = t_2;
} else if (t_1 <= -5e-222) {
tmp = ((x * y) - t_1) / (a * 2.0);
} else if (t_1 <= 2e-251) {
tmp = (x * 0.5) * (y / a);
} else if (t_1 <= 5e+219) {
tmp = ((x * y) - (z * (t * 9.0))) / (a * 2.0);
} else {
tmp = t_2;
}
return tmp;
}
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double t_1 = t * (z * 9.0);
double t_2 = t * ((z / a) * -4.5);
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = t_2;
} else if (t_1 <= -5e-222) {
tmp = ((x * y) - t_1) / (a * 2.0);
} else if (t_1 <= 2e-251) {
tmp = (x * 0.5) * (y / a);
} else if (t_1 <= 5e+219) {
tmp = ((x * y) - (z * (t * 9.0))) / (a * 2.0);
} else {
tmp = t_2;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): t_1 = t * (z * 9.0) t_2 = t * ((z / a) * -4.5) tmp = 0 if t_1 <= -math.inf: tmp = t_2 elif t_1 <= -5e-222: tmp = ((x * y) - t_1) / (a * 2.0) elif t_1 <= 2e-251: tmp = (x * 0.5) * (y / a) elif t_1 <= 5e+219: tmp = ((x * y) - (z * (t * 9.0))) / (a * 2.0) else: tmp = t_2 return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) t_1 = Float64(t * Float64(z * 9.0)) t_2 = Float64(t * Float64(Float64(z / a) * -4.5)) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = t_2; elseif (t_1 <= -5e-222) tmp = Float64(Float64(Float64(x * y) - t_1) / Float64(a * 2.0)); elseif (t_1 <= 2e-251) tmp = Float64(Float64(x * 0.5) * Float64(y / a)); elseif (t_1 <= 5e+219) tmp = Float64(Float64(Float64(x * y) - Float64(z * Float64(t * 9.0))) / Float64(a * 2.0)); else tmp = t_2; end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
t_1 = t * (z * 9.0);
t_2 = t * ((z / a) * -4.5);
tmp = 0.0;
if (t_1 <= -Inf)
tmp = t_2;
elseif (t_1 <= -5e-222)
tmp = ((x * y) - t_1) / (a * 2.0);
elseif (t_1 <= 2e-251)
tmp = (x * 0.5) * (y / a);
elseif (t_1 <= 5e+219)
tmp = ((x * y) - (z * (t * 9.0))) / (a * 2.0);
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_, a_] := Block[{t$95$1 = N[(t * N[(z * 9.0), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(t * N[(N[(z / a), $MachinePrecision] * -4.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], t$95$2, If[LessEqual[t$95$1, -5e-222], N[(N[(N[(x * y), $MachinePrecision] - t$95$1), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e-251], N[(N[(x * 0.5), $MachinePrecision] * N[(y / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 5e+219], N[(N[(N[(x * y), $MachinePrecision] - N[(z * N[(t * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], t$95$2]]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_1 := t \cdot \left(z \cdot 9\right)\\
t_2 := t \cdot \left(\frac{z}{a} \cdot -4.5\right)\\
\mathbf{if}\;t_1 \leq -\infty:\\
\;\;\;\;t_2\\
\mathbf{elif}\;t_1 \leq -5 \cdot 10^{-222}:\\
\;\;\;\;\frac{x \cdot y - t_1}{a \cdot 2}\\
\mathbf{elif}\;t_1 \leq 2 \cdot 10^{-251}:\\
\;\;\;\;\left(x \cdot 0.5\right) \cdot \frac{y}{a}\\
\mathbf{elif}\;t_1 \leq 5 \cdot 10^{+219}:\\
\;\;\;\;\frac{x \cdot y - z \cdot \left(t \cdot 9\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if (*.f64 (*.f64 z 9) t) < -inf.0 or 5e219 < (*.f64 (*.f64 z 9) t) Initial program 53.3%
associate-*l*53.2%
Simplified53.2%
div-inv53.2%
fma-neg60.2%
distribute-rgt-neg-in60.2%
*-commutative60.2%
distribute-rgt-neg-in60.2%
metadata-eval60.2%
*-commutative60.2%
associate-/r*60.2%
metadata-eval60.2%
Applied egg-rr60.2%
Taylor expanded in x around 0 60.2%
associate-*r/92.8%
*-commutative92.8%
associate-*l*92.9%
*-commutative92.9%
Simplified92.9%
if -inf.0 < (*.f64 (*.f64 z 9) t) < -5.00000000000000008e-222Initial program 97.5%
if -5.00000000000000008e-222 < (*.f64 (*.f64 z 9) t) < 2.00000000000000003e-251Initial program 83.7%
associate-*l*83.7%
Simplified83.7%
div-inv83.6%
fma-neg83.6%
distribute-rgt-neg-in83.6%
*-commutative83.6%
distribute-rgt-neg-in83.6%
metadata-eval83.6%
*-commutative83.6%
associate-/r*83.6%
metadata-eval83.6%
Applied egg-rr83.6%
Taylor expanded in x around inf 81.8%
associate-*r/81.9%
Applied egg-rr81.9%
*-commutative81.9%
associate-*r*81.9%
*-un-lft-identity81.9%
times-frac93.1%
Applied egg-rr93.1%
if 2.00000000000000003e-251 < (*.f64 (*.f64 z 9) t) < 5e219Initial program 96.0%
associate-*l*95.9%
Simplified95.9%
Final simplification95.5%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) 5e+298) (/ (- (* x y) (* z (* t 9.0))) (* a 2.0)) (* 0.5 (* y (/ x a)))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= 5e+298) {
tmp = ((x * y) - (z * (t * 9.0))) / (a * 2.0);
} else {
tmp = 0.5 * (y * (x / a));
}
return tmp;
}
NOTE: x and y 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+298) then
tmp = ((x * y) - (z * (t * 9.0d0))) / (a * 2.0d0)
else
tmp = 0.5d0 * (y * (x / a))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= 5e+298) {
tmp = ((x * y) - (z * (t * 9.0))) / (a * 2.0);
} else {
tmp = 0.5 * (y * (x / a));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= 5e+298: tmp = ((x * y) - (z * (t * 9.0))) / (a * 2.0) else: tmp = 0.5 * (y * (x / a)) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= 5e+298) tmp = Float64(Float64(Float64(x * y) - Float64(z * Float64(t * 9.0))) / Float64(a * 2.0)); else tmp = Float64(0.5 * Float64(y * Float64(x / a))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= 5e+298)
tmp = ((x * y) - (z * (t * 9.0))) / (a * 2.0);
else
tmp = 0.5 * (y * (x / a));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], 5e+298], N[(N[(N[(x * y), $MachinePrecision] - N[(z * N[(t * 9.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(a * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq 5 \cdot 10^{+298}:\\
\;\;\;\;\frac{x \cdot y - z \cdot \left(t \cdot 9\right)}{a \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y \cdot \frac{x}{a}\right)\\
\end{array}
\end{array}
if (*.f64 x y) < 5.0000000000000003e298Initial program 90.2%
associate-*l*90.2%
Simplified90.2%
if 5.0000000000000003e298 < (*.f64 x y) Initial program 56.9%
associate-*l*56.9%
Simplified56.9%
Taylor expanded in x around inf 61.4%
associate-/l*95.3%
associate-/r/95.5%
Simplified95.5%
Final simplification90.6%
NOTE: x and y should be sorted in increasing order before calling this function.
(FPCore (x y z t a)
:precision binary64
(let* ((t_1 (* 0.5 (* y (/ x a)))) (t_2 (* -4.5 (/ t (/ a z)))))
(if (<= z -2.05e+101)
t_2
(if (<= z -8.5e+59)
t_1
(if (<= z -2.5e+49)
(* -4.5 (/ (* z t) a))
(if (<= z 4e-43) t_1 t_2))))))assert(x < y);
double code(double x, double y, double z, double t, double a) {
double t_1 = 0.5 * (y * (x / a));
double t_2 = -4.5 * (t / (a / z));
double tmp;
if (z <= -2.05e+101) {
tmp = t_2;
} else if (z <= -8.5e+59) {
tmp = t_1;
} else if (z <= -2.5e+49) {
tmp = -4.5 * ((z * t) / a);
} else if (z <= 4e-43) {
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, 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) :: t_2
real(8) :: tmp
t_1 = 0.5d0 * (y * (x / a))
t_2 = (-4.5d0) * (t / (a / z))
if (z <= (-2.05d+101)) then
tmp = t_2
else if (z <= (-8.5d+59)) then
tmp = t_1
else if (z <= (-2.5d+49)) then
tmp = (-4.5d0) * ((z * t) / a)
else if (z <= 4d-43) 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 a) {
double t_1 = 0.5 * (y * (x / a));
double t_2 = -4.5 * (t / (a / z));
double tmp;
if (z <= -2.05e+101) {
tmp = t_2;
} else if (z <= -8.5e+59) {
tmp = t_1;
} else if (z <= -2.5e+49) {
tmp = -4.5 * ((z * t) / a);
} else if (z <= 4e-43) {
tmp = t_1;
} else {
tmp = t_2;
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): t_1 = 0.5 * (y * (x / a)) t_2 = -4.5 * (t / (a / z)) tmp = 0 if z <= -2.05e+101: tmp = t_2 elif z <= -8.5e+59: tmp = t_1 elif z <= -2.5e+49: tmp = -4.5 * ((z * t) / a) elif z <= 4e-43: tmp = t_1 else: tmp = t_2 return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) t_1 = Float64(0.5 * Float64(y * Float64(x / a))) t_2 = Float64(-4.5 * Float64(t / Float64(a / z))) tmp = 0.0 if (z <= -2.05e+101) tmp = t_2; elseif (z <= -8.5e+59) tmp = t_1; elseif (z <= -2.5e+49) tmp = Float64(-4.5 * Float64(Float64(z * t) / a)); elseif (z <= 4e-43) 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, a)
t_1 = 0.5 * (y * (x / a));
t_2 = -4.5 * (t / (a / z));
tmp = 0.0;
if (z <= -2.05e+101)
tmp = t_2;
elseif (z <= -8.5e+59)
tmp = t_1;
elseif (z <= -2.5e+49)
tmp = -4.5 * ((z * t) / a);
elseif (z <= 4e-43)
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_, a_] := Block[{t$95$1 = N[(0.5 * N[(y * N[(x / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(-4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.05e+101], t$95$2, If[LessEqual[z, -8.5e+59], t$95$1, If[LessEqual[z, -2.5e+49], N[(-4.5 * N[(N[(z * t), $MachinePrecision] / a), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 4e-43], t$95$1, t$95$2]]]]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
t_1 := 0.5 \cdot \left(y \cdot \frac{x}{a}\right)\\
t_2 := -4.5 \cdot \frac{t}{\frac{a}{z}}\\
\mathbf{if}\;z \leq -2.05 \cdot 10^{+101}:\\
\;\;\;\;t_2\\
\mathbf{elif}\;z \leq -8.5 \cdot 10^{+59}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -2.5 \cdot 10^{+49}:\\
\;\;\;\;-4.5 \cdot \frac{z \cdot t}{a}\\
\mathbf{elif}\;z \leq 4 \cdot 10^{-43}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_2\\
\end{array}
\end{array}
if z < -2.05e101 or 4.00000000000000031e-43 < z Initial program 82.6%
associate-*l*82.6%
Simplified82.6%
Taylor expanded in x around 0 62.8%
associate-/l*73.5%
Simplified73.5%
if -2.05e101 < z < -8.4999999999999999e59 or -2.5000000000000002e49 < z < 4.00000000000000031e-43Initial program 92.1%
associate-*l*92.1%
Simplified92.1%
Taylor expanded in x around inf 64.4%
associate-/l*66.2%
associate-/r/69.5%
Simplified69.5%
if -8.4999999999999999e59 < z < -2.5000000000000002e49Initial program 80.7%
associate-*l*80.7%
Simplified80.7%
Taylor expanded in x around 0 61.5%
Final simplification71.3%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (or (<= (* x y) -5e+67) (not (<= (* x y) 5e-13))) (* 0.5 (/ x (/ a y))) (* -4.5 (/ t (/ a z)))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -5e+67) || !((x * y) <= 5e-13)) {
tmp = 0.5 * (x / (a / y));
} else {
tmp = -4.5 * (t / (a / z));
}
return tmp;
}
NOTE: x and y 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+67)) .or. (.not. ((x * y) <= 5d-13))) then
tmp = 0.5d0 * (x / (a / y))
else
tmp = (-4.5d0) * (t / (a / z))
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if (((x * y) <= -5e+67) || !((x * y) <= 5e-13)) {
tmp = 0.5 * (x / (a / y));
} else {
tmp = -4.5 * (t / (a / z));
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if ((x * y) <= -5e+67) or not ((x * y) <= 5e-13): tmp = 0.5 * (x / (a / y)) else: tmp = -4.5 * (t / (a / z)) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if ((Float64(x * y) <= -5e+67) || !(Float64(x * y) <= 5e-13)) tmp = Float64(0.5 * Float64(x / Float64(a / y))); else tmp = Float64(-4.5 * Float64(t / Float64(a / z))); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if (((x * y) <= -5e+67) || ~(((x * y) <= 5e-13)))
tmp = 0.5 * (x / (a / y));
else
tmp = -4.5 * (t / (a / z));
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[Or[LessEqual[N[(x * y), $MachinePrecision], -5e+67], N[Not[LessEqual[N[(x * y), $MachinePrecision], 5e-13]], $MachinePrecision]], N[(0.5 * N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+67} \lor \neg \left(x \cdot y \leq 5 \cdot 10^{-13}\right):\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}}\\
\mathbf{else}:\\
\;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\
\end{array}
\end{array}
if (*.f64 x y) < -4.99999999999999976e67 or 4.9999999999999999e-13 < (*.f64 x y) Initial program 84.7%
associate-*l*84.8%
Simplified84.8%
Taylor expanded in x around inf 70.4%
associate-/l*77.7%
Simplified77.7%
if -4.99999999999999976e67 < (*.f64 x y) < 4.9999999999999999e-13Initial program 89.7%
associate-*l*89.6%
Simplified89.6%
Taylor expanded in x around 0 71.6%
associate-/l*78.1%
Simplified78.1%
Final simplification77.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (if (<= (* x y) -5e+67) (* 0.5 (/ x (/ a y))) (if (<= (* x y) 5e-13) (* -4.5 (/ t (/ a z))) (* (* x 0.5) (/ y a)))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -5e+67) {
tmp = 0.5 * (x / (a / y));
} else if ((x * y) <= 5e-13) {
tmp = -4.5 * (t / (a / z));
} else {
tmp = (x * 0.5) * (y / a);
}
return tmp;
}
NOTE: x and y 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+67)) then
tmp = 0.5d0 * (x / (a / y))
else if ((x * y) <= 5d-13) then
tmp = (-4.5d0) * (t / (a / z))
else
tmp = (x * 0.5d0) * (y / a)
end if
code = tmp
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
double tmp;
if ((x * y) <= -5e+67) {
tmp = 0.5 * (x / (a / y));
} else if ((x * y) <= 5e-13) {
tmp = -4.5 * (t / (a / z));
} else {
tmp = (x * 0.5) * (y / a);
}
return tmp;
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): tmp = 0 if (x * y) <= -5e+67: tmp = 0.5 * (x / (a / y)) elif (x * y) <= 5e-13: tmp = -4.5 * (t / (a / z)) else: tmp = (x * 0.5) * (y / a) return tmp
x, y = sort([x, y]) function code(x, y, z, t, a) tmp = 0.0 if (Float64(x * y) <= -5e+67) tmp = Float64(0.5 * Float64(x / Float64(a / y))); elseif (Float64(x * y) <= 5e-13) tmp = Float64(-4.5 * Float64(t / Float64(a / z))); else tmp = Float64(Float64(x * 0.5) * Float64(y / a)); end return tmp end
x, y = num2cell(sort([x, y])){:}
function tmp_2 = code(x, y, z, t, a)
tmp = 0.0;
if ((x * y) <= -5e+67)
tmp = 0.5 * (x / (a / y));
elseif ((x * y) <= 5e-13)
tmp = -4.5 * (t / (a / z));
else
tmp = (x * 0.5) * (y / a);
end
tmp_2 = tmp;
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := If[LessEqual[N[(x * y), $MachinePrecision], -5e+67], N[(0.5 * N[(x / N[(a / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(x * y), $MachinePrecision], 5e-13], N[(-4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * 0.5), $MachinePrecision] * N[(y / a), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot y \leq -5 \cdot 10^{+67}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{a}{y}}\\
\mathbf{elif}\;x \cdot y \leq 5 \cdot 10^{-13}:\\
\;\;\;\;-4.5 \cdot \frac{t}{\frac{a}{z}}\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot 0.5\right) \cdot \frac{y}{a}\\
\end{array}
\end{array}
if (*.f64 x y) < -4.99999999999999976e67Initial program 82.8%
associate-*l*82.8%
Simplified82.8%
Taylor expanded in x around inf 78.5%
associate-/l*82.7%
Simplified82.7%
if -4.99999999999999976e67 < (*.f64 x y) < 4.9999999999999999e-13Initial program 89.7%
associate-*l*89.6%
Simplified89.6%
Taylor expanded in x around 0 71.6%
associate-/l*78.1%
Simplified78.1%
if 4.9999999999999999e-13 < (*.f64 x y) Initial program 85.9%
associate-*l*85.9%
Simplified85.9%
div-inv85.9%
fma-neg87.2%
distribute-rgt-neg-in87.2%
*-commutative87.2%
distribute-rgt-neg-in87.2%
metadata-eval87.2%
*-commutative87.2%
associate-/r*87.2%
metadata-eval87.2%
Applied egg-rr87.2%
Taylor expanded in x around inf 65.7%
associate-*r/65.6%
Applied egg-rr65.6%
*-commutative65.6%
associate-*r*65.6%
*-un-lft-identity65.6%
times-frac74.3%
Applied egg-rr74.3%
Final simplification77.8%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* -4.5 (* z (/ t a))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
return -4.5 * (z * (t / a));
}
NOTE: x and y 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) * (z * (t / a))
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
return -4.5 * (z * (t / a));
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): return -4.5 * (z * (t / a))
x, y = sort([x, y]) function code(x, y, z, t, a) return Float64(-4.5 * Float64(z * Float64(t / a))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z, t, a)
tmp = -4.5 * (z * (t / a));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(-4.5 * N[(z * N[(t / a), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
-4.5 \cdot \left(z \cdot \frac{t}{a}\right)
\end{array}
Initial program 87.3%
associate-*l*87.3%
Simplified87.3%
Taylor expanded in x around 0 49.9%
associate-/l*54.4%
Simplified54.4%
associate-/r/51.9%
Applied egg-rr51.9%
Final simplification51.9%
NOTE: x and y should be sorted in increasing order before calling this function. (FPCore (x y z t a) :precision binary64 (* -4.5 (/ t (/ a z))))
assert(x < y);
double code(double x, double y, double z, double t, double a) {
return -4.5 * (t / (a / z));
}
NOTE: x and y 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 / (a / z))
end function
assert x < y;
public static double code(double x, double y, double z, double t, double a) {
return -4.5 * (t / (a / z));
}
[x, y] = sort([x, y]) def code(x, y, z, t, a): return -4.5 * (t / (a / z))
x, y = sort([x, y]) function code(x, y, z, t, a) return Float64(-4.5 * Float64(t / Float64(a / z))) end
x, y = num2cell(sort([x, y])){:}
function tmp = code(x, y, z, t, a)
tmp = -4.5 * (t / (a / z));
end
NOTE: x and y should be sorted in increasing order before calling this function. code[x_, y_, z_, t_, a_] := N[(-4.5 * N[(t / N[(a / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
[x, y] = \mathsf{sort}([x, y])\\
\\
-4.5 \cdot \frac{t}{\frac{a}{z}}
\end{array}
Initial program 87.3%
associate-*l*87.3%
Simplified87.3%
Taylor expanded in x around 0 49.9%
associate-/l*54.4%
Simplified54.4%
Final simplification54.4%
(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 2023297
(FPCore (x y z t a)
:name "Diagrams.Solve.Polynomial:cubForm from diagrams-solve-0.1, I"
:precision binary64
:herbie-target
(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)))))
(/ (- (* x y) (* (* z 9.0) t)) (* a 2.0)))